예제 #1
0
        public async void GivenRegisteredAsynchronousRequestHandler_WhenSendMethodIsBeingCalled_ThenReturnsProperResult()
        {
            //Given
            var query = new GetIssuesNamesQuery("cleaning");

            //When
            var result = await mediator.Send(query);

            //Then
            result.Should().Have.Count.EqualTo(2);
            result.Should().Have.SameValuesAs("Cleaning main room", "cleaning kitchen");
        }
예제 #2
0
        public async void GivenNonRegisteredQueryHandler_WhenSendMethodIsBeingCalled_ThenThrowsAnError()
        {
            var ex = await Record.ExceptionAsync(async() =>
            {
                //Given
                var serviceLocator = new ServiceLocator();
                var mediator       = new Mediator(type => serviceLocator.Get(type).Single());

                var query = new GetIssuesNamesQuery("cleaning");

                //When
                var result = await mediator.Send(query);
            });

            //Then
            ex.Should().Not.Be.Null();
        }
예제 #3
0
        public async void GivenCommandWithData_WhenCommandIsSendToApplicationService_ThenreadModelIsChanged()
        {
            var serviceLocator = new ServiceLocator();

            var readModel      = new AppReadModel("Cleaning main room", "Writing blog", "cleaning kitchen");
            var commandHandler = new CreateIssueCommandHandler(readModel);

            serviceLocator.RegisterQueryHandler(commandHandler);

            var applicationService = new IssueApplicationService(new QueryBus(serviceLocator.GetMediator()));

            //Given
            var query = new GetIssuesNamesQuery("cleaning");

            //When
            var result = await applicationService.GetIssuesNames(query);

            //Then
            result.Should().Have.Count.EqualTo(2);
            result.Should().Have.SameValuesAs("Cleaning main room", "cleaning kitchen");
        }
예제 #4
0
 public Task <List <string> > Handle(GetIssuesNamesQuery query, CancellationToken cancellationToken = default)
 {
     return(Task.Run(() => issuesList.Issues
                     .Where(taskName => taskName.ToLower().Contains(query.Filter.ToLower()))
                     .ToList(), cancellationToken));
 }
예제 #5
0
 public Task <List <string> > GetIssuesNames(GetIssuesNamesQuery query)
 {
     return(queryBus.Send(query));
 }