public void TheSameMessageCanNotBeAddedTwice() { var map = new SagaMessageMap(); map.Add <TestSagaMessage1>((m) => "Function1"); map.Add <TestSagaMessage1>((m) => "Function2"); }
public void CorrectFunctinIsInvokedForEachMessageType() { int invokeCount1 = 0; int invokeCount2 = 0; var map = new SagaMessageMap(); map.Add <TestSagaMessage1>((m) => { invokeCount1++; return("Function1"); }); map.Add <TestSagaMessage2>((m) => { invokeCount2++; return("Function2"); }); Assert.AreEqual("Function1", map.GetKey(new TestSagaMessage1())); Assert.AreEqual("Function2", map.GetKey(new TestSagaMessage2())); Assert.AreEqual(1, invokeCount1); Assert.AreEqual(1, invokeCount2); Assert.AreEqual("Function1", map.GetKey(new TestSagaMessage1())); Assert.AreEqual("Function2", map.GetKey(new TestSagaMessage2())); Assert.AreEqual(2, invokeCount1); Assert.AreEqual(2, invokeCount2); }
public override void ConfigureMessageKeys(SagaMessageMap mapper) { ConfigureMessageKeysCount++; mapper.Add <MockMessage1>((m) => m.Key); mapper.Add <MockMessage2>((m) => m.Key); }
public override void ConfigureMessageKeys(SagaMessageMap mapper) { throw new NotImplementedException(); }
public override void ConfigureMessageKeys(SagaMessageMap mapper) { mapper.Add <TestSagaMessage1>(m => "TestSagaKey"); mapper.Add <TestSagaMessage2>(m => "TestSagaKey"); }
/// <summary> /// Describes how to find the correct row in the saga data table for any given message being handled. /// </summary> /// <param name="mapper"></param> public override void ConfigureMessageKeys(SagaMessageMap mapper) { // each of these maps should return the same string value for a given instance of the saga. mapper.Add <SampleSagaStart>(m => m.AppId.ToString()); mapper.Add <SampleDistributedTaskResponse>(m => m.AppId.ToString()); }
public void GetKey_ThrowsForUnmappedMessageType() { var map = new SagaMessageMap(); map.GetKey(new TestSagaMessage1()); }
/// <summary> /// Each message that a sage will handle must be convertable to a saga key. /// This is used to map any given message to an instance of the persisted saga data. /// Two related messages should produce the same key, allowing the bus to use the same /// saga data instance for both messages. /// </summary> /// <example> /// { /// mapper.Add<MessageA>(m => m.Id.ToString()); /// mapper.Add<MessageB>(m => m.Id.ToString()); /// } /// </example> /// <param name="mapper"></param> public abstract void ConfigureMessageKeys(SagaMessageMap mapper);