public ActionResult Create(AddKanbanBoardCommand addKanbanBoardCommand) { if(!ModelState.IsValid) { return View("Create", new AddKanbanBoardCommand()); } addKanbanBoardCommand.User = authenticationService.UserName; commandService.AddKanbanBoard(addKanbanBoardCommand); return RedirectToAction("MyBoards"); }
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); }
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)); }