コード例 #1
0
        public void Constructor_allows_external_writer()
        {
            // arrange
            TagWriter  target;
            Tag        expected;
            Tag        actual;
            XmlWriter  writer;
            TextWriter textWriter;

            expected = this.CreateComplexData();

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

            target = new XmlTagWriter(writer);

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

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

            // assert
            NbtAssert.AreEqual(expected, actual);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }
コード例 #5
0
        public void ReadDocument_can_handle_xml_documents_with_self_closing_tags()
        {
            // arrange
            XmlTagReader target;
            Tag          actual;
            Tag          expected;
            Stream       stream;

            expected = this.CreateSimpleNesting();
            stream   = File.OpenRead(Path.Combine(this.DataPath, "project.xml"));
            target   = new XmlTagReader(stream);

            // act
            actual = target.ReadDocument();

            // assert
            NbtAssert.AreEqual(expected, actual);
        }
コード例 #6
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);
        }