Tutorial by Examples

Sometimes you want to mock a class or an interface and have its properties behave as if they were simple getters and setters. As this is a common requirement, Moq provides a short cut method to setup all properties of a mock to store and retrieve values: // SetupAllProperties tells mock to impleme...
Sometimes you want to create a mock of a class that has a private setter: public class MockTarget { public virtual string PropertyToMock { get; private set; } } Or an interface that only defines a getter: public interface MockTarget { string PropertyToMock { get; } } In both ca...

Page 1 of 1