LoadTextDocument() public method

Load text from a extension data file
public LoadTextDocument ( string fileName, bool memoryCache = false ) : string
fileName string File name
memoryCache bool Load file from memory cache if possible.
return string
Example #1
0
		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);
		}
Example #2
0
		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);
		}