Ejemplo n.º 1
0
        public void DictionaryLoadTest()
        {
            var settings = SettingsLoader.Create <DictionarySettings>();

            // Various Dictionarys
            Assert.That(settings.MySimpleDictionaryProperty, Is.EquivalentTo(
                            new Dictionary <string, string>
            {
                { "Foo", "oof" },
                { "Bar", "rab" }
            }));
            Assert.That(settings.MyNumericDictionaryProperty, Is.EquivalentTo(
                            new Dictionary <string, byte>
            {
                { "Foo", 14 },
                { "Bar", 42 }
            }));
            Assert.That(settings.MyDictionaryProperty, 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
            }));
        }
Ejemplo n.º 2
0
        public void ShouldReadCreatedWadFile()
        {
            var fileInfo = new FileInfo(Path.GetTempFileName());

            try
            {
                var map = DemoMap.Create();

                var wadWriter = new WadWriter();
                wadWriter.Append("MAP01", map);
                wadWriter.SaveTo(fileInfo.FullName);

                using (var wadReader = WadReader.Read(fileInfo.FullName))
                {
                    Assert.That(wadReader.Directory.Length, Is.EqualTo(3), "Did not return correct count.");
                    Assert.That(
                        wadReader.Directory.Select(l => l.Name).ToArray(),
                        Is.EquivalentTo(new[]
                                        { new LumpName("MAP01"), new LumpName("TEXTMAP"), new LumpName("ENDMAP"), }),
                        "Did not return correct lump names.");

                    var roundTripped = MapData.LoadFrom(wadReader.GetTextmapStream("MAP01"));

                    Assert.That(roundTripped, Is.DeepEqualTo(map));
                }
            }
            finally
            {
                if (fileInfo.Exists)
                {
                    fileInfo.Delete();
                }
            }
        }
Ejemplo n.º 3
0
        public void DirectStringArrayLoadTest()
        {
            var settings = SettingsLoader.CreateArray <string>("MySimpleArrayProperty");

            // Array
            Assert.That(settings, Is.EquivalentTo(
                            new[]
            {
                "Foo Primary", "Foo 1", "Foo 2"
            }));
        }
Ejemplo n.º 4
0
        public void ArrayLoadTest()
        {
            var settings = SettingsLoader.Create <ArraySettings>();

            // Array
            Assert.That(settings.MySimpleArrayProperty, Is.EquivalentTo(
                            new[]
            {
                "Foo Primary", "Foo 1", "Foo 2"
            }));
            Assert.That(settings.MyNumericArrayProperty, Is.EqualTo(
                            new decimal[]
            {
                1, 2, 3, 4
            }));
            Assert.That(settings.MyArrayProperty, 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
            }));
            Assert.That(settings.LostNumbersArray, Is.EqualTo(
                            new[]
            {
                4, 8, 15, 16, 23, 42
            }));
        }