public async Task ProcessCommand_WhenSubscribingDuringExecution_ShouldNotifyCommandStarted( [Frozen] Mock <IAsyncCommandBus> innerCommandBus, NotifyCommandStateBus sut, IAsyncCommand command, [Frozen] TestScheduler scheduler) { //arrange var observer = scheduler.CreateObserver <IAsyncCommand>(); innerCommandBus.Setup(bus => bus.ProcessCommand(It.IsAny <IAsyncCommand>())) .Returns(() => { sut.ObserveCommandStarted().Subscribe(observer); return(Task.FromResult(true)); }); //act scheduler.AdvanceTo(200); await sut.ProcessCommand(command); scheduler.Start(); //assert var expected = OnNext(201, command); observer.Messages.First().ShouldBeEquivalentTo(expected); }
public async Task ProcessCommand_ShouldCallInnerProcessCommnad( [Frozen]Mock<IAsyncCommandBus> innerCommandBus, NotifyCommandStateBus sut, IAsyncCommand command) { //arrange var verifiable = innerCommandBus.Setup(bus => bus.ProcessCommand(command)).ReturnsDefaultTaskVerifiable(); //act await sut.ProcessCommand(command); //assert verifiable.Verify(); }
public async Task ProcessCommand_ShouldCallInnerProcessCommnad( [Frozen] Mock <IAsyncCommandBus> innerCommandBus, NotifyCommandStateBus sut, IAsyncCommand command) { //arrange var verifiable = innerCommandBus.Setup(bus => bus.ProcessCommand(command)).ReturnsDefaultTaskVerifiable(); //act await sut.ProcessCommand(command); //assert verifiable.Verify(); }
public async Task ProcessCommand_WhenSubscribingAfterExecution_ShouldNotNotifyCommandStarted( [Frozen] Mock <IAsyncCommandBus> innerCommandBus, NotifyCommandStateBus sut, IAsyncCommand command, [Frozen] TestScheduler scheduler) { //arrange var observer = scheduler.CreateObserver <IAsyncCommand>(); //act scheduler.AdvanceTo(200); await sut.ProcessCommand(command); sut.ObserveCommandStarted().Subscribe(observer); //assert observer.Values().Should().BeEmpty(); }
public async Task ProcessCommand_ShouldNotifyCommandStarted( [Frozen] Mock <IAsyncCommandBus> innerCommandBus, NotifyCommandStateBus sut, IAsyncCommand command, [Frozen] TestScheduler scheduler) { //arrange var observer = scheduler.CreateObserver <IAsyncCommand>(); sut.ObserveCommandStarted().Subscribe(observer); //act scheduler.AdvanceTo(200); await sut.ProcessCommand(command); //assert var expected = OnNext(200, command); observer.Messages.First().ShouldBeEquivalentTo(expected); }
public async Task ProcessCommand_ShouldNotifyCommandError( [Frozen] Mock <IAsyncCommandBus> innerCommandBus, NotifyCommandStateBus sut, IAsyncCommand command, [Frozen] TestScheduler scheduler, Exception exception) { //arrange var observer = scheduler.CreateObserver <Tuple <IAsyncCommand, Exception> >(); innerCommandBus.Setup(bus => bus.ProcessCommand(It.IsAny <IAsyncCommand>())) .Returns(() => { scheduler.AdvanceTo(300); throw exception; }); sut.ObserveCommandError().Subscribe(observer); //act try { await sut.ProcessCommand(command); } catch (Exception ex) { if (ex != exception) { throw; } } //assert var expected = OnNext(300, new Tuple <IAsyncCommand, Exception>(command, exception)); observer.Messages.First().ShouldBeEquivalentTo(expected); }
public async Task ProcessCommand_ShouldNotifyCommandStarted( [Frozen]Mock<IAsyncCommandBus> innerCommandBus, NotifyCommandStateBus sut, IAsyncCommand command, [Frozen]TestScheduler scheduler) { //arrange var observer = scheduler.CreateObserver<IAsyncCommand>(); sut.ObserveCommandStarted().Subscribe(observer); //act scheduler.AdvanceTo(200); await sut.ProcessCommand(command); //assert var expected = OnNext(200, command); observer.Messages.First().ShouldBeEquivalentTo(expected); }
public void Sut_IsCommandStateEvents( NotifyCommandStateBus sut) { sut.IsAssignableTo<ICommandStateEvents>(); }
public void Sut_IsAsyncCommandBus( NotifyCommandStateBus sut) { sut.IsAssignableTo<IAsyncCommandBus>(); }
public async Task ProcessCommand_WhenSubscribingAfterExecution_ShouldNotNotifyCommandStarted( [Frozen]Mock<IAsyncCommandBus> innerCommandBus, NotifyCommandStateBus sut, IAsyncCommand command, [Frozen]TestScheduler scheduler) { //arrange var observer = scheduler.CreateObserver<IAsyncCommand>(); //act scheduler.AdvanceTo(200); await sut.ProcessCommand(command); sut.ObserveCommandStarted().Subscribe(observer); //assert observer.Values().Should().BeEmpty(); }
public async Task ProcessCommand_WhenSubscribingDuringExecution_ShouldNotifyCommandStarted( [Frozen]Mock<IAsyncCommandBus> innerCommandBus, NotifyCommandStateBus sut, IAsyncCommand command, [Frozen]TestScheduler scheduler) { //arrange var observer = scheduler.CreateObserver<IAsyncCommand>(); innerCommandBus.Setup(bus => bus.ProcessCommand(It.IsAny<IAsyncCommand>())) .Returns(() => { sut.ObserveCommandStarted().Subscribe(observer); return Task.FromResult(true); }); //act scheduler.AdvanceTo(200); await sut.ProcessCommand(command); scheduler.Start(); //assert var expected = OnNext(201, command); observer.Messages.First().ShouldBeEquivalentTo(expected); }
public async Task ProcessCommand_ShouldNotifyCommandError( [Frozen]Mock<IAsyncCommandBus> innerCommandBus, NotifyCommandStateBus sut, IAsyncCommand command, [Frozen]TestScheduler scheduler, Exception exception) { //arrange var observer = scheduler.CreateObserver<Tuple<IAsyncCommand, Exception>>(); innerCommandBus.Setup(bus => bus.ProcessCommand(It.IsAny<IAsyncCommand>())) .Returns(() => { scheduler.AdvanceTo(300); throw exception; }); sut.ObserveCommandError().Subscribe(observer); //act try { await sut.ProcessCommand(command); } catch (Exception ex) { if (ex != exception) { throw; } } //assert var expected = OnNext(300, new Tuple<IAsyncCommand, Exception>(command, exception)); observer.Messages.First().ShouldBeEquivalentTo(expected); }
public void Sut_IsCommandStateEvents( NotifyCommandStateBus sut) { sut.IsAssignableTo <ICommandStateEvents>(); }
public void Sut_IsAsyncCommandBus( NotifyCommandStateBus sut) { sut.IsAssignableTo <IAsyncCommandBus>(); }