As the commenters have noted, you are testing the class LongestRisingSequenceFinder
. Good unit tests dispense with other concerns, and test one thing. Instead, skip service resolution, which is a completely separate concern.
Your test should look like
[Theory]
[InlineData(new [] {4,3,5,8,5,0,0,-3}, new [] {3,5,8})]
public async Task CanFind(IEnumerable<int> data, IEnumerable<int> expected)
{
var finder = new LongestRisingSequenceFinder();
// a guess on usage...
var actual = finder.MethodOfFinder(...);
actual.Should().Equal(expected);
}
If you're truly wanting to test service resolution with a call to the method, this is an integration test. A test like that is going to require constructing a test server, doing all the dependency injection, etc. in the context of the server.
Simply creating an artificial container as your code shows and then calling the method adds no value to testing. Think about it this way; your code was creating a container with 1 entry for the sole purpose of getting an entry. That's a really complicated way to instead just do new
in your test, so adds no value.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…