/// <summary> /// Закрытие окна /// </summary> void CloseWindow() { //запись текущих настроек в файл JsonFileProvider <AppSettings> settingsService = new JsonFileProvider <AppSettings>(); settingsService.Save(AppSettings.GetSettings(), Properties.Settings.Default.AppSettingsFileName); }
public void GetDictionary_TwoUpdatesOneBigger_ReturnsAppropriatelyShapedDict() { //Arrange SelectLanguageFile("empty"); var jfp = new JsonFileProvider(Path); var key1 = "greeting"; var key2 = "approving"; IEnumerable <TextLocalization> localizations1 = GreetingsExamplePlusIndonesian; IEnumerable <TextLocalization> localizations2 = AcceptExample; IList <CultureInfo> containingLanguagesPlusID = new List <CultureInfo> { new CultureInfo("id") }.Concat(ContainingLanguages).ToList(); //Act jfp.Update(key1, localizations1); jfp.Update(key2, localizations2); var dict = jfp.GetDictionary(); //Assert Assert.IsTrue(dict.Keys.ToList().All(containingLanguagesPlusID.Contains)); Assert.AreEqual(containingLanguagesPlusID.Count, dict.Count); VerifyDictionary(dict, key1, localizations1); VerifyDictionary(dict, key2, localizations2); Assert.AreEqual(1, dict[containingLanguagesPlusID[0]].Count); Assert.AreEqual(2, dict[containingLanguagesPlusID[1]].Count); Assert.AreEqual(2, dict[containingLanguagesPlusID[2]].Count); Assert.AreEqual(2, dict[containingLanguagesPlusID[3]].Count); Assert.AreEqual(2, dict[containingLanguagesPlusID[4]].Count); }
public void GetDictionary_TwoUpdatesOneSmaller_ReturnsAppropriatelyShapedDict() { //Arrange SelectLanguageFile("empty"); var jfp = new JsonFileProvider(Path); var key1 = "greeting"; var key2 = "approving"; IEnumerable <TextLocalization> localizations1 = GreetingsExampleMinusGerman; IEnumerable <TextLocalization> localizations2 = AcceptExample; //Act jfp.Update(key1, localizations1); jfp.Update(key2, localizations2); var dict = jfp.GetDictionary(); //Assert Assert.IsTrue(dict.Keys.ToList().All(ContainingLanguages.Contains)); Assert.AreEqual(ContainingLanguages.Count, dict.Count); VerifyDictionary(dict, key1, localizations1); VerifyDictionary(dict, key2, localizations2); Assert.AreEqual(2, dict[ContainingLanguages[0]].Count); Assert.AreEqual(2, dict[ContainingLanguages[1]].Count); Assert.AreEqual(1, dict[ContainingLanguages[2]].Count); Assert.AreEqual(2, dict[ContainingLanguages[3]].Count); }
public void GetDictionary_NormalUpdateThenUpdateWithEmptyLocalizations_DictUpdatedOnce() { //Arrange SelectLanguageFile("empty"); var Jfp = new JsonFileProvider(Path); var key1 = "greeting"; var key2 = "approving"; IEnumerable <TextLocalization> localizations1 = GreetingsExample; IEnumerable <TextLocalization> localizations2 = new List <TextLocalization>(); //Act Jfp.Update(key1, localizations1); Jfp.Update(key2, localizations2); var dict = Jfp.GetDictionary(); //Assert Assert.IsTrue(dict.Keys.ToList().All(ContainingLanguages.Contains)); Assert.AreEqual(ContainingLanguages.Count, dict.Count); VerifyDictionary(dict, key1, localizations1); Assert.AreEqual(1, dict[ContainingLanguages[0]].Count); Assert.AreEqual(1, dict[ContainingLanguages[1]].Count); Assert.AreEqual(1, dict[ContainingLanguages[2]].Count); Assert.AreEqual(1, dict[ContainingLanguages[3]].Count); }
public void DefaultConfiguration() { if (_provider == null) { var basePath = AppDomain.CurrentDomain.BaseDirectory; var cfgFilePath = Path.Combine(basePath, "secrets.json"); var fileProvider = new JsonFileProvider(cfgFilePath); ConfigureProvider(fileProvider); } }
public void Update_NullKey_ThrowsArgumentNullException() { //Arrange SelectLanguageFile("empty"); var jfp = new JsonFileProvider(Path); IEnumerable <TextLocalization> localizations = GreetingsExample; //Act //Assert Assert.ThrowsException <ArgumentNullException>(() => jfp.Update(null, localizations)); }
/// <summary> /// Загрузка исходный данных /// </summary> /// <param name="devices"></param> public void LoadSource(List <Device> devices) { Devices = devices; AppSettings settings = AppSettings.GetSettings(); JsonFileProvider <DeviceTypeInfos> typeInfosService = new JsonFileProvider <DeviceTypeInfos>(); TypeInfos = typeInfosService.Load(settings.DefaultTypeInfosFilePath).TypeInfos; JsonFileProvider <Dictionary <string, int> > typeOffsetService = new JsonFileProvider <Dictionary <string, int> >(); TypeOffset = typeOffsetService.Load(settings.DefaultTypeOffsetFilePath); }
public void LoadingFiles_NoLanguages_FileProviderIsInStateEmpty() { //Arrange SelectLanguageFile("no languages"); //Act var efp = new JsonFileProvider(Path); //Assert Assert.AreEqual(ProviderStatus.Empty, efp.Status); }
public void LoadingFiles_Some_GetDictionaryReturnsAppropriateNumberOfEntries() { //Arrange SelectLanguageFile("some"); var efp = new JsonFileProvider(Path); //Act var dict = efp.GetDictionary(); //Assert Assert.AreEqual(ContainingLanguages.Count, dict.Count); Assert.IsTrue(AllDictionariesAreSize(dict, NumberOfEntriesInSomeFile)); }
public MainWindowViewModel() { OpenDeviceFileCmd = new DelegateCommand(OpenDeviceFile, CanOpenDeviceFile); SaveDeviceFileCmd = new DelegateCommand(SaveDeviceFile, CanSaveDeviceFile); GenModBusTableCmd = new DelegateCommand(GenModBusTable, CanGenModBusTable); OpenSettingsWindowCmd = new DelegateCommand(OpenSettingsWindow, CanOpenSettingsWindow); CloseWindowCommand = new DelegateCommand(CloseWindow, CanCloseWindow); SelectedDevice = new Device(); //считывание текущих настроек из файла if (File.Exists(Properties.Settings.Default.AppSettingsFileName)) { JsonFileProvider <AppSettings> settingsService = new JsonFileProvider <AppSettings>(); AppSettings.SetSettings(settingsService.Load(Properties.Settings.Default.AppSettingsFileName)); } }
public void GetDictionary_NoUpdate_ReturnDictHasEmptyInnerDicts() { //Arrange SelectLanguageFile("empty"); var jfp = new JsonFileProvider(Path); //Act var dict = jfp.GetDictionary(); //Assert Assert.IsTrue(dict.Keys.ToList().All(ContainingLanguages.Contains)); Assert.AreEqual(ContainingLanguages.Count, dict.Count); Assert.AreEqual(0, dict[ContainingLanguages[0]].Count); Assert.AreEqual(0, dict[ContainingLanguages[1]].Count); Assert.AreEqual(0, dict[ContainingLanguages[2]].Count); Assert.AreEqual(0, dict[ContainingLanguages[3]].Count); }
private void OnStartup(object sender, StartupEventArgs e) { Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); var consoleLoggerFactory = LoggerFactory.Create(builder => { builder .SetMinimumLevel(LogLevel.Information) .AddConsole(); }); GlobalSettings.LibraryLoggerFactory = consoleLoggerFactory; IFileProvider jfp = new JsonFileProvider("Resource/Resource_Corrections.json"); //IFileProvider efp = new ExcelFileProvider("Resource/Corrections_as_excel.xlsx"); ResourceLiteralProvider.Initialize(jfp, new CultureInfo("en")); }
public void GetDictionary_NormalUpdate_ReturnsUpdatedDict() { //Arrange SelectLanguageFile("empty"); var jfp = new JsonFileProvider(Path); var key = "greeting"; IEnumerable <TextLocalization> localizations = GreetingsExample; //Act jfp.Update(key, localizations); var dict = jfp.GetDictionary(); //Assert Assert.IsTrue(dict.Keys.ToList().All(ContainingLanguages.Contains)); Assert.AreEqual(ContainingLanguages.Count, dict.Count); VerifyDictionary(dict, key, localizations); Assert.AreEqual(1, dict[ContainingLanguages[0]].Count); Assert.AreEqual(1, dict[ContainingLanguages[1]].Count); Assert.AreEqual(1, dict[ContainingLanguages[2]].Count); Assert.AreEqual(1, dict[ContainingLanguages[3]].Count); }