public void GivenTimeEntryWithFromAndThroughDates_WhenDeriving_ThenAmountOfTimeDerived() { // Arrange var frequencies = new TimeFrequencies(this.Session); var workOrder = new WorkTaskBuilder(this.Session).WithName("Task").Build(); var employee = new PersonBuilder(this.Session).WithFirstName("Good").WithLastName("Worker").Build(); var employment = new EmploymentBuilder(this.Session).WithEmployee(employee).Build(); this.Session.Derive(true); var now = DateTimeFactory.CreateDateTime(this.Session.Now()); var later = DateTimeFactory.CreateDateTime(now.AddHours(4)); var timeEntry = new TimeEntryBuilder(this.Session) .WithRateType(new RateTypes(this.Session).StandardRate) .WithFromDate(now) .WithThroughDate(later) .WithTimeFrequency(frequencies.Hour) .WithWorkEffort(workOrder) .Build(); employee.TimeSheetWhereWorker.AddTimeEntry(timeEntry); // Act this.Session.Derive(true); // Assert Assert.Equal(4.00M, timeEntry.AmountOfTime); Assert.Equal(4.00M, timeEntry.ActualHours); //// Re-arrange timeEntry.RemoveAmountOfTime(); timeEntry.TimeFrequency = frequencies.Day; // Act this.Session.Derive(true); // Assert Assert.Equal(Math.Round(4.0M / 24.0M, M.TimeEntry.AmountOfTime.Scale ?? 2), timeEntry.AmountOfTime); Assert.Equal(4.00M, timeEntry.ActualHours); //// Re-arrange timeEntry.RemoveAmountOfTime(); timeEntry.TimeFrequency = frequencies.Minute; // Act this.Session.Derive(true); // Assert Assert.Equal(4.0M * 60.0M, timeEntry.AmountOfTime); Assert.Equal(4.00M, timeEntry.ActualHours); }