public LoadTextDocument ( string fileName, bool memoryCache = false ) : string | ||
fileName | string | File name |
memoryCache | bool | Load file from memory cache if possible. |
return | string |
public void LoadTextDocument_CacheEnabledDefaultFile_DefaultFileFromCache() { // Assign FileReader.ClearCache(); _fs.Setup(x => x.File.Exists(It.Is<string>(d => d == "C:/WebSites/FooSite/App_Data/Foo.ru.txt"))).Returns(false); // Act _fileReader.LoadTextDocument("Foo.txt", true); _fileReader = new FileReader(DataPath, "en", _languageManagerProvider.Object); _fileReader.Setup(); var result = _fileReader.LoadTextDocument("Foo.txt", true); // Assert _fs.Verify(x => x.File.ReadAllText(It.IsAny<string>()), Times.Once); Assert.AreEqual("Dummy", result); }
public void LoadTextDocument_CacheEnabled_SecondTimeFromCache() { // Assign FileReader.ClearCache(); // Act _fileReader.LoadTextDocument("Foo.txt", true); _fileReader = new FileReader(DataPath, "en", _languageManagerProvider.Object); _fileReader.Setup(); var result = _fileReader.LoadTextDocument("Foo.txt", true); // Assert _fs.Verify(x => x.File.ReadAllText(It.IsAny<string>()), Times.Once); // ReSharper disable once StringLiteralTypo Assert.AreEqual("Тест", result); }