public void Complete_Removes_Headers() { //Arrange var correlationId = Guid.NewGuid(); var saga = new MySaga { CorrelationId = correlationId, Headers = new Dictionary <string, string>() { { "SomeKey", Guid.NewGuid().ToString() } }, }; database.Insert(new SagaData() { CorrelationId = correlationId, BlobData = JsonConvert.SerializeObject(saga.SagaData) }); database.Insert(new SagaHeaders() { CorrelationId = correlationId, Key = saga.Headers.First().Key, Value = saga.Headers.First().Value }); // Act sut.Complete(saga); // Assert var updatedHeaders = DatabaseHelpers.GetSagaHeaders(database, correlationId); updatedHeaders.Should().HaveCount(0); }
public void Save_Updates_ExistingHeaders() { //Arrange var correlationId = Guid.NewGuid(); var expectedValue = Guid.NewGuid().ToString(); var saga = new MySaga { CorrelationId = correlationId, Headers = new Dictionary <string, string>() { { "SomeKey", Guid.NewGuid().ToString() } }, }; database.Insert(new SagaData() { CorrelationId = correlationId, BlobData = JsonConvert.SerializeObject(saga.SagaData) }); database.Insert(new SagaHeaders() { CorrelationId = correlationId, Key = saga.Headers.First().Key, Value = saga.Headers.First().Value }); saga.Headers["SomeKey"] = expectedValue; // Act sut.Save(saga); // Assert var updatedHeaders = DatabaseHelpers.GetSagaHeaders(database, correlationId); updatedHeaders.Should().HaveCount(1); updatedHeaders.First().Value.Should().Be(expectedValue); }
public void Save_Persists_Headers() { //Arrange var correlationId = Guid.NewGuid(); var saga = new MySaga { CorrelationId = correlationId }; var expectedValue = Guid.NewGuid().ToString(); saga.Headers = new Dictionary <string, string>() { { "key", expectedValue } }; // Act sut.Save(saga); // Assert var restoredHeaders = DatabaseHelpers.GetSagaHeaders(database, correlationId); restoredHeaders.Should().HaveCount(1); restoredHeaders.First().Value.Should().Be(expectedValue); }