Example #1
0
        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();
		}
Example #3
0
        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();
        }
Example #4
0
        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();
        }
Example #5
0
        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);
        }
Example #6
0
        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>();
		}
Example #10
0
		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();
		}
Example #11
0
		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);
		}
Example #12
0
		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);
		}
Example #13
0
 public void Sut_IsCommandStateEvents(
     NotifyCommandStateBus sut)
 {
     sut.IsAssignableTo <ICommandStateEvents>();
 }
Example #14
0
 public void Sut_IsAsyncCommandBus(
     NotifyCommandStateBus sut)
 {
     sut.IsAssignableTo <IAsyncCommandBus>();
 }