예제 #1
0
        public async Task StartAsync_HappyPath_CallsManager()
        {
            // arrange
            SubmitPaymentCommand command = Fixture.Create <SubmitPaymentCommand>();

            CommandQueueMock.Setup(m => m.DequeueAsync(It.IsAny <CancellationToken>())).ReturnsAsync(command);
            CreatePaymentManagerMock
            .Setup(m => m.ProcessPaymentAsync(command))
            .Callback <SubmitPaymentCommand>(t => SUT.Dispose())
            .Returns(Task.CompletedTask);

            // act
            await SUT.StartAsync(CancellationToken.None);

            // assert
            CreatePaymentManagerMock.Verify(m => m.ProcessPaymentAsync(command));
        }
예제 #2
0
        public async Task CreateAsync_HappyPath_AddsToCommandQueue()
        {
            // arrange
            var createPayment = Fixture.Create <CreatePayment>();
            var payment       = Fixture.Create <Payment>();

            PaymentRepositoryMock
            .Setup(m => m.CreateAsync(createPayment))
            .ReturnsAsync(payment);

            // act
            await SUT.CreateAsync(createPayment);

            // assert
            CommandQueueMock
            .Setup(m => m.QueueCommand(It.Is <SubmitPaymentCommand>(c => c.PaymentId == payment.Id)));
        }