public void ProvideTranslationFromHighlyPrioritizedSource() { var inMemorySource = new InMemorySource(); inMemorySource.SaveString("greeting", enCulture, "Hello from memory!"); CreateFileWithTranslations(localizationsFilePath, new [] { new LocalFileSource.StringTranslationRecord { TextCode = "greeting", CultureId = enCulture.LCID, Translation = "Hello from file!" } }); var localFileSource = new LocalFileSource(localizationsFilePath); var sourcesList = new LocalizationSourcesList(); var localizationFactory = new LocalizationFactory(sourcesList); localizationFactory.RegisterSource(inMemorySource, 0); localizationFactory.RegisterSource(localFileSource, 1); var code = new LocalizationCode("greeting"); var translatedString = localizationFactory.GetString(code); Assert.AreEqual("Hello from file!", translatedString); }
public async void TestLoadingFromCache() { var cacheSource = new LocalFileSource(localCacheFilePath); var vacanciesCsv = await cacheSource.GetSourceData(); Assert.NotEmpty(vacanciesCsv); }
public async void TestCacheReadAndWrite() { var cacheSource = new LocalFileSource(localCacheFilePath); var vacanciesCsv = await cacheSource.GetSourceData(); int nVacanciesOnFirstLoad = vacanciesCsv.Count; await cacheSource.UpdateCache(vacanciesCsv); int nVacanciesOnSecondLoad = (await cacheSource.GetSourceData()).Count; Assert.Equal(nVacanciesOnFirstLoad, nVacanciesOnSecondLoad); }
public void TestLoadLocalFile() { var src = new LocalFileSource(); SnowSharp.FileSystem.AddSource(src); src = new LocalFileSource(); src.SetDir("../../../OnWindows"); SnowSharp.FileSystem.AddSource(src); var s = SnowSharp.FileSystem.OpenFile("LocalFileSource.cs"); Console.WriteLine(new StreamReader(s).ReadToEnd()); }
public void RVSharpReadTest() { var source = new LocalFileSource(); source.Dir = "../../"; FileSystem.AddSource(source); var rvs = new RVSharp("RVSharpTest.rvs"); Console.WriteLine(rvs.Get <double>("Key_1")); Console.WriteLine(rvs.Get <int>("Key_2")); Console.WriteLine(rvs.Get <int>("Key_3")); Console.WriteLine(rvs.Get <string>("Key_4")); Console.WriteLine(rvs.Get <int>("Key_5")); Console.WriteLine(rvs.Get <string>("Key_6")); }
public void CSVReaderTest() { var source = new LocalFileSource(); source.Dir = "../../"; FileSystem.AddSource(source); CSVReader csv = new CSVReader("CSVTestFile.csv"); while (csv.EnumLine()) { while (!csv.IsLineEnd) { Console.Write(csv.Pop <string>() + "\t"); } Console.WriteLine(); } }