public async Task AddMutation_Adds_Diff_MessageAttribute_Identical_Objects() { await Task.CompletedTask; // Arrange var obj1 = new TestItem(); var obj2 = new TestItem(); var request = new PublishRequest(); // Act request.AddMutation(obj1, obj2); // Assert Assert.Empty(JsonConvert.DeserializeObject <List <string> >(request.MessageAttributes[Constants.UpdatedProperties].StringValue)); }
public async Task AddMutation_Adds_Diff_MessageAttribute_Null_NewImage() { await Task.CompletedTask; // Arrange var obj1 = new TestItem { Name = "Test", Age = 1, CreationDate = DateTime.Now }; TestItem obj2 = null; var request = new PublishRequest(); // Act request.AddMutation(obj1, obj2); // Assert var diff = JsonConvert.DeserializeObject <List <string> >(request.MessageAttributes[Constants.UpdatedProperties].StringValue); Assert.Equal(4, diff.Count); }
public async Task AddMutation_Adds_Diff_MessageAttribute_Different_Objects() { await Task.CompletedTask; // Arrange var obj1 = new TestItem(); var obj2 = new TestItem { Name = "Test" }; var request = new PublishRequest(); // Act request.AddMutation(obj1, obj2); // Assert var diff = JsonConvert.DeserializeObject <List <string> >(request.MessageAttributes[Constants.UpdatedProperties].StringValue); Assert.Single(diff); Assert.Equal("Name", diff[0]); }
public void AddMutation_Adds_EventId() { // Arrange var obj1 = new TestItem { Name = "Test", Age = 1, CreationDate = DateTime.Now }; var obj2 = new TestItem { Name = "Test", Age = 2, CreationDate = DateTime.Now }; var request = new PublishRequest(); // Act request.AddMutation(obj1, obj2); // Assert var model = JsonConvert.DeserializeObject <MutationModel <TestItem> >(request.Message); Assert.True(Guid.Parse(model.EventId) != default(Guid)); }
public void AddMutation_Adds_EventType() { // Arrange var obj1 = new TestItem { Name = "Test", Age = 1, CreationDate = DateTime.Now }; var obj2 = new TestItem { Name = "Test", Age = 2, CreationDate = DateTime.Now }; var eventType = "order-service.order"; var request = new PublishRequest(); // Act request.AddMutation(obj1, obj2, eventType); // Assert var model = JsonConvert.DeserializeObject <MutationModel <TestItem> >(request.Message); Assert.Equal(eventType, model.EventType); }