コード例 #1
0
        public void Lz4BinFormatsToStream()
        {
            var test = TestResourceFactory.CreateRandom() as MockClassC;
            var bson = new BSONFormatter();
            var zip = new LZ4ZipFormatter(bson);

            var bytes = bson.FormatObjStream(test);

            var binFormatted = zip.Format(bytes);
            var buffer = zip.Unformat(binFormatted);

            var unformatted = bson.UnformatObj<MockClassA>(buffer) as MockClassC;

            Assert.AreEqual(unformatted.Id, test.Id);
            Assert.AreEqual(unformatted.Name, test.Name);
            Assert.AreEqual(unformatted.GetSomeCheckSum[0], test.GetSomeCheckSum[0]);
            Assert.AreEqual(unformatted.Location.X, test.Location.X);
            Assert.AreEqual(unformatted.Location.Y, test.Location.Y);
            Assert.AreEqual(unformatted.Location.Z, test.Location.Z);
            Assert.AreEqual(unformatted.Location.W, test.Location.W);
            Assert.AreEqual(unformatted.ReferenceCode, test.ReferenceCode);
            Assert.AreEqual(unformatted.ReplicationID, test.ReplicationID);
        }
コード例 #2
0
        public void FormatterCompressesVeryLargeFiles()
        {
            var test = new Mocks.MockImageContainer(testRes.IronAsteroid_NRM) { Name = "IronAsteroid_NRM" };

            var bson = new BSONFormatter();
            var zip = new LZ4ZipFormatter(bson);

            var bytes = bson.FormatObjStream(test);

            var binFormatted = zip.Format(bytes);

            var buffer = zip.Unformat(binFormatted);

            var unformatted = bson.UnformatObj<ResourceContainer>(buffer) as MockImageContainer;

            Assert.AreEqual(unformatted.Name, test.Name);
            Assert.AreEqual(unformatted.GetResource<Bitmap>().Size.Width, test.GetResource<Bitmap>().Size.Width);
        }
コード例 #3
0
        public void FormatterCompressesVeryLargeFileStreams()
        {
            var test = new Mocks.MockStreamContainer(new MemoryStream(testRes.MiscAngelic)) { Name = "MiscAngelic" };

            var bson = new BSONFormatter();
            var zip = new LZ4ZipFormatter(bson);

            var bytes = bson.FormatObjStream(test);

            var binFormatted = zip.Format(bytes);

            var buffer = zip.Unformat(binFormatted);

            var unformatted = bson.UnformatObj<ResourceStreamContainer>(buffer) as MockStreamContainer;

            Assert.AreEqual(unformatted.Name, test.Name);
            Assert.AreEqual(unformatted.GetResource<Stream>().Length, test.GetResource<Stream>().Length);
        }