コード例 #1
0
        public void GetUserTaskBoards_RequestingTaskBoardsForExistingUser_ReturnsOK()
        {
            // ARRANGE
            List <TaskBoardPublic> taskBoards = new List <TaskBoardPublic>
            {
                new TaskBoardPublic()
                {
                    ID = 1, Name = Guid.NewGuid().ToString(), UserID = 1
                },
                new TaskBoardPublic()
                {
                    ID = 2, Name = Guid.NewGuid().ToString(), UserID = 1
                },
                new TaskBoardPublic()
                {
                    ID = 3, Name = Guid.NewGuid().ToString(), UserID = 2
                }
            };

            ITaskBoardRepository taskBoardRepository = new MemoryTaskBoardRepository(taskBoards);
            TaskBoardController  controller          = new TaskBoardController(taskBoardRepository);

            // ACT
            OkObjectResult result = controller.GetUserTaskBoards(1) as OkObjectResult;

            // ASSERT
            result.Should().NotBeNull();
            result.StatusCode.Should().Be(200);
        }
コード例 #2
0
        public void GetUserTaskBoards_RequestingTaskBoardsForExistingUser_ReturnsTaskboards()
        {
            // ARRANGE
            List <TaskBoardPublic> taskBoards = new List <TaskBoardPublic>
            {
                new TaskBoardPublic()
                {
                    ID = 1, Name = Guid.NewGuid().ToString(), UserID = 1
                },
                new TaskBoardPublic()
                {
                    ID = 2, Name = Guid.NewGuid().ToString(), UserID = 1
                },
                new TaskBoardPublic()
                {
                    ID = 3, Name = Guid.NewGuid().ToString(), UserID = 2
                }
            };

            ITaskBoardRepository taskBoardRepository = new MemoryTaskBoardRepository(taskBoards);
            TaskBoardController  controller          = new TaskBoardController(taskBoardRepository);

            // ACT
            IEnumerable <TaskBoardPublic> result = (controller.GetUserTaskBoards(1) as ObjectResult).Value as IEnumerable <TaskBoardPublic>;

            // ASSERT
            result.Should().HaveCount(2);
        }
コード例 #3
0
        public void GetTaskBoard_RequestingNonExistingTaskboard_ReturnsNotFound()
        {
            // ARRANGE
            ITaskBoardRepository taskBoardRepository = new MemoryTaskBoardRepository();
            TaskBoardController  controller          = new TaskBoardController(taskBoardRepository);

            // ACT
            NotFoundObjectResult result = (NotFoundObjectResult)controller.GetTaskBoard(1);

            // ASSERT
            result.Should().NotBeNull();
            result.StatusCode.Should().Be(404);
        }
コード例 #4
0
        public void GetTaskBoard_OnInvalidID_ReportsProblem()
        {
            // ARRANGE
            ITaskBoardRepository taskBoardRepository = new MemoryTaskBoardRepository();
            TaskBoardController  controller          = new TaskBoardController(taskBoardRepository);

            controller.ProblemDetailsFactory = new MockProblemDetailsFactory();

            // ACT
            ObjectResult result = controller.GetTaskBoard(0) as ObjectResult;

            // ASSERT
            result.Should().NotBeNull();
            result.StatusCode.Should().Be(500);
        }
コード例 #5
0
        public void CreateTaskBoard_OnProperBody_ReturnsCreated()
        {
            // ARRANGE
            ITaskBoardRepository taskBoardRepository = new MemoryTaskBoardRepository();
            TaskBoardController  controller          = new TaskBoardController(taskBoardRepository);

            // ACT
            CreatedResult result = controller.CreateTaskBoard(new TaskBoardPublic()
            {
                ID = 1, Name = Guid.NewGuid().ToString(), UserID = 1
            }) as CreatedResult;

            // ASSERT
            result.Should().NotBeNull();
            result.StatusCode.Should().Be(201);
        }
コード例 #6
0
        public void CreateTaskBoard_OnProperBody_ReturnsCreatedTaskboard()
        {
            // ARRANGE
            ITaskBoardRepository taskBoardRepository = new MemoryTaskBoardRepository();
            TaskBoardController  controller          = new TaskBoardController(taskBoardRepository);
            TaskBoardPublic      taskBoard           = new TaskBoardPublic()
            {
                ID = 1, Name = Guid.NewGuid().ToString(), UserID = 1
            };

            // ACT
            TaskBoardPublic result = (controller.CreateTaskBoard(taskBoard) as CreatedResult).Value as TaskBoardPublic;

            // ASSERT
            result.Should().NotBeNull();
            result.Should().BeEquivalentTo <TaskBoardPublic>(taskBoard);
        }
コード例 #7
0
        public void GetTaskBoard_OnValidRequest_ReturnOK()
        {
            // ARRANGE
            ITaskBoardRepository taskBoardRepository = new MemoryTaskBoardRepository();

            taskBoardRepository.CreateTaskBoard(new TaskBoardPublic()
            {
                ID = 1
            });
            TaskBoardController controller = new TaskBoardController(taskBoardRepository);

            controller.ProblemDetailsFactory = new MockProblemDetailsFactory();

            // ACT
            OkObjectResult result = controller.GetTaskBoard(1) as OkObjectResult;

            // ASSERT
            result.Should().NotBeNull();
            result.StatusCode.Should().Be(200);
        }
コード例 #8
0
        public void GetTaskBoard_OnValidRequest_ReturnTaskBoardPublic()
        {
            // ARRANGE
            ITaskBoardRepository taskBoardRepository = new MemoryTaskBoardRepository();

            taskBoardRepository.CreateTaskBoard(new TaskBoardPublic()
            {
                ID = 1, Name = "Test", UserID = 1
            });
            TaskBoardController controller = new TaskBoardController(taskBoardRepository);

            controller.ProblemDetailsFactory = new MockProblemDetailsFactory();

            // ACT
            TaskBoardPublic result = (controller.GetTaskBoard(1) as OkObjectResult).Value as TaskBoardPublic;

            // ASSERT
            result.Should().NotBeNull();
            result.Should().BeEquivalentTo <TaskBoardPublic>(new TaskBoardPublic()
            {
                ID = 1, Name = "Test", UserID = 1
            });
        }