Esempio n. 1
0
        public void FileInfoArrayTest()
        {
            var settings = SettingsLoader.CreateArray <FileInfo>("FileArray");

            // Defaults
            Assert.That(settings.Length, Is.EqualTo(2));
            Assert.That(settings[0].FullName, Is.EqualTo(Path.GetFullPath(Path.Combine(TestProjectFolder, @"..\Miracle.Settings.sln"))));
            Assert.That(settings[1].FullName, Is.EqualTo(@"c:\Windows\regedit.exe"));
        }
Esempio n. 2
0
        public void DirectSplitStringArrayLoadTest()
        {
            var numbers = SettingsLoader.CreateArray <int>("LostNumbers", new[] { ',' });

            Assert.That(numbers, Is.EqualTo(
                            new[]
            {
                4, 8, 15, 16, 23, 42
            }));
        }
Esempio n. 3
0
        public void DirectNumericArrayLoadTest()
        {
            var settings = SettingsLoader.CreateArray <int>("MyNumericArrayProperty");

            // Array
            Assert.That(settings, Is.DeepEqualTo(
                            new int[]
            {
                1, 2, 3, 4
            }));
        }
Esempio n. 4
0
        public void DirectStringArrayLoadTest()
        {
            var settings = SettingsLoader.CreateArray <string>("MySimpleArrayProperty");

            // Array
            Assert.That(settings, Is.EquivalentTo(
                            new[]
            {
                "Foo Primary", "Foo 1", "Foo 2"
            }));
        }
Esempio n. 5
0
        public void Test2()
        {
            var key = "FooIp";
            var ips = new[] { "42.41.40.39", "38.37.36.35" };
            var ip  = string.Join(",", ips);

            // Setup mock value provider
            var settingsLoader = new SettingsLoader(new DictionaryValueProvider(new Dictionary <string, string>
            {
                { key, ip }
            }));

            var ipAddresses = settingsLoader.CreateArray <IPAddress>(key, new[] { ',' });

            Assert.That(ipAddresses, Is.Not.Null);
            Assert.That(ipAddresses, Has.Length.EqualTo(2));
            Assert.That(ipAddresses, Is.EqualTo(ips.Select(IPAddress.Parse).ToArray()));
        }
Esempio n. 6
0
        public void DirectClassArrayLoadTest()
        {
            var settings = SettingsLoader.CreateArray <Nested>("MyArrayProperty");

            // Array
            Assert.That(settings, Is.DeepEqualTo(
                            new[]
            {
                new Nested {
                    Foo = "Foo Primary", Bar = 420
                },
                new Nested {
                    Foo = "Foo 1", Bar = 421
                },
                new Nested {
                    Foo = "Foo 2", Bar = 422
                },
            }).WithComparisonConfig(new ComparisonConfig()
            {
                IgnoreCollectionOrder = true
            }));
        }