Ejemplo n.º 1
0
        public void UpdateAsync_Last_Sprint_Should_Return_Error_Response()
        {
            // Arrange
            SprintDto newSprintDto = new SprintDto
            {
                Id          = 3,
                Name        = "Sprint 3",
                Description = "Some description",
                Items       = null,
                ProjectId   = 1,
                StartDate   = new DateTime(2020, 3, 1),
                EndDate     = new DateTime(2020, 4, 1)
            };
            var sprints = GetSampleSprints();

            mockSprintRepo.Setup(repo => repo.GetByIdAsync(3)).ReturnsAsync(sprints[2]);
            mockProjectUserRepo.Setup(repo => repo.GetRoleOfMember(It.IsAny <string>(), 1)).ReturnsAsync(AppUserRole.Owner);
            mockSprintRepo.Setup(repo => repo.GetAllByProjectIdAsync(1)).ReturnsAsync(sprints);
            var sprintBL = new SprintBl(mockSprintRepo.Object, mockMapper, mockProjectUserRepo.Object, mockItemRepo.Object);
            // Act
            var result = sprintBL.UpdateAsync(newSprintDto, It.IsAny <string>());

            // Assert
            Assert.IsType <SprintResponse>(result.Result);
            Assert.False(result.Result.Success);
            Assert.Equal($"Error. Choose start date after {sprints[1].EndDate.Value.ToShortDateString()}", result.Result.Message);
        }
Ejemplo n.º 2
0
        public void UpdateAsync_Should_Return_Error_Response_When_Start_Date_Is_Later_Than_End_Date()
        {
            // Arrange
            SprintDto newSprintDto = new SprintDto
            {
                Id          = 2,
                Name        = "Sprint 2",
                Description = "Some description",
                Items       = null,
                ProjectId   = 1,
                StartDate   = new DateTime(2020, 2, 15),
                EndDate     = new DateTime(2020, 2, 14)
            };
            var sprints = GetSampleSprints();

            mockSprintRepo.Setup(repo => repo.GetByIdAsync(2)).ReturnsAsync(sprints[1]);
            mockProjectUserRepo.Setup(repo => repo.GetRoleOfMember(It.IsAny <string>(), 1)).ReturnsAsync(AppUserRole.Owner);
            mockSprintRepo.Setup(repo => repo.GetAllByProjectIdAsync(1)).ReturnsAsync(sprints);
            var sprintBL = new SprintBl(mockSprintRepo.Object, mockMapper, mockProjectUserRepo.Object, mockItemRepo.Object);
            // Act
            var result = sprintBL.UpdateAsync(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);
        }
Ejemplo n.º 3
0
        public void UpdateAsync_Should_Return_Error_Response_When_End_Date_Is_Greater_Than_Start_Date_Of_The_Next_Sprint()
        {
            // Arrange
            SprintDto newSprintDto = new SprintDto
            {
                Id          = 2,
                Name        = "Sprint 2",
                Description = "Some description",
                Items       = null,
                ProjectId   = 1,
                StartDate   = new DateTime(2020, 2, 2),
                EndDate     = new DateTime(2020, 3, 2)
            };
            var sprints = GetSampleSprints();

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

            // Assert
            Assert.IsType <SprintResponse>(result.Result);
            Assert.False(result.Result.Success);
            Assert.Equal($"Error. Choose dates after {sprints[0].EndDate.Value.ToShortDateString()} and before {sprints[2].StartDate.Value.ToShortDateString()}", result.Result.Message);
        }
Ejemplo n.º 4
0
        public void UpdateAsync_Should_Return_CorrectResponse()
        {
            // Arrange
            SprintDto newSprintDto = new SprintDto
            {
                Id          = 2,
                Name        = "Sprint 2",
                Description = "Some description",
                Items       = null,
                ProjectId   = 1,
                StartDate   = new DateTime(2020, 2, 2),
                EndDate     = new DateTime(2020, 2, 28)
            };
            var sprints = GetSampleSprints();

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

            // Assert
            Assert.IsType <SprintResponse>(result.Result);
            Assert.True(result.Result.Success);
        }