-
Notifications
You must be signed in to change notification settings - Fork 2
Stubs: Simple Property Usage
haven1433 edited this page Nov 21, 2018
·
1 revision
public interface IExample {
int PropertyWithGetter { get; }
bool PropertyWithSetter { set; }
double PropertyWithGetAndSet { get; set; }
}
The assignment operator can handle most simple scenarios for properties. Just assign the value you want the property to have.
var stub = new StubExample();
IExample example = stub;
// you can use the property the same whether the interface has a getter, a setter, or both.
stub.PropertyWithGetter = 12;
stub.PropertyWithGetAndSet = 3.0;
// from the interface, everything works as expected
Assert.Equal(12, example.PropertyWithGetter);
Assert.Equal(3.0, example.PropertyWithGetAndSet);