I have the following code in c♯ but can not work out how to test it; I need to test aMethodUnderTest. I can not change ABaseClass as it is in a library. But if I am to test AClass I need to be able to set what theThing returns. Does anyone have any ideas, or experience with this type of code testing?
public ABaseClass
{
protected ThingBaseClass theThing {get;}
public virtual ....
...
}
public AClassUnderTest : ABaseClass
{
public MyThing Thing
{
get
{
return (MyThing)base.theThing;
}
}
public void aMethedUnderTest()
{
Thing.doSomething();
}
}
Note: The initial value of theThing is null. theThing has no public setter.
I think you can create mock that inherits ABaseClass and then check if AClass.Thing returns the same result as ABaseClassMock.theThing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With