public void Create_should_return_null_when_policy_not_configured() { var sp = NSubstitute.Substitute.For <IServiceProvider>(); var sut = new DefaultSagaPolicyFactory <DummySaga>(sp); var policy = sut.Create <StartDummySaga>(); policy.Should().BeNull(); }
public void Create_should_return_policy_when_policy_not_configured() { var expectedPolicy = NSubstitute.Substitute.For <IPolicy>(); var factory = NSubstitute.Substitute.For <IMessagePolicyFactory <DummySaga, StartDummySaga> >(); factory.Create().Returns(expectedPolicy); var sp = NSubstitute.Substitute.For <IServiceProvider>(); sp.GetService(typeof(IMessagePolicyFactory <DummySaga, StartDummySaga>)) .Returns(factory); var sut = new DefaultSagaPolicyFactory <DummySaga>(sp); var policy = sut.Create <StartDummySaga>(); policy.Should().Be(expectedPolicy); }