예제 #1
0
        private async void GetHistory(string documentName)
        {
            var log = await ClientManager.GetHistoryAsync(documentName);

            opsList         = new List <Operation>(OperationCompressor.Compress(log));
            Log.ItemsSource = opsList;
        }
        public void Compress_GreaterThanMinRatio_ReturnsNull()
        {
            // Arrange

            var options = new ClusterOptions
            {
                CompressionMinRatio = 0.80f
            };

            var compressionAlgorithm = CreateMockCompressionAlgorithm(81);

            var compressor = new OperationCompressor(compressionAlgorithm, options,
                                                     NullLogger <OperationCompressor> .Instance);

            // Act

            using var result = compressor.Compress(new byte[100]);

            // Assert

            Assert.Null(result);
        }
        public void Compress_Disabled_ReturnsNull()
        {
            // Arrange

            var options = new ClusterOptions
            {
                Compression = false
            };

            var compressionAlgorithm = CreateMockCompressionAlgorithm(100);

            var compressor = new OperationCompressor(compressionAlgorithm, options,
                                                     NullLogger <OperationCompressor> .Instance);

            // Act

            using var result = compressor.Compress(new byte[1024]);

            // Assert

            Assert.Null(result);
        }
        public void Compress_EqualToMinSize_ReturnsCompressed()
        {
            // Arrange

            var options = new ClusterOptions
            {
                CompressionMinSize = 32
            };

            var compressionAlgorithm = CreateMockCompressionAlgorithm(1);

            var compressor = new OperationCompressor(compressionAlgorithm, options,
                                                     NullLogger <OperationCompressor> .Instance);

            // Act

            using var result = compressor.Compress(new byte[32]);

            // Assert

            Assert.NotNull(result);
        }
        public void Compress_LessThanMinSize_ReturnsNull()
        {
            // Arrange

            var options = new ClusterOptions
            {
                CompressionMinSize = 32
            };

            var compressionAlgorithm = CreateMockCompressionAlgorithm(1);

            var compressor = new OperationCompressor(compressionAlgorithm, options,
                                                     NullLogger <OperationCompressor> .Instance);

            // Act

            using var result = compressor.Compress(new byte[31], NoopRequestSpan.Instance);

            // Assert

            Assert.Null(result);
        }