public void Initiate_NoCorrelationId_Throws() { // Arrange var initiatingMessage = new MySagaInitiatingMessage(); // Act Action act = () => sut.Consume(initiatingMessage); // Assert act.ShouldThrow <ArgumentException>().Which.Message.Contains("CorrelationId was not provided in the message"); }
public void GetSagaTypesInitiatedBy_Returns_MySaga() { // Arrange var initiatingMessage = new MySagaInitiatingMessage(); // Act var result = NSagaReflection.GetSagaTypesInitiatedBy(initiatingMessage, typeof(NSagaReflectionTests).Assembly); // Assert result.Should().HaveCount(1).And.Contain(typeof(MySaga)); }
public void Initiate_CalledInitiate_CheckData() { //Arrange var correlationId = Guid.NewGuid(); var initiatingMessage = new MySagaInitiatingMessage(correlationId); // Act sut.Consume(initiatingMessage); // Assert var saga = repository.Find <MySaga>(correlationId); saga.SagaData.IsInitialised.Should().BeTrue(); }
public void Initiate_Saves_IntoRepository() { //Arrange var correlationId = Guid.NewGuid(); var initiatingMessage = new MySagaInitiatingMessage(correlationId); // Act sut.Consume(initiatingMessage); // Assert repository.DataDictionary.Should().HaveCount(1); var saga = repository.Find <MySaga>(correlationId); saga.CorrelationId.Should().Be(correlationId); }
public void Initiate_SagaAlreadyExists_Throws() { // Arrange var correlationId = Guid.NewGuid(); repository.Save(new MySaga() { CorrelationId = correlationId }); var initiatingMessage = new MySagaInitiatingMessage(correlationId); // Act Action act = () => sut.Consume(initiatingMessage); // Assert act.ShouldThrow <ArgumentException>().Which.Message.Contains("Trying to initiate the same saga twice"); }
public OperationResult Initiate(MySagaInitiatingMessage message) { SagaData.IsInitialised = true; return(new OperationResult()); }