As a note, you can use the implicit constructor syntax to make the class declaration more enjoyable. You can also simplify readonly properties because you can omit with get() :
// F
As for testing - do you have an example of what you are trying to achieve? I am sure that we can help, for example, when translating code from C #. Or what tests would you like to write using mockery?
In general, the good thing about F # and functional languages ββis that you can usually easily test code without using any layouts. Functional programs are written in a different style:
In functional programming, a function takes all input as arguments, and the only thing it does is that it calculates and returns some result. This is also true for methods of immutable object types - they do not change any state of any objects
Mocks are usually used for two purposes:
To make sure that the checked operation made some call to the method of the reference object, for example. prod.Update(newPrice) to update the state of an object. However, in functional programming, a method should instead return a new state as a result - so you donβt need an object layout. Just check if the new return state is expected.
To load the created fake application component, for example, instead of loading data from the database. Again, a purely functional function should accept all nested arguments. This means that you do not need to create an object layout - you simply call the function with some test data as an argument (instead of data loaded from the database).
Thus, this means that in a well-designed functional program, you should be able to write all unit tests simply as checks that confirm that some function returns the expected result for the expected arguments. Of course, this is not entirely true in F #, because you may need to interact with other unclean .NET components (but you can only answer them if you give a more specific example).
source share