Я не хочу создавать файл на жестком диске каждый раз, когда запускаю тест.
Мне просто нужно sr.ReadToEnd(); будет моей ожидаемой строкой.
Код: Выделить всё
public class ConfigStore : IConfigStore
{
public string ReadFile(string FileName)
{
string result;
using(StreamReader sr=new StreamReader(FileName) )
{
result= sr.ReadToEnd();
}
//logic to be tested
return result+1;
}
}
Код: Выделить всё
[TestClass]
public class UnitTest2
{
[TestMethod]
public void Shoud_Add_1_To_File_Content()
{
//arrange
ConfigStore configStore = new ConfigStore();
//act
var returntype=configStore.ReadFile("config.json");
//assert
Assert.AreEqual ("test1",returntype);
}
}
Подробнее здесь: https://stackoverflow.com/questions/520 ... ding-files