Esempio n. 1
0
        public ExecutionResult HandleKey(ConsoleKey key)
        {
            if (!KeyCommandMap.TryGetValue(key, out var command))
            {
                return(ExecutionResult.Error($"Unknown keyboard key: {(char) key}"));
            }

            return(_dispatcher.Handle(command));
        }
Esempio n. 2
0
        public async Task <IActionResult> Post([FromBody] Todo value)
        {
            value.Id = Guid.NewGuid();

            var command = new CreateTodo(value.Id, value.Description);

            await _command.Handle(command);

            // return Ok();
            return(Ok(await _query.Handle <GetTodoById, Task <Todo> >(new GetTodoById(value.Id))));
        }
        public IActionResult Create(CreateMeetupCommand request)
        {
            var meetup    = _commandDispatcher.Handle <CreateMeetupCommand, Domain.Meetup>(request);
            var meetupDto = new CreatedMeetupDto
            {
                Id             = meetup.Id,
                Name           = meetup.Name,
                AvailableSeats = meetup.AvailableSeats
            };

            return(CreatedAtAction(nameof(Get), new { id = meetupDto.Id }, meetupDto));
        }
        public QueryDto Create(long projectId, string name)
        {
            var command = new CreateQueryCommand(name, projectId);

            _commandDispatcher.Handle(command);

            var query = new QueryByNameQuery(name, projectId);

            var queryDto = _dataQueryDispatcher.Process <QueryByNameQuery, QueryDto>(query);

            return(queryDto);
        }
        public void ProcessCommandHandler()
        {
            var commandHandler = new Mock <ICommandHandler <TestCommand> >();

            _commandHandlerProvider
            .Setup(_ => _.Resolve <TestCommand>())
            .Returns(commandHandler.Object);

            var command = new TestCommand();

            _commandDispatcher.Handle(command);

            _commandHandlerProvider.Verify(_ => _.Resolve <TestCommand>(), Times.Once);
            commandHandler.Verify(_ => _.Process(command), Times.Once);
        }
Esempio n. 6
0
        static void RoverRunSecond(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher)
        {
            DefineRoverCommand defineRoverCommand = new DefineRoverCommand(new Point(3, 3), new Size(5, 5), "E");

            commandDispatcher.Handle(defineRoverCommand);

            MoveRoverCommand moveRoverCommand = new MoveRoverCommand("MMRMMRMRRM");

            commandDispatcher.Handle(moveRoverCommand);

            LocationInfoQuery locationInfoQuery = new LocationInfoQuery();
            string            locationInfo      = queryDispatcher.Handle <LocationInfoQuery, string>(locationInfoQuery);

            Console.WriteLine(locationInfo);
        }
Esempio n. 7
0
        public void Test_Acceptance_Result_When_Rover_Move(Point inPosition, Size Plateau, string inDirection,
                                                           string inMovementList, Point outPoint, Direction outDirection)
        {
            DefineRoverCommand defineRoverCommand = new DefineRoverCommand(inPosition, Plateau, inDirection);

            _commandDispatcher.Handle(defineRoverCommand);

            MoveRoverCommand moveRoverCommand = new MoveRoverCommand(inMovementList);

            _commandDispatcher.Handle(moveRoverCommand);

            LocationInfoQuery locationInfoQuery = new LocationInfoQuery();
            string            locationInfo      = _queryDispatcher.Handle <LocationInfoQuery, string>(locationInfoQuery);
            string            outputInfo        = outPoint.X + " " + outPoint.Y + " " + outDirection.ToString("G");

            Assert.Equal(outputInfo, locationInfo);
        }
        public ActionResult Create(ClientCreateCommand clientCreateCommand)
        {
            if (!ModelState.IsValid)
            {
                return(this.RedirectToAction(f => f.New()));
            }
            _commandDispatcher.Handle(clientCreateCommand);

            return(this.RedirectToAction <HomeController>(f => f.Index()));
        }
        public long CreateProject(NewProjectDto project)
        {
            var command = project.ToCommand();

            _commandDispatcher.Handle(command);

            return(command.CreatedProjectId);
        }
        private void CreateTestProject()
        {
            const string projectAlias = "sdltest";

            if (!_projectRepository.Get(projectAlias).Any())
            {
                _commandHandlerProvider.Handle(new CreateProjectCommand
                {
                    Alias             = projectAlias,
                    DefaultBranchName = "master",
                    Description       =
                        @"<h2> Default project</h2>
<p> Default project settings for next user roles:</p>
<ul>
<li> Developer </li>
<li> Security officer </li>
</ul>",
                    Name = "Positive SDL project"
                });
            }
        }
        public void Delete(long reportId)
        {
            var command = new DeleteReportCommand(reportId);

            _commandDispatcher.Handle(command);
        }