예제 #1
0
        public void CreateAsync_Should_Return_Correct_Response_When_Created()
        {
            // Arrange
            SprintDto newSprintDto = new SprintDto
            {
                Id        = 0,
                Items     = null,
                ProjectId = 1,
                StartDate = new DateTime(2020, 4, 2),
                EndDate   = new DateTime(2020, 5, 1)
            };

            mockProjectUserRepo.Setup(repo => repo.GetRoleOfMember(It.IsAny <string>(), 1)).ReturnsAsync(AppUserRole.Owner);
            mockSprintRepo.Setup(repo => repo.GetAllByProjectIdAsync(1)).ReturnsAsync(GetSampleSprints());
            var sprintBL = new SprintBl(mockSprintRepo.Object, mockMapper, mockProjectUserRepo.Object, mockItemRepo.Object);
            // Act
            var result = sprintBL.CreateAsync(newSprintDto, It.IsAny <string>());

            // Assert
            Assert.IsType <SprintResponse>(result.Result);
            Assert.True(result.Result.Success);
        }
예제 #2
0
        public void CreateAsync_Should_Return_Error_Response_When_Start_Date_Is_Later_Then_End_Date()
        {
            // Arrange
            SprintDto newSprintDto = new SprintDto
            {
                Id        = 0,
                Items     = null,
                ProjectId = 1,
                StartDate = new DateTime(2020, 5, 2),
                EndDate   = new DateTime(2020, 4, 1)
            };

            mockProjectUserRepo.Setup(repo => repo.GetRoleOfMember(It.IsAny <string>(), 1)).ReturnsAsync(AppUserRole.Owner);
            mockSprintRepo.Setup(repo => repo.GetAllByProjectIdAsync(1)).ReturnsAsync(GetSampleSprints());
            var sprintBL = new SprintBl(mockSprintRepo.Object, mockMapper, mockProjectUserRepo.Object, mockItemRepo.Object);
            // Act
            var result = sprintBL.CreateAsync(newSprintDto, It.IsAny <string>());

            // Assert
            Assert.IsType <SprintResponse>(result.Result);
            Assert.False(result.Result.Success);
            Assert.Equal("Sprint end date must be later than start date", result.Result.Message);
        }
예제 #3
0
        public void CreateAsync_Should_Return_Error_Response_When_Sprints_Overlaps()
        {
            // Arrange
            SprintDto newSprintDto = new SprintDto
            {
                Id        = 0,
                Items     = null,
                ProjectId = 1,
                StartDate = new DateTime(2020, 4, 1),
                EndDate   = new DateTime(2020, 5, 1)
            };

            mockProjectUserRepo.Setup(repo => repo.GetRoleOfMember(It.IsAny <string>(), 1)).ReturnsAsync(AppUserRole.Owner);
            mockSprintRepo.Setup(repo => repo.GetAllByProjectIdAsync(1)).ReturnsAsync(GetSampleSprints());
            var sprintBL = new SprintBl(mockSprintRepo.Object, mockMapper, mockProjectUserRepo.Object, mockItemRepo.Object);
            // Act
            var result = sprintBL.CreateAsync(newSprintDto, It.IsAny <string>());

            // Assert
            Assert.IsType <SprintResponse>(result.Result);
            Assert.False(result.Result.Success);
            Assert.Equal($"Sprint overlaps. Choose start date after {GetSampleSprints()[2].EndDate.Value.ToShortDateString()}", result.Result.Message);
        }