public async Task Handle_get_request_Id_Test() { ////Arrange IdentifiedCommand <CreateOrderCommand, bool> reqCreateOrder = null; _mediatorMock .Setup(x => x.Send( It.IsAny <IdentifiedCommand <CreateOrderCommand, bool> >(), It.IsAny <CancellationToken>())) .Callback <IRequest <bool>, CancellationToken>( (req, token) => reqCreateOrder = (IdentifiedCommand <CreateOrderCommand, bool>)req) .Returns(Task.FromResult(true)); UserCheckoutAcceptedIntegrationEvent @event = new UserCheckoutAcceptedIntegrationEvent( "user123", null, null, null, null, null, null, null, null, DateTime.Now, null, 333, null, Guid.NewGuid(), new CustomerBasket("user123") ); // action var handler = new UserCheckoutAcceptedIntegrationEventHandler(_mediatorMock.Object, _logger.Object); await handler.Handle(@event); // assert Assert.Equal("user123", reqCreateOrder.Command.UserId); }
public void Create_ApplicationParamIsNull_ThrowArgumentNullException() { //Arrange //Act Action act = () => _ = new UserCheckoutAcceptedIntegrationEventHandler( null, null, null, null ); //Assert act.Should().Throw <ArgumentNullException>(); }
public void Create_MediatorParamIsNull_ThrowArgumentNullException( Mock <IApplication> mockApplication ) { //Arrange //Act Action act = () => _ = new UserCheckoutAcceptedIntegrationEventHandler( mockApplication.Object, null, null, null ); //Assert act.Should().Throw <ArgumentNullException>(); }
public async Task Handle_GuidNotEmpty_CommandIsSent( [Frozen] Mock <IMediator> mockMediator, UserCheckoutAcceptedIntegrationEventHandler sut, UserCheckoutAcceptedIntegrationEvent integrationEvent ) { //Arrange //Act await sut.Handle(integrationEvent); //Assert mockMediator.Verify(_ => _.Send( It.IsAny <IRequest <bool> >(), It.IsAny <CancellationToken>() )); }
public async Task Handle_mediator_sent_once_Test() { ////Arrange UserCheckoutAcceptedIntegrationEvent @event = new UserCheckoutAcceptedIntegrationEvent( "user123", null, null, null, null, null, null, null, null, DateTime.Now, null, 333, null, Guid.NewGuid(), new CustomerBasket("user123") ); // action var handler = new UserCheckoutAcceptedIntegrationEventHandler(_mediatorMock.Object, _logger.Object); await handler.Handle(@event); // assert _mediatorMock.Verify( h => h.Send( It.IsAny <IdentifiedCommand <CreateOrderCommand, bool> >(), It.IsAny <CancellationToken>()), Times.Once()); }