public void MarkAsHoliday_DayIsMarkedAsHoliday(
            [Frozen] Mock<IZohoClient> zoho,
            TimeLog log,
            TimeLog log2)
        {
            var target = FilledDay(zoho, log, log2, false);

            target.MarkAsHoliday("test");

            Assert.True(target.IsHoliday);
            Assert.Equal("test", target.HolidayName);
        }
        public void Clear_AllInfoInDayCleared(
            [Frozen] Mock<IZohoClient> zoho,
            TimeLog log,
            TimeLog log2)
        {
            var target = FilledDay(zoho, log, log2, true);

            target.Clear();

            Assert.True(target.IsActive);
            Assert.False(target.IsFilled);
            Assert.False(target.IsHoliday);
            Assert.Null(target.HolidayName);
        }
        public void Delete_DeleteAllJobsAndClearDay(
            [Frozen] Mock<IZohoClient> zoho, 
            TimeLog log,
            TimeLog log2)
        {
            var target = FilledDay(zoho, log, log2, true);

            target.DeleteCommand.Execute(null);

            Assert.True(target.IsActive);
            Assert.False(target.IsFilled);
            Assert.True(target.IsHoliday);
            Assert.Equal("test", target.HolidayName);

            zoho.Verify(x => x.TimeTracker.TimeLog.DeleteAsync(log.TimelogId), Times.Once);
            zoho.Verify(x => x.TimeTracker.TimeLog.DeleteAsync(log2.TimelogId), Times.Once);
        }
        private static IDayViewModel FilledDay(Mock<IZohoClient> zoho, TimeLog log, TimeLog log2, bool isHoliday)
        {
            var logs = new List<TimeLog>
            {
                log,
                log2
            };
            var target = DayViewModel.DayFromThisMonth(1, new DateTime(2015, 01, 01), zoho.Object);
            target.FillLogs(logs);
            if (isHoliday)
            {
                target.MarkAsHoliday("test");
            }

            return target;
        }
        public async void FillDays_TimeLogRecieved_FilledWithCorrectValues(
            [Frozen] Mock<IZohoClient> zoho,
            [Frozen] Mock<IAuthenticationStorage> auth,
            AuthenticationData authData,
            DaysService target)
        {
            var startOfTheMonth = new DateTime(2015, 07, 01);
            var middleOfTheMonth = new DateTime(2015, 07, 15);
            var endOfTheMonth = startOfTheMonth.EndOfMonth();
            
            var firstLog = new TimeLog { WorkDate = startOfTheMonth, Hours = TimeSpan.FromHours(8) };
            var secondLog1 = new TimeLog { WorkDate = middleOfTheMonth, Hours = TimeSpan.FromHours(2) };
            var secondLog2 = new TimeLog { WorkDate = middleOfTheMonth, Hours = TimeSpan.FromHours(12) };
            var thirdLog = new TimeLog { WorkDate = endOfTheMonth, Hours = TimeSpan.FromHours(10) };

            var timeLogs = new List<TimeLog>
            {
                firstLog,
                secondLog1,
                secondLog2,
                thirdLog
            };

            auth.Setup(x => x.GetAuthenticationData())
                .Returns(authData);
            var days = target.GetDays(startOfTheMonth);

            zoho.Setup(x => x.TimeTracker.TimeLog.GetAsync(authData.Id, startOfTheMonth, endOfTheMonth, "all", "all"))
                .ReturnsAsync(timeLogs);
            
            // Act
            await target.FillDaysWithTimeLogsAsync(days, startOfTheMonth);

            // Assert
            zoho.Verify(x => x.TimeTracker.TimeLog.GetAsync(authData.Id, startOfTheMonth, endOfTheMonth, "all", "all"));
            zoho.Verify(x => x.Leave.GetHolidaysAsync(authData.Id));
            
            var firstDayInCalendar = days.First(x => x.Day == startOfTheMonth.Day);
            Assert.True(firstDayInCalendar.IsActive);
            Assert.True(firstDayInCalendar.IsFilled);
            Assert.Equal(TimeSpan.FromHours(8), firstDayInCalendar.Hours);
            Assert.False(firstDayInCalendar.IsHoliday);
            
            var secondDayInCalendar = days.First(x => x.Day == middleOfTheMonth.Day);
            Assert.True(secondDayInCalendar.IsActive);
            Assert.True(secondDayInCalendar.IsFilled);
            Assert.Equal(TimeSpan.FromHours(14), secondDayInCalendar.Hours);
            Assert.False(secondDayInCalendar.IsHoliday);
            
            var secondMiddleDayInCalendar = days.First(x => x.Day == middleOfTheMonth.Day + 1);
            Assert.False(secondMiddleDayInCalendar.IsHoliday);
            
            var thirdDayInMonth = days.First(x => x.Day == endOfTheMonth.Day);
            Assert.True(thirdDayInMonth.IsActive);
            Assert.True(thirdDayInMonth.IsFilled);
            Assert.Equal(TimeSpan.FromHours(10), thirdDayInMonth.Hours);
            Assert.False(thirdDayInMonth.IsHoliday);
            Assert.Null(thirdDayInMonth.HolidayName);

            var notFilledDay = days.First(x => x.Day == 2);
            Assert.True(notFilledDay.IsActive);
            Assert.False(notFilledDay.IsFilled);
        }