Lessons learned:
- It is possible, to mock abstract classes and usual classes, it is impossible, to mock sealed classes.
- Only abstract and virtual methods can be mocked.
- Properties can be mocked the following way
public abstract class Entity
{
public abstract int Id { get; protected set; }
}
...
var mock = new Mock<Entity>();
mock.SetupProperty(entity => entity.Id, 5);
Keine Kommentare:
Kommentar veröffentlichen