예제 #1
0
        public void GetKeysTest()
        {
            var dictionary = SettingsLoader.CreateDictionary <string, string>();

            Assert.That(dictionary, Is.DeepEqualTo(
                            new Dictionary <string, string>
            {
                { "Bar", "14" },
                { "Baz", "hello world" },
                { "Foo", "Foo from database" },
            }));
        }
예제 #2
0
        public void DirectDictionaryLoadTest()
        {
            var dict = SettingsLoader.CreateDictionary <string, Nested>(nameof(DictionarySettings.MyDictionaryProperty));

            Assert.That(dict, Is.DeepEqualTo(
                            new Dictionary <string, Nested>
            {
                { "Key1", new Nested {
                      Foo = "oof1", Bar = 421
                  } },
                { "Key2", new Nested {
                      Foo = "oof2", Bar = 422
                  } }
            }).WithComparisonConfig(new ComparisonConfig()
            {
                IgnoreCollectionOrder = true
            }));
        }
예제 #3
0
        public void EnumDictionaryLoadTest()
        {
            var settings = SettingsLoader.CreateDictionary <AnimalType, Animal>("Animals");

            // Dictionary with non string TKey
            Assert.That(settings, Is.DeepEqualTo(
                            new Dictionary <AnimalType, Animal>
            {
                { AnimalType.Parrot, new Animal {
                      Name = "Polly", Talks = true
                  } },
                { AnimalType.Rabbit, new Animal {
                      Name = "Beatrice", Talks = false
                  } },
                { AnimalType.Fox, new Animal {
                      Name = "John", Talks = false
                  } },
            }).WithComparisonConfig(new ComparisonConfig()
            {
                IgnoreCollectionOrder = true
            }));
        }