public void Load_BooleanCollection_ShouldLoad()
        {
            RoomSettingsDictionary<bool> settings1 = new RoomSettingsDictionary<bool>();
            settings1.Set("#testroom1", true);
            settings1.Set("#testroom2", false);

            string outputFile = Path.Combine(TestContext.ResultsDirectory, "settings.xml");
            // write it out
            settings1.Save(outputFile);

            // read it back in
            RoomSettingsDictionary<bool> settings2 = RoomSettingsDictionary<bool>.LoadFrom(outputFile);

            // get bool out
            bool s1_settings1 = settings1["#testroom1"];
            bool s1_settings2 = settings2["#testroom1"];
            bool s2_settings1 = settings1["#testroom2"];
            bool s2_settings2 = settings2["#testroom2"];

            Assert.AreEqual(settings1.Count, settings2.Count);
            ObjectAssert.AreEqual(s1_settings1, s1_settings2);
            ObjectAssert.AreEqual(s2_settings1, s2_settings2);
        }
        public void Load_CustomClassCollection_ShouldLoad()
        {
            RoomSettingsDictionary<Person> settings1 = new RoomSettingsDictionary<Person>();
            settings1.Set("#testroom1", new Person { FirstName = "jon", LastName = "smith" });
            settings1.Set("#testroom2", new Person { FirstName = "steve", LastName = "fox" });

            string outputFile = Path.Combine(TestContext.ResultsDirectory, "settings.xml");
            // write it out
            settings1.Save(outputFile);

            // read it back in
            RoomSettingsDictionary<Person> settings2 = RoomSettingsDictionary<Person>.LoadFrom(outputFile);

            // get people out
            Person p1_settings1 = settings1["#testroom1"];
            Person p1_settings2 = settings2["#testroom1"];
            Person p2_settings1 = settings1["#testroom2"];
            Person p2_settings2 = settings2["#testroom2"];

            Assert.AreEqual(settings1.Count, settings2.Count);
            ObjectAssert.AreEqual(p1_settings1, p1_settings2);
            ObjectAssert.AreEqual(p2_settings1, p2_settings2);
        }
        public void Save_ListOfBooleansCollection_ShouldSaveXml()
        {
            RoomSettingsDictionary<List<bool>> settings = new RoomSettingsDictionary<List<bool>>();
            settings.Set("#testroom1", new List<bool> { true, true, false });
            settings.Set("#testroom2", new List<bool> { false, false });

            string outputFile = Path.Combine(TestContext.ResultsDirectory, "settings.xml");
            settings.Save(outputFile);

            Assert.IsTrue(File.Exists(outputFile));
        }
        public void Save_CustomClassCollection_ShouldSaveXml()
        {
            RoomSettingsDictionary<Person> settings = new RoomSettingsDictionary<Person>();
            settings.Set("#testroom1", new Person { FirstName = "jon", LastName = "smith" });
            settings.Set("#testroom2", new Person { FirstName = "steve", LastName = "fox" });

            string outputFile = Path.Combine(TestContext.ResultsDirectory, "settings.xml");
            settings.Save(outputFile);

            Assert.IsTrue(File.Exists(outputFile));
        }
        public void Save_BooleanCollection_ShouldSaveXml()
        {
            RoomSettingsDictionary<bool> settings = new RoomSettingsDictionary<bool>();
            settings.Set("#testroom1", true);
            settings.Set("#testroom2", false);
            settings.Set("#testroom3", false);
            settings.Set("#testroom4", true);

            string outputFile = Path.Combine(TestContext.ResultsDirectory, "settings.xml");
            settings.Save(outputFile);

            Assert.IsTrue(File.Exists(outputFile));
        }
        public void Load_StringCollectionWithXmlInvalidCharacters_ShouldLoad()
        {
            RoomSettingsDictionary<string> settings1 = new RoomSettingsDictionary<string>();
            settings1.Set("#testroom1", "<b>Dude!</b>. This text can \"most\" certainly not be used in <strong>xml</strong>.");

            string outputFile = Path.Combine(TestContext.ResultsDirectory, "settings.xml");
            // write it out
            settings1.Save(outputFile);

            // read it back in
            RoomSettingsDictionary<string> settings2 = RoomSettingsDictionary<string>.LoadFrom(outputFile);

            // get bool out
            string s1_settings1 = settings1["#testroom1"];
            string s1_settings2 = settings2["#testroom1"];

            Assert.AreEqual(settings1.Count, settings2.Count);
            ObjectAssert.AreEqual(s1_settings1, s1_settings2);
        }
        public void Load_ListOfCustomClassCollection_ShouldLoad()
        {
            RoomSettingsDictionary<List<Person>> settings1 = new RoomSettingsDictionary<List<Person>>();
            settings1.Set("#testroom1", new List<Person> {
                new Person { FirstName = "jon", LastName = "smith" },
                new Person { FirstName = "steve", LastName = "fox" }
            });

            string outputFile = Path.Combine(TestContext.ResultsDirectory, "settings.xml");
            // write it out
            settings1.Save(outputFile);

            // read it back in
            RoomSettingsDictionary<List<Person>> settings2 = RoomSettingsDictionary<List<Person>>.LoadFrom(outputFile);

            // get the people out
            List<Person> p1_settings1 = settings1["#testroom1"];
            List<Person> p1_settings2 = settings2["#testroom1"];

            ObjectAssert.AreEqual(p1_settings1, p1_settings2);
        }
        public void Load_ListOfBooleansCollection_ShouldLoad()
        {
            RoomSettingsDictionary<List<bool>> settings1 = new RoomSettingsDictionary<List<bool>>();
            settings1.Set("#testroom1", new List<bool> { true, true, false });
            settings1.Set("#testroom2", new List<bool> { false, false });

            string outputFile = Path.Combine(TestContext.ResultsDirectory, "settings.xml");
            // write it out
            settings1.Save(outputFile);

            // read it back in
            RoomSettingsDictionary<List<bool>> settings2 = RoomSettingsDictionary<List<bool>>.LoadFrom(outputFile);

            // get the lists out
            List<bool> l1_settings1 = settings1["#testroom1"];
            List<bool> l1_settings2 = settings2["#testroom1"];
            List<bool> l2_settings1 = settings1["#testroom2"];
            List<bool> l2_settings2 = settings2["#testroom2"];

            ObjectAssert.AreEqual(l1_settings1, l1_settings2);
            ObjectAssert.AreEqual(l2_settings1, l2_settings2);
        }