Elfocrash / Cosmonaut

šŸŒ A supercharged Azure CosmosDB .NET SDK with ORM support
https://cosmonaut.readthedocs.io
MIT License
342 stars 44 forks source link

CosmosResponse to interface #40

Closed MatsJakobsson closed 5 years ago

MatsJakobsson commented 5 years ago

Hi,

Is it possible to rewrite so that AddAsync (and similiar) in ICosmosStore returns some form of interface instead of CosmosResponse. This would simplify mocking/testing a lot.

Many thanks!

Elfocrash commented 5 years ago

Hello @MatsJakobsson and thanks for opening this.

Up until 2.5.0 the constructor for CosmosResponse was public and I accidentally set it back to internal. The idea was that if people wanted to wrap their CosmosDB responses with this single response object, they should be able to. I don't know how this will be in 3.0 but for now I am changing back to public as it would be a breaking change.

This should allow you to to create the object on your Mocking framework's Returns method. Does that sound ok?

MatsJakobsson commented 5 years ago

Wow! You are fast! :)

Sounds great! An interface would be even more flexible, but a public constructor would simplify a lot.

Thanks!

Elfocrash commented 5 years ago

Public constructors added back in 2.6.2. Feel free to upgrade. Donā€™t forget to read the response handling sector of the readme page.

Yeah I think Iā€™ll have to rethink some appoaches in 3.0, this one included. The end goal would be an interface but I canā€™t massively change interfaces without a major release atm.

Thanks for raising this issue and thanks for using Cosmonaut. Closing this for now. Feel free to open a new issue if you find some problem.