Example #1
0
        public void Constructor_allows_external_writer()
        {
            // arrange
            Tag actual;

            Tag expected = CreateComplexData();

            TextWriter textWriter = new StringWriter();
            var        writer     = XmlWriter.Create(textWriter, new XmlWriterSettings
            {
                Indent = true
            });

            TagWriter target = new XmlTagWriter(writer);

            // act
            target.WriteStartDocument();
            target.WriteTag(expected);
            target.WriteEndDocument();

            using (TextReader textReader = new StringReader(textWriter.ToString()))
            {
                using (var reader = XmlReader.Create(textReader))
                {
                    actual = new XmlTagReader(reader).ReadTag();
                }
            }

            // assert
            NbtAssert.Equal(expected, actual);
        }
Example #2
0
        public void ReadDocument_should_handle_uncompressed_files()
        {
            // arrange
            var       expected = CreateComplexData();
            Stream    stream   = File.OpenRead(UncompressedComplexDataFileName);
            TagReader target   = new BinaryTagReader(stream);

            // act
            var actual = target.ReadDocument();

            // assert
            NbtAssert.Equal(expected, actual);
        }
Example #3
0
        public void ReadDocument_can_handle_xml_documents_with_self_closing_tags()
        {
            // arrange
            Tag    expected = CreateSimpleNesting();
            Stream stream   = File.OpenRead(Path.Combine(DataPath, "project.xml"));
            var    target   = new XmlTagReader(stream);

            // act
            Tag actual = target.ReadDocument();

            // assert
            NbtAssert.Equal(expected, actual);
        }
Example #4
0
        public void LoadTest()
        {
            // arrange
            var       expected = CreateComplexData();
            Stream    stream   = File.OpenRead(ComplexXmlDataFileName);
            TagReader target   = new XmlTagReader(stream);

            // act
            var actual = target.ReadDocument();

            // assert
            NbtAssert.Equal(expected, actual);
        }
Example #5
0
        public void ReadDocument_can_handle_xml_documents_without_whitespace()
        {
            // arrange
            var       expected = CreateComplexData();
            Stream    stream   = File.OpenRead(ComplexXmlWithoutWhitespaceDataFileName);
            TagReader target   = new XmlTagReader(stream);

            // act
            var actual = target.ReadDocument();

            // assert
            NbtAssert.Equal(expected, actual);
        }
Example #6
0
        public void Constructor_allows_external_reader()
        {
            // arrange
            Tag expected = CreateComplexData();

            var reader = XmlReader.Create(ComplexXmlDataFileName);

            TagReader target = new XmlTagReader(reader);

            // act
            var actual = target.ReadTag();

            // assert
            NbtAssert.Equal(expected, actual);
        }
Example #7
0
        public void ReadDocument_should_handle_uncompressed_files()
        {
            // arrange
            TagReader   target;
            TagCompound expected;
            TagCompound actual;
            Stream      stream;

            expected = this.CreateComplexData();
            stream   = File.OpenRead(this.UncompressedComplexDataFileName);
            target   = new BinaryTagReader(stream);

            // act
            actual = target.ReadDocument();

            // assert
            NbtAssert.AreEqual(expected, actual);
        }
Example #8
0
        public void LoadTest()
        {
            // arrange
            TagReader   target;
            TagCompound expected;
            TagCompound actual;
            Stream      stream;

            expected = this.CreateComplexData();
            stream   = File.OpenRead(this.ComplexXmlDataFileName);
            target   = new XmlTagReader(stream);

            // act
            actual = target.ReadDocument();

            // assert
            NbtAssert.AreEqual(expected, actual);
        }
Example #9
0
        public void ReadDocument_can_handle_xml_documents_without_whitespace()
        {
            // arrange
            TagReader   target;
            TagCompound expected;
            TagCompound actual;
            Stream      stream;

            expected = this.CreateComplexData();
            stream   = File.OpenRead(this.ComplexXmlWithoutWhitespaceDataFileName);
            target   = new XmlTagReader(stream);

            // act
            actual = target.ReadDocument();

            // assert
            NbtAssert.AreEqual(expected, actual);
        }
Example #10
0
        public void Constructor_allows_external_reader()
        {
            // arrange
            TagReader target;
            Tag       expected;
            Tag       actual;
            XmlReader reader;

            expected = this.CreateComplexData();

            reader = XmlReader.Create(this.ComplexXmlDataFileName);

            target = new XmlTagReader(reader);

            // act
            actual = target.ReadTag();

            // assert
            NbtAssert.AreEqual(expected, actual);
        }