public async Task <int> AddWorkingDays(int sprintId, int memberId, int workingDays) { var sprint = await _manageSprintsService.GetSprintAsync(sprintId, false); if (TryValidateModel(MemberWorkingDays.Create(memberId, sprintId, sprint, workingDays))) { var result = await _manageMemberWorkingDaysService.AddMemberWorkingDaysAsync(MemberWorkingDays.Create(memberId, sprintId, null, workingDays)); if (result) { var memberWorkingDays = await _manageMemberWorkingDaysService.GetAllWorkingDaysForSprintAsync(sprintId); return(memberWorkingDays.FirstOrDefault(i => i.MemberId == memberId).Id); } else { return(-1); } } else { return(-1); } }
public async Task <bool> AddMemberWorkingDaysAsync(MemberWorkingDays memberWorkingDays) { if (memberWorkingDays.WorkingDays < 0) { return(false); } return(await _memberWorkingDaysRepository.InsertAsync(memberWorkingDays)); }
public override bool IsValid(object value) { MemberWorkingDays memberWorkingDays = value as MemberWorkingDays; if (memberWorkingDays.WorkingDays >= 0 && memberWorkingDays.WorkingDays <= memberWorkingDays.Sprint.DaysInSprint) { return(true); } return(false); }
public async Task <bool> EditMemberWorkingDaysAsync(MemberWorkingDays memberWorkingDays) { var oldMemberWorkingDays = await _memberWorkingDaysRepository.GetByIdAsync(memberWorkingDays.Id); if (oldMemberWorkingDays == null || memberWorkingDays.WorkingDays < 0) { return(false); } return(await _memberWorkingDaysRepository.UpdateAsync(memberWorkingDays)); }
public async System.Threading.Tasks.Task UpdateAsync_MemberWorkingDaysRepositoryReturnsFalse_ReturnsFalse() { //Arrange Sprint sprint = Sprint.Create(1, new List <Task>()); MemberWorkingDays memberWorkingDays = MemberWorkingDays.Create(1, 1, sprint, 2); //Act var result = await _memberWorkingDaysRepository.UpdateAsync(memberWorkingDays); //Assert Assert.IsFalse(result); }
public async System.Threading.Tasks.Task InsertAsync_MemberWorkingDaysRepositoryReturnsTrue_ReturnsTrue() { //Arrange Sprint sprint = Sprint.Create(2, new List <Task>()); MemberWorkingDays memberWorkingDays = MemberWorkingDays.Create(1, 2, sprint, 21); //Act var result = await _memberWorkingDaysRepository.InsertAsync(memberWorkingDays); //Assert Assert.IsTrue(result); }
public async System.Threading.Tasks.Task UpdateAsync_MemberWorkingDaysRepositoryReturnsFalse_ReturnsFalse() { //Arrange MemberWorkingDays memberWorkingDays = new MemberWorkingDays { Id = 7, SprintId = 1, MemberId = 1, WorkingDays = 2 }; //Act var result = await _memberWorkingDaysRepository.UpdateAsync(memberWorkingDays); //Assert Assert.IsFalse(result); }
public async System.Threading.Tasks.Task InsertAsync_MemberWorkingDaysRepositoryReturnsTrue_ReturnsTrue() { //Arrange MemberWorkingDays memberWorkingDays = new MemberWorkingDays { Id = 4, SprintId = 2, MemberId = 1, WorkingDays = 21 }; //Act var result = await _memberWorkingDaysRepository.InsertAsync(memberWorkingDays); //Assert Assert.IsTrue(result); }
public async System.Threading.Tasks.Task AddMemberWorkingDaysAsync_ManageMemberWorkingDaysServiceReturnsFalse_ReturnsFalse() { //Arrange Sprint sprint = Sprint.Create(1, new List <Task>()); var memberWorkingDays = MemberWorkingDays.Create(1, 1, 1, sprint, -4); _memberWorkingDaysRepository.Setup(x => x.InsertAsync(It.IsAny <MemberWorkingDays>())).ReturnsAsync(true); //Act var result = await _manageMemberWorkingDaysService.AddMemberWorkingDaysAsync(memberWorkingDays); //Assert Assert.IsFalse(result); }
public async Task <bool> EditWorkingDays(int workingDaysId, int workingDays) { var memberWorkingDays = await _manageMemberWorkingDaysService.GetWorkingDaysByIdAsync(workingDaysId); if (memberWorkingDays == null) { return(false); } var newMemberWorkingDays = new MemberWorkingDays { Id = memberWorkingDays.Id, MemberId = memberWorkingDays.MemberId, SprintId = memberWorkingDays.SprintId, WorkingDays = workingDays }; return(await _manageMemberWorkingDaysService.EditMemberWorkingDaysAsync(newMemberWorkingDays)); }
public async System.Threading.Tasks.Task AddMemberWorkingDaysAsync_ManageMemberWorkingDaysServiceReturnsFalse_ReturnsFalse() { //Arrange var memberWorkingDays = new MemberWorkingDays { Id = 1, MemberId = 1, SprintId = 1, WorkingDays = -4 }; _memberWorkingDaysRepository.Setup(x => x.InsertAsync(It.IsAny <MemberWorkingDays>())).ReturnsAsync(true); //Act var result = await _manageMemberWorkingDaysService.AddMemberWorkingDaysAsync(memberWorkingDays); //Assert Assert.IsFalse(result); }
public async System.Threading.Tasks.Task UpdateAsync_MemberWorkingDaysRepositoryReturnsTrue_ReturnsTrue() { //Arrange Sprint sprint = Sprint.Create(1, new List <Task>()); MemberWorkingDays memberWorkingDays = MemberWorkingDays.Create(1, 1, 1, sprint, 2); _context.MemberWorkingDays.AddRange(GetFakeMemberWorkingDaysDb()); _context.SaveChanges(); //Act var result = await _memberWorkingDaysRepository.UpdateAsync(memberWorkingDays); //Assert Assert.IsTrue(result); }
public async System.Threading.Tasks.Task EditMemberWorkingDaysAsync_ManageMemberWorkingDaysServiceReturnsTrue_ReturnsTrue() { //Arrange Sprint sprint = Sprint.Create(1, new List <Task>()); var memberWorkingDays = MemberWorkingDays.Create(1, 1, 1, sprint, 10); _memberWorkingDaysRepository.Setup(x => x.UpdateAsync(It.IsAny <MemberWorkingDays>())).ReturnsAsync(true); _memberWorkingDaysRepository.Setup(x => x.GetByIdAsync(It.IsAny <int>())).ReturnsAsync(memberWorkingDays); //Act var result = await _manageMemberWorkingDaysService.EditMemberWorkingDaysAsync(memberWorkingDays); //Assert Assert.IsTrue(result); }
public async System.Threading.Tasks.Task DeleteAsync_MemberWorkingDaysRepositoryReturnsTrue_ReturnsTrue() { //Arrange MemberWorkingDays memberWorkingDays = new MemberWorkingDays { Id = 4, SprintId = 2, MemberId = 1, WorkingDays = 21 }; _context.MemberWorkingDays.Add(memberWorkingDays); _context.SaveChanges(); //Act var result = await _memberWorkingDaysRepository.DeleteAsync(memberWorkingDays); //Assert Assert.IsTrue(result); }
public async System.Threading.Tasks.Task EditMemberWorkingDaysAsync_ManageMemberWorkingDaysServiceReturnsTrue_ReturnsTrue() { //Arrange var memberWorkingDays = new MemberWorkingDays { Id = 1, MemberId = 1, SprintId = 1, WorkingDays = 10 }; _memberWorkingDaysRepository.Setup(x => x.UpdateAsync(It.IsAny <MemberWorkingDays>())).ReturnsAsync(true); _memberWorkingDaysRepository.Setup(x => x.GetByIdAsync(It.IsAny <int>())).ReturnsAsync(memberWorkingDays); //Act var result = await _manageMemberWorkingDaysService.EditMemberWorkingDaysAsync(memberWorkingDays); //Assert Assert.IsTrue(result); }
public async System.Threading.Tasks.Task GetTaskByIdAsync_ManageMemberWorkingDaysServiceReturnsId1_ReturnsId1() { //Arrange const int memberWorkingDaysId = 1; Sprint sprint = Sprint.Create(1, new List <Task>()); var memberWorkingDays = new List <MemberWorkingDays>() { MemberWorkingDays.Create(1, 1, 1, sprint, 21) }; var mock = memberWorkingDays.AsQueryable().BuildMock(); _memberWorkingDaysRepository.Setup(x => x.GetAllAsync()) .Returns(System.Threading.Tasks.Task.FromResult(memberWorkingDays.AsEnumerable())); //Act var result = await _manageMemberWorkingDaysService.GetWorkingDaysByIdAsync(memberWorkingDaysId); //Assert Assert.AreEqual(memberWorkingDaysId, result.Id); }
public async System.Threading.Tasks.Task GetStoryPointsInDayForMember_TestsValue(int sprintId, int teamMemberId, int teamMemberTotalSp, double excepted) { //Arrange var team = Team.Create(1, "1", "1234", new List <TeamMember>()); var sprint = Sprint.Create(1, 1, team, "Sprint1", 14, 4, PossibleStatuses.ActiveStatus); var memberWorkingDays = new List <MemberWorkingDays>() { MemberWorkingDays.Create(1, 1, 1, sprint, 7), }; _memberWorkingDaysRepository.Setup(x => x.GetAllAsync()) .Returns(System.Threading.Tasks.Task.FromResult(memberWorkingDays.AsEnumerable())); //Act var result = await _manageMemberWorkingDaysService.GetStoryPointsInDayForMember(sprintId, teamMemberId, teamMemberTotalSp); //Assert Assert.AreEqual(excepted, System.Math.Round(result, 2)); }
public async Task <bool> EditWorkingDays(int workingDaysId, int workingDays) { var memberWorkingDays = await _manageMemberWorkingDaysService.GetWorkingDaysByIdAsync(workingDaysId); if (memberWorkingDays == null) { return(false); } var newMemberWorkingDays = MemberWorkingDays.Create(memberWorkingDays.Id, memberWorkingDays.MemberId, memberWorkingDays.SprintId, memberWorkingDays.Sprint, workingDays); if (newMemberWorkingDays.WorkingDays >= 0 && newMemberWorkingDays.WorkingDays <= newMemberWorkingDays.Sprint.DaysInSprint) { return(await _manageMemberWorkingDaysService.EditMemberWorkingDaysAsync(newMemberWorkingDays)); } else { return(false); } }