Hello I have code like below and use xUnit. I would like to write TestClass to test my interface. Could you tell my how can I:
- inject different services to test class by DependencyInjection and run test for this services.
- prepare object to inject with Autofixture and AutoMoq. Before inject i would like to create services like
I want to do somethink like this :
public ServiceTestClass
{
private ISampleService sut;
public ServiceTestClass(ISampleService service) {
this.sut = service;
}
[Fact]
public MyTestMetod() {
// arrange
var fixture = new Fixture();
// act
sut.MakeOrder();
// assert
Assert(somethink);
}
}
public class SampleService : ISampleService // ande few services which implements ISampleService
{
// ISampleUow also include few IRepository
private readonly ISampleUow uow;
public SampleService(ISampleUow uow) {
this.uow = uow;
}
public void MakeOrder() {
//implementation which use uow
}
}