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;
        }
        public void TimeManager_GetPersonTasksWithTime_OneCustomTask_TimeAndHoursShouldBeNotChanged()
        {
            const int daysCount = 30;

            var hours = TimeSpan.FromHours(2);
            var days = new WorkDayFactory().GetWorkDays(Year, Month, daysCount);
            var task = new CustomPersonTask("custom") { Hours = hours, StartTime = days[10].Date };

            var personWorkMonth = TimeManager_GetPersonWorkMonthWithoutData();
            personWorkMonth.PersonTasks = new List<PersonTask> { task };
            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 = hours.Ticks;

            Assert.AreEqual(expectedResult, actualResult);
            Assert.AreEqual(daysCount, personWorkMonth.WorkDays.Count);
            Assert.AreEqual(personWorkMonth.PersonTasks[0].Hours, hours);
            Assert.IsTrue(days[10].Date.Equals(personWorkMonth.PersonTasks[0].StartTime.Value));
        }
        public void TimeManager_GetPersonTasksWithTime_NullableInput_ResultShouldBeNull()
        {
            var projects = new ProjectFactory().GetProjects();
            var products = new ProductFactory().GetProducts();
            var person = new PersonFactory().GetPersons(projects[0], products[0]);

            var personWorkMonth = new PersonWorkMonth
            {
                Person = person[0],
                Year = Year,
                Month = Month,
                PersonTasks = null,
                WorkDays = null,
            };

            var timeManager = new PersonTimeManager(new TimeSpan(8, 0, 0));
            var result = timeManager.GetPersonTasksWithTime(personWorkMonth.PersonTasks, personWorkMonth.WorkDays);

            Assert.IsNull(result);
        }