Example #1
0
        public void CreateNonExistantConfigurationStream()
        {
            AssertFileDoesNotExist("./CreateNonExistantConfiguration.xml");
            var config = new njFileConfiguration(new FileStream("./CreateNonExistantConfiguration.xml", FileMode.CreateNew), true);

            config.LoadConfiguration();
            Assert.IsTrue(config.IsValid);
            config.Dispose();
        }
Example #2
0
        public void ReadOnlyNonExistantConfiguration()
        {
            AssertFileDoesNotExist("./ReadOnlyNonExistantConfiguration.xml");
            var config = new njFileConfiguration("./ReadOnlyNonExistantConfiguration.xml", false);

            config.LoadConfiguration();
            Assert.IsFalse(config.IsValid);
            config.Dispose();
        }
Example #3
0
        public void OpenSimpleConfigOneEntryStream()
        {
            var config = new njFileConfiguration(new FileStream("./TestData/SimpleConfigOneEntry.xml", FileMode.Open), false);

            config.LoadConfiguration();
            Assert.IsTrue(config.IsValid);
            Assert.AreEqual(1, config?.Count, "Falsche Anzahl an Items");

            config.Dispose();
        }
Example #4
0
        private void CloseTestConfig(string strName, njFileConfiguration config)
        {
            if (!config.CanWrite)
            {
                config.Dispose();
            }
            else
            {
                config.SaveConfiguration();
                config.Dispose();

                Assert.IsTrue(File.Exists("./TestData-Verify/" + strName), "Verify-Datei fehlt!");

                Diff d = DiffBuilder.Compare(Input.FromString(File.ReadAllText("./TestData-TestWrite/" + strName)))
                         .WithTest(Input.FromString(File.ReadAllText("./TestData-Verify/" + strName)))
                         .Build();
                Assert.IsFalse(d.HasDifferences(), "Datei ist nach dem Schreibvorgang nicht identisch mit Verify-Datei");
                File.Delete("./TestData-TestWrite/" + strName);
            }
        }