Trying to mock a class provided by a vendor that contains a number of public fields.
Either I'm not arranging the mock properly or JustMock does not support mocking fields.
Sample code
// sample class to mock
public class HasFields
{
public string FieldA;
}
// code to set up mokc
var mock = Mock.Create<HasFields>();
Mock.Arrange (() => mock.FieldA).Returns("it works");
When executed the Mock.Arrange call throws the error:
Telerik.JustMock.MockAssertionException: Lambda must contain a valid method to procceed
In the test code if the field is changed to a property, the Mock.Arrange works.
Unfortunately changing the field to a property isn't an option with the classes provided by a vendor.
Either I'm not arranging the mock properly or JustMock does not support mocking fields.
Sample code
// sample class to mock
public class HasFields
{
public string FieldA;
}
// code to set up mokc
var mock = Mock.Create<HasFields>();
Mock.Arrange (() => mock.FieldA).Returns("it works");
When executed the Mock.Arrange call throws the error:
Telerik.JustMock.MockAssertionException: Lambda must contain a valid method to procceed
In the test code if the field is changed to a property, the Mock.Arrange works.
Unfortunately changing the field to a property isn't an option with the classes provided by a vendor.