public async Task SerializeDeserializeAsync() { // Arrange var testObject = new TestHelperObject { Name = "RussianTestObject", Address = "1600 Pennsylvania Ave.", BitsAndPieces = new List <string> { "russianoperative", "spraytan", "traitor", "peetape", "kompromat" } }; // Act var data = await SerializeAsUtf8JsonFormatAsync(testObject); data = await CompressBytesWithLZ4Async(data); var testData = await DecompressBytesWithLZ4Async(data); var desTestObject = await DeserializeAsUtf8JsonFormatAsync <ZeroTestHelperObject>(testData); // Re-Assert Assert.NotNull(data); Assert.NotNull(testData); Assert.NotNull(desTestObject); Assert.Equal(testObject.Name, desTestObject.Name); Assert.Equal(testObject.Address, desTestObject.Address); Assert.Equal(testObject.BitsAndPieces, desTestObject.BitsAndPieces); }
public async Task SerializeAsJsonAndDeserializeAsync() { // Arrange var testObject = new TestHelperObject { Name = "RussianTestObject", Address = "1600 Pennsylvania Ave.", BitsAndPieces = new List <string> { "russianoperative", "spraytan", "traitor", "peetape", "kompromat" } }; // Act var jsonString = await SerializeToJsonAsync(testObject); var compressedData = await CompressBytesWithLZ4Async(Encoding.UTF8.GetBytes(jsonString)); var decompressedString = Encoding.UTF8.GetString(await DecompressBytesWithLZ4Async(compressedData)); var decompressedTestObject = await DeserializeJsonAsync <TestHelperObject>(decompressedString); // Assert Assert.NotNull(jsonString); Assert.NotNull(decompressedString); Assert.NotNull(decompressedTestObject); Assert.Equal(testObject.Name, decompressedTestObject.Name); Assert.Equal(testObject.Address, decompressedTestObject.Address); Assert.Equal(testObject.BitsAndPieces, decompressedTestObject.BitsAndPieces); }
public async Task PublishExceptionAsync() { // Arrange var queueName = $"{_fixture.TestQueueName1}.3111"; var exchangeName = string.Empty; var testObject = new TestHelperObject { Name = "RussianTestObject", Address = "1600 Pennsylvania Ave.", BitsAndPieces = new List <string> { "russianoperative", "spraytan", "traitor", "peetape", "kompromat" } }; var envelope = new Envelope { ExchangeName = exchangeName, RoutingKey = queueName, ContentEncoding = ContentEncoding.Binary, MessageType = $"{ContentType.Textplain.Description()}{Charset.Utf8.Description()}" }; // Act var createSuccess = await _fixture.RabbitTopologyService.QueueDeclareAsync(queueName).ConfigureAwait(false); await Assert.ThrowsAsync <System.InvalidOperationException>(() => _fixture.RabbitSerializeService.SerializeAndPublishAsync(testObject, envelope)).ConfigureAwait(false); var deleteSuccess = await _fixture.RabbitTopologyService.QueueDeleteAsync(queueName).ConfigureAwait(false); Assert.True(createSuccess, "Queue was not created."); Assert.True(deleteSuccess); }
public async Task SerializeExceptionAsync() { // Arrange var testObject = new TestHelperObject { Name = "RussianTestObject", Address = "1600 Pennsylvania Ave.", BitsAndPieces = new List <string> { "russianoperative", "spraytan", "traitor", "peetape", "kompromat" } }; // Assert await Assert.ThrowsAsync <InvalidOperationException>(() => SerializeAsZeroFormatAsync(testObject)); }
public async Task SerializeAsJsonAsync() { // Arrange var testObject = new TestHelperObject { Name = "RussianTestObject", Address = "1600 Pennsylvania Ave.", BitsAndPieces = new List <string> { "russianoperative", "spraytan", "traitor", "peetape", "kompromat" } }; // Act var data = await SerializeToJsonAsync(testObject); // Assert Assert.NotNull(data); }
public async Task SerializeAsJsonAsync() { // Arrange var testObject = new TestHelperObject { Name = "RussianTestObject", Address = "1600 Pennsylvania Ave.", BitsAndPieces = new List <string> { "russianoperative", "spraytan", "traitor", "peetape", "kompromat" } }; // Act var data = await SerializeToJsonAsync(testObject).ConfigureAwait(false); var compressedData = await CompressBytesWithLZ4Async(Encoding.UTF8.GetBytes(data)).ConfigureAwait(false); // Assert Assert.NotNull(compressedData); }
public async Task PublishAndGetAsync() { // Arrange var queueName = $"{_fixture.TestQueueName2}.3112"; var exchangeName = string.Empty; var testObject = new TestHelperObject { Name = "RussianTestObject", Address = "1600 Pennsylvania Ave.", BitsAndPieces = new List <string> { "russianoperative", "spraytan", "traitor", "peetape", "kompromat" } }; var envelope = new Envelope { ExchangeName = exchangeName, RoutingKey = queueName, ContentEncoding = ContentEncoding.Binary, MessageType = $"{ContentType.Textplain.Description()}{Charset.Utf8.Description()}" }; // Act var createSuccess = await _fixture.RabbitTopologyService.QueueDeclareAsync(queueName).ConfigureAwait(false); var publishSuccess = await _fixture.RabbitSerializeService.SerializeAndPublishAsync(testObject, envelope).ConfigureAwait(false); await Task.Delay(200).ConfigureAwait(false); // Allow Server Side Routing var result = await _fixture.RabbitSerializeService.GetAndDeserializeAsync <TestHelperObject>(queueName).ConfigureAwait(false); var deleteSuccess = await _fixture.RabbitTopologyService.QueueDeleteAsync(queueName).ConfigureAwait(false); // Assert Assert.True(createSuccess, "Queue was not created."); Assert.True(publishSuccess, "Message failed to publish."); Assert.True(result != null, "Result was null."); Assert.True(deleteSuccess); }
public async Task SerializeAsJsonAndDeserializeAsync() { // Arrange var testObject = new TestHelperObject { Name = "RussianTestObject", Address = "1600 Pennsylvania Ave.", BitsAndPieces = new List <string> { "russianoperative", "spraytan", "traitor", "peetape", "kompromat" } }; // Act var data = await SerializeToJsonAsync(testObject).ConfigureAwait(false); var desTestObject = await DeserializeJsonAsync <TestHelperObject>(data).ConfigureAwait(false); // Assert Assert.NotNull(data); Assert.NotNull(desTestObject); Assert.Equal(testObject.Name, desTestObject.Name); Assert.Equal(testObject.Address, desTestObject.Address); Assert.Equal(testObject.BitsAndPieces, desTestObject.BitsAndPieces); }