Relative Content

Tag Archive for c#unit-testingmoqexpression-bodied-members

How to mock an expression-bodied member that doesn’t have a getter

Context I have a class that has an expression-bodied member: public MyState { public List<Thing> Things { get; set; } public double SomeValue => Things.sum(thing => thing.Value); public double MyProperty { get; set; } } I need to write a unit test for a method Apply() whose signature looks like this: public OtherClass { public […]