I am writing a unit test using xUnit for .Net core.
Below is the TestBase Class
public class TestBase : IDisposable
{
TestBase(string filename) {
...
stream = new MemoryStream(File.ReadAllBytes(Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, filename))));
}
public TestBase() : this("filename.csv") { }
public void Dispose() {
..
}
}
Here's how it's being used
public class FileProcessingServiceFacadeTest : IClassFixture<TestBase>
{
TestBase testBase { get; set; }
public FileProcessingServiceFacadeTest(TestBase testBase) {
this.testBase = testBase;
}
[Fact]
public void ProcessAsync() {
....
}
}
Because I don't know how to pass the parameter to the TestBase class using interface IClassFixture, I had to create a constructor that internally calls the parameter constructor.
Can I pass a parameter to interface IClassFixture without an additional constructor?