コード例 #1
0
        public ActionResult Create(AddKanbanBoardCommand addKanbanBoardCommand)
        {
            if(!ModelState.IsValid)
            {
                return View("Create", new AddKanbanBoardCommand());
            }

            addKanbanBoardCommand.User = authenticationService.UserName;
            commandService.AddKanbanBoard(addKanbanBoardCommand);

            return RedirectToAction("MyBoards");
        }
コード例 #2
0
        public void AddKanbanBoard(AddKanbanBoardCommand command)
        {
            var board = new KanbanBoard {
                                User = command.User,
                                Posted = DateTime.Now,
                                TimesFavorited = 0,
                                Title = command.Title,
                                Description = command.Description,
                                Tags = command.Tags
                            };

            kanbanBoardRepository.Add(board);
        }
コード例 #3
0
        public void should_add_a_KanbanBoard_when_called_with_correct_AddKanbanBoardCommand()
        {
            // Arrange
            var cmd = new AddKanbanBoardCommand {
                              Title = "Test tile", User = "******",
                              Description = "A long description that contains information",
                              BoardImage = @"C:\Path\", Tags = "Tag1, Tag2, Tag3"
                          };

            var repository = Substitute.For<IKanbanBoardRepository>();
            var commandService = new KanbanBoardCommandService(repository);

            // Act
            commandService.AddKanbanBoard(cmd);

            // Assert
            repository.Received().Add(Arg.Is<KanbanBoard>(x => x.Title == cmd.Title));
            repository.Received().Add(Arg.Is<KanbanBoard>(x => x.User == cmd.User));
            repository.Received().Add(Arg.Is<KanbanBoard>(x => x.Tags == cmd.Tags));
            repository.Received().Add(Arg.Is<KanbanBoard>(x => x.Description == cmd.Description));
        }