Esempio n. 1
0
        public void AppSettingsLoader_Load_CollectionHandlesTypes()
        {
            var mockSettingsLoader = new SettingLoaderMock();

            mockSettingsLoader.Settings.Add("StringCollection", "string1,string2,string3");
            mockSettingsLoader.Settings.Add("IntCollection", "1,2,3");
            mockSettingsLoader.Settings.Add("EnumCollection", "Option0,Option1,Option2");

            var settings = new SettingsCollections();

            Assert.IsTrue(AppSettingsLoader.Load(mockSettingsLoader, ref settings), "Load returned false");

            CollectionAssert.AreEqual(
                mockSettingsLoader.Settings["StringCollection"].Split(','),
                settings.StringCollection.ToArray(),
                "String collection not set");

            CollectionAssert.AreEqual(
                mockSettingsLoader.Settings["IntCollection"].Split(',').Select(i => Int32.Parse(i)).ToArray(),
                settings.IntCollection.ToArray(),
                "Int collection not set");

            CollectionAssert.AreEqual(
                mockSettingsLoader.Settings["EnumCollection"].Split(',').Select(e => Enum.Parse(typeof(Option), e, false)).ToArray(),
                settings.EnumCollection.ToArray(),
                "Enum collection not set");
        }
Esempio n. 2
0
        public void AppSettingsLoader_Load_CollectionHandlesTypes()
        {
            var mockSettingsLoader = new SettingLoaderMock();

            mockSettingsLoader.Settings.Add("StringCollection", "string1,string2,string3");
            mockSettingsLoader.Settings.Add("IntCollection", "1,2,3");
            mockSettingsLoader.Settings.Add("EnumCollection", "Option0,Option1,Option2");

            var settings = new SettingsCollections();

            Assert.IsTrue(AppSettingsLoader.Load(mockSettingsLoader, ref settings), "Load returned false");

            CollectionAssert.AreEqual(
                mockSettingsLoader.Settings["StringCollection"].Split(','),
                settings.StringCollection.ToArray(),
                "String collection not set");

            CollectionAssert.AreEqual(
                mockSettingsLoader.Settings["IntCollection"].Split(',').Select(i => Int32.Parse(i)).ToArray(),
                settings.IntCollection.ToArray(),
                "Int collection not set");

            CollectionAssert.AreEqual(
                mockSettingsLoader.Settings["EnumCollection"].Split(',').Select(e => Enum.Parse(typeof(Option), e, false)).ToArray(),
                settings.EnumCollection.ToArray(),
                "Enum collection not set");
        }