public void SerializationShouldBeCompressed() { // Arrange. var filter = new GzipCompressionMessageFilter(); var envelope = Envelope.Create(new CreateOrderCommand { Id = "abc" }) .Property("Something", 123); var serializer = new NewtonsoftJsonSerializer(); var serializedBody = serializer.Serialize(envelope.Body).Result; // Act. var compressedBody = filter.AfterSerialization(envelope, serializedBody).Result; // Assert. Assert.True(compressedBody.Length < serializedBody.Length); }
public void DeserializationShouldWorkCorrectly() { // Arrange. var filter = new GzipCompressionMessageFilter(); var envelope = Envelope.Create(new CreateOrderCommand { Id = "abc" }) .Property("Something", 123); var serializer = new NewtonsoftJsonSerializer(); var serializedBody = serializer.Serialize(envelope.Body).Result; var compressedBody = filter.AfterSerialization(envelope, serializedBody).Result; // Act. var decompressedBody = filter.BeforeDeserialization(envelope, compressedBody).Result; var command = serializer.Deserialize<CreateOrderCommand>(decompressedBody).Result; // Assert. Assert.Equal(envelope.Body.Id, command.Id); }