コード例 #1
0
        public void ReadYamlFileTest()
        {
            IFileIO     reader = new YamlFileIO();
            FooSettings foo    = reader.Read(typeof(FooSettings), FoobarPath.FilePath) as FooSettings;

            Assert.AreEqual(10, foo.Foo);
            Assert.AreEqual(20, foo.Bar);
        }
コード例 #2
0
        public void ScenarioTest()
        {
            IFileIO io     = new YamlFileIO();
            var     loader = new SettingsLoader <FooSettings>(io, FoobarPath.FilePath);
            var     foo    = loader.Settings;

            Assert.AreEqual(10, foo.Foo);
            Assert.AreEqual(20, foo.Bar);
        }
コード例 #3
0
        public void WriteYamlFileTest()
        {
            FooSettings foo = new FooSettings()
            {
                Foo = 10, Bar = 20
            };
            IFileIO writer = new YamlFileIO();

            writer.Write(typeof(FooSettings), foo, FoobarPath.FilePath);

            Assert.AreEqual(true, File.Exists(FoobarPath.FilePath));
        }
コード例 #4
0
        public void ElementRemoved()
        {
            YamlFileIO file = new YamlFileIO(AssertExceptionFail);
            var        data = file.Read(typeof(ThemeRemoved), TestPath.FilePath) as ThemeRemoved;

            data.ItemsCountPerPage = 88;
            file.Write(typeof(ThemeRemoved), data, TestPath.FilePath);

            var newData = file.Read(typeof(ThemeRemoved), TestPath.FilePath) as ThemeRemoved;

            Assert.AreEqual(true, newData.UseMigemo);
            Assert.AreEqual(88, newData.ItemsCountPerPage);
        }
コード例 #5
0
        public void CreateNew()
        {
            Assert.AreEqual(false, File.Exists(TestPath.FilePath));

            YamlFileIO file = new YamlFileIO(AssertExceptionFail);
            var        data = file.Read(typeof(TestStorage), TestPath.FilePath) as TestStorage;

            Assert.AreEqual(true, File.Exists(TestPath.FilePath));

            Assert.AreEqual(15, data.ItemsCountPerPage);
            Assert.AreEqual("General", data.Theme);
            Assert.AreEqual(true, data.UseMigemo);
        }
コード例 #6
0
        public void ElementAdded()
        {
            YamlFileIO file = new YamlFileIO(AssertExceptionFail);
            var        data = file.Read(typeof(TestStorage), TestPath.FilePath) as TestStorage;

            data.Theme = "Added";
            file.Write(typeof(TestStorage), data, TestPath.FilePath);

            var newData = file.Read(typeof(TestStorage), TestPath.FilePath) as TestStorage;

            Assert.AreEqual("Added", newData.Theme);
            Assert.AreEqual(88, newData.ItemsCountPerPage);
            Assert.AreEqual(true, newData.UseMigemo);
        }
コード例 #7
0
 public void RaiseException()
 {
     try
     {
         YamlFileIO file = new YamlFileIO((filename, ex) =>
         {
             throw ex;
         });
         var data = file.Read(typeof(ExceptionRaised), TestPath.FilePath) as ExceptionRaised;
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.WriteLine($"{ex.Message}\n{ex.StackTrace}");
         return;
     }
     Assert.Fail();
 }
コード例 #8
0
 private UIAssistantAPI()
 {
     DefaultSettingsFileIO = new YamlFileIO((path, ex) => NotificationAPI.NotifyWarnMessage("Load Settings Error", string.Format(LocalizationAPI.Localize(TextID.SettingsLoadError), path)));
     UIAssistantSettings   = DefaultSettingsFileIO.Read(typeof(UserSettings), UserSettings.FilePath) as UserSettings;
 }