public void SaveCompressedTest()
    {
      // arrange
      BinaryTagWriter writer;
      TagCompound tag;

      tag = this.GetComplexData();
      writer = new BinaryTagWriter();

      // act
      writer.Write(tag, this.OutputFileName, NbtOptions.Compress | NbtOptions.Header);

      // assert
      this.CompareTags(tag, new NbtDocument(this.OutputFileName).DocumentRoot);
    }
Esempio n. 2
0
    public void SaveBinaryTest()
    {
      // arrange
      TagCompound target;
      TagWriter writer;
      string fileName;
      byte[] source;
      byte[] destination;

      fileName = this.ComplexDataFileName;
      target = new NbtDocument(fileName).DocumentRoot;

      using (FileStream file = File.OpenRead(fileName))
        source = this.Decompress(file);

      // act
      using (MemoryStream stream = new MemoryStream())
      {
        writer = new BinaryTagWriter(stream, NbtOptions.Header);
        writer.Write(target);
        destination = stream.ToArray();
      }
      File.WriteAllBytes(this.OutputFileName, destination);

      // assert
      CollectionAssert.AreEqual(source, destination);

      new NbtDocument(this.OutputFileName);
    }