Exemple #1
0
        private void ReadTest <T>(T expected, Action <TagWriter, T> write, Func <TR2, T> read)
        {
            using (Stream stream = new MemoryStream())
            {
                // arrange
                TR2 target;
                T   actual;

                using (BinaryTagWriter writer = new BinaryTagWriter(stream))
                {
                    writer.WriteStartDocument();
                    writer.WriteStartTag(TagType.Compound);
                    write(writer, expected);
                    writer.WriteEndTag();
                    writer.WriteEndDocument();
                }

                stream.Position = 0;

                target = new TR2(stream);
                target.MoveToNextElement(); // compound

                // act
                actual = read(target);

                // assert
                Assert.AreEqual(expected, actual);
            }
        }
Exemple #2
0
        public void Types_load_in_correct_order()
        {
            using (Stream stream = File.OpenRead(this.ComplexDataFileName))
            {
                using (Stream decompressorStream = new GZipStream(stream, CompressionMode.Decompress))
                {
                    // arrange
                    TR2            target;
                    List <TagType> actual;
                    TagType[]      expected;

                    expected = new TagType[0];
                    actual   = new List <TagType>();

                    target = new TR2(decompressorStream);

                    // act
                    while (target.MoveToNextElement())
                    {
                        Debug.WriteLine(target.Name);
                        actual.Add(target.Type);
                    }

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