I have class ImportProvider
, and I want write unit test for Import method.
But this should be unit test, so I don't want to read from file to stream. Any idea?
public class ImportProvider : IImportProvider
{
public bool Import(Stream stream)
{
//Do import
return isImported;
}
}
public interface IImportProvider
{
bool Import(Stream input);
}
This is unit test:
[TestMethod]
public void ImportProvider_Test()
{
// Arrange
var importRepository = new Mock<IImportRepository>();
var imp = new ImportProvider(importRepository.Object);
//Do setup...
// Act
var test_Stream = ?????????????
// This working but not option:
//test_Stream = File.Open("C:/ExcelFile.xls", FileMode.Open, FileAccess.Read);
var result = imp.Import(test_Stream);
// Assert
Assert.IsTrue(result);
}