Consider the following test,
[Theory, MyConventions]
public void GetClientExtensionReturnsCorrectValue(BuilderStrategy sut)
{
var expected = ""; // <--??? the value injected into BuilderStrategy
var actual = sut.GetClientExtension();
Assert.Equal(expected, actual);
}
and the custom attribute I'm using:
public class MyConventionsAttribute : AutoDataAttribute {
public MyConventionsAttribute()
: base(new Fixture().Customize(new AutoMoqCustomization())) {}
}
and the SUT:
class BuilderStrategy {
private readonly string _clientID;
private readonly IDependency _dependency;
public void BuilderStrategy(string clientID, IDependency dependency) {
_clientID = clientID;
_dependency = dependency;
}
public string GetClientExtension() {
return _clientID.Substring(_clientID.LastIndexOf("-") + 1);
}
}
I need to know what value was injected into the constructor parameter clientID
so that I can use it to compare with the output of GetClientExtension
. Is it possible to do this while still writing this style of test where the SUT is injected into the test method?
IBuilderStrategy
whichBuilderStrategy
implements)? Also, I would think that it would be better to expose these properties as the need arises in unit testing, rather than expose all dependencies as a routine matter (although, I suppose that in practicing TDD, this would all happen naturally). Do you have an opinion on any of that? – Plataea