예제 #1
0
        public async Task SaveNewPresetTest_正常()
        {
            appSettings.AppDataPath = @"C:\AppData";
            settingService.UserSettings.MergeUnknownJsonProperty = true;
            target.ConfigJson.CharacterModels.Add(100);
            var name = "プリセットその1";

            await target.SaveNewPresetAsync(name);

            Assert.IsFalse(target.IsBusy);
            CollectionAssert.AreEqual(new[] { nameof(ConfigJsonService.IsBusy), nameof(ConfigJsonService.CurrentPreset), nameof(ConfigJsonService.IsBusy) }, notifiedProperies);
            Assert.IsTrue(Guid.TryParse(target.CurrentPreset.Id, out var _));
            Assert.IsFalse(target.ConfigJson.IsChanged);

            var preset = settingService.UserSettings.PresetInfos[0];

            Assert.AreEqual(name, preset.Name);
            Assert.AreEqual(target.CurrentPreset.Id, preset.Id);
            StringAssert.StartsWith(preset.FileName, name);
            StringAssert.EndsWith(preset.FileName, preset.Id + ".json");

            Assert.AreEqual(Path.Combine(appSettings.AppDataPath, preset.Name + "_" + preset.Id + ".json"), fileService.WriteAsyncPath);

            Assert.IsTrue(settingService.SaveAsyncCalled);
        }
예제 #2
0
        /// <summary>
        /// 新規プリセット保存
        /// </summary>
        public async void SaveAs()
        {
            var dlgVm = new NewPresetDialogViewModel();

            Messenger.Raise(new TransitionMessage(dlgVm, "NewPresetDialog"));

            if (dlgVm.IsOk)
            {
                await ConfigJsonService.SaveNewPresetAsync(dlgVm.PresetName);
            }
        }