public void Arrange()
        {
            _fixture = new Fixture();

            _mockEventPublisher = new Mock <IEventPublisher>();

            _mockEventPublisher
            .Setup(m => m.Publish(It.IsAny <List <RefreshLegalEntitiesEvent> >()))
            .Returns(Task.CompletedTask);

            _sut = new RefreshLegalEntitiesCommandHandler(_mockEventPublisher.Object);
        }
Пример #2
0
        public async Task Then_The_legal_entities_are_refreshed(
            [Frozen] Mock <ILegalEntitiesService> legalEntitiesService,
            [Frozen] Mock <IAccountsService> accountsService,
            RefreshLegalEntitiesCommand command,
            RefreshLegalEntitiesCommandHandler handler)
        {
            var legalEntities = _fixture.CreateMany <AccountLegalEntity>(100).ToList();
            var pagedResponse = new PagedResponse <AccountLegalEntity> {
                Data = legalEntities, Page = command.PageNumber, TotalPages = command.PageNumber
            };

            accountsService.Setup(x => x.GetLegalEntitiesByPage(command.PageNumber, command.PageSize)).ReturnsAsync(pagedResponse);

            await handler.Handle(command, CancellationToken.None);

            accountsService.Verify(x => x.GetLegalEntitiesByPage(command.PageNumber, command.PageSize), Times.Once);
            legalEntitiesService.Verify(x => x.RefreshLegalEntities(pagedResponse.Data, pagedResponse.Page, command.PageSize, pagedResponse.TotalPages), Times.Once);
        }