Exemplo n.º 1
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");
        }
Exemplo n.º 2
0
    public void GivenCommandWithData_WhenCommandIsSendToApplicationService_ThenWriteModelIsChanged()
    {
        var serviceLocator = new ServiceLocator();

        var writeModel     = new AppWriteModel();
        var commandHandler = new CreateIssueCommandHandler(writeModel);

        serviceLocator.RegisterCommandHandler <CreateIssueCommand, CreateIssueCommandHandler>(commandHandler);

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

        //Given
        var createdIssueName = "cleaning";

        var command = new CreateIssueCommand(createdIssueName);

        //When
        applicationService.CreateIssue(command);

        //Then
        writeModel.Issues.Should().Have.Count.EqualTo(1);
        writeModel.Issues.Should().Have.SameValuesAs(createdIssueName);
    }