Ejemplo n.º 1
0
        public async void SerializedConfiguration_ShouldBeMuchLessThanTheOriginalStream()
        {
            using (var compressedStream = new MemoryStream())
            {
                await Zipper.WriteCompressedDataToStreamAsync(compressedStream, Data);

                int uncompressedLength = Encoding.UTF8.GetBytes(Data).Length;
                int compressedLength   = compressedStream.ToArray().Length;
                compressedLength.Should().BeLessThan(uncompressedLength / 4);
            }
        }
Ejemplo n.º 2
0
        public async void DecompressingACompressedStream_ShouldYieldTheOriginalData()
        {
            using (var compressedStream = new MemoryStream())
            {
                await Zipper.WriteCompressedDataToStreamAsync(compressedStream, Data);

                using (var readFromStream = new MemoryStream(compressedStream.ToArray()))
                {
                    string data = await Zipper.GetDataFromCompressedStreamAsync(readFromStream);

                    data.Should().Be(Data);
                }
            }
        }
Ejemplo n.º 3
0
        public async void ASerializedAndCompressedLargeConfiguration_ShouldBeSmallerThanTheRoamingStorageQuota()
        {
            var    configurations = BuildArrayOfConfigurations(noConfigs: 10, noGroups: 20, noActions: 8);
            string data           = await Serializer.SerializeAsync(configurations);

            using (var compressedStream = new MemoryStream())
            {
                await Zipper.WriteCompressedDataToStreamAsync(compressedStream, data);

                int actualNumberOfBytes = compressedStream.ToArray().Length;
                // ApplicationData.RoamingStorageQuota is 100KB. For some reason that property cannot be accessed in the test project.
                actualNumberOfBytes.Should().BeLessThan(100 * 1024);
            }
        }