예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }