public void TimeManager_GetPersonTasksWithTime_CustomTasksAndJiraTasks_TimeShouldBeEqual(int daysCount, int jiraTasksCount, int customTaskCount) { var days = new WorkDayFactory().GetWorkDays(Year, Month, daysCount); var jiraTasks = new TaskFactory().GetJiraTasks(jiraTasksCount); var customTasks = new TaskFactory().GetCustomTasks(days, customTaskCount); var personTasks = new List<PersonTask>(); personTasks.AddRange(jiraTasks); personTasks.AddRange(customTasks); var personWorkMonth = TimeManager_GetPersonWorkMonthWithoutData(); personWorkMonth.PersonTasks = personTasks; personWorkMonth.WorkDays = days; var timeManager = new PersonTimeManager(new TimeSpan(8, 0, 0)); personWorkMonth.PersonTasks = timeManager.GetPersonTasksWithTime(personWorkMonth.PersonTasks, personWorkMonth.WorkDays); var workMonthHelper = new WorkMonthHelper(); var actualResult = workMonthHelper.ActualWorkTime(personWorkMonth).Ticks; var expectedResult = workMonthHelper.FullWorkTime(personWorkMonth).Ticks; var actualCustomTasks = personWorkMonth.PersonTasks.Where(t => t is CustomPersonTask).ToList(); Assert.AreEqual(expectedResult, actualResult); Assert.AreEqual(daysCount, personWorkMonth.WorkDays.Count); Assert.AreEqual(customTaskCount, actualCustomTasks.Count); foreach (var personTask in personWorkMonth.PersonTasks) { Assert.IsTrue(personTask.Hours > TimeSpan.Zero); } foreach (var customTask in actualCustomTasks) { var expectedCustomTask = customTasks.Single(t => t.Id == customTask.Id); Assert.AreEqual(expectedCustomTask.Hours.Value, customTask.Hours.Value); Assert.AreEqual(expectedCustomTask.Hours.Value, customTask.Hours.Value); Assert.AreEqual(expectedCustomTask.StartTime.Value, customTask.StartTime.Value); } }
public PersonWorkMonth TimeManager_GetPersonWorkMonthWithData(int daysCount, int tasksCount) { var projects = new ProjectFactory().GetProjects(); var products = new ProductFactory().GetProducts(); var person = new PersonFactory().GetPersons(projects[0], products[0]); var workDaysFactory = new WorkDayFactory(); var tasksFactory = new TaskFactory(); var personWorkMonth = new PersonWorkMonth { Person = person[0], Year = Year, Month = Month, PersonTasks = tasksFactory.GetJiraTasks(tasksCount), WorkDays = workDaysFactory.GetWorkDays(Year, Month, daysCount) }; var timeManager = new PersonTimeManager(new TimeSpan(8, 0, 0)); personWorkMonth.PersonTasks = timeManager.GetPersonTasksWithTime(personWorkMonth.PersonTasks, personWorkMonth.WorkDays); return personWorkMonth; }