public OpenFiscaResource Build(MotorVehicleSimulationCase rule, MotorVehiclePerson person, decimal dailyResult) { var result = new OpenFiscaResource(); string personName = "person1"; result.CreatePerson(personName); // Target value result.SetProp(personName, OF.TotalOTHours, null); // Person vars result.SetProp(personName, OF.WeeklyHmvoHours, person.WeeklyHmvoHours); result.SetProp(personName, OF.WeeklyBusHours, 0); result.SetProp(personName, OF.WeeklyCmvoHours, person.WeeklyCmvoHours); result.SetProp(personName, OF.WeeklyOtherHours, person.WeeklyOtherHours); result.SetProp(personName, OF.NumHolidaysInPeriod, person.NumHolidays); // Parameter overrides result.SetProp(personName, OF.StandardClcDailyHours, rule.StandardOtherDaily); result.SetProp(personName, OF.StandardCmvoDailyHours, rule.StandardCmvoDaily); result.SetProp(personName, OF.StandardClcWeeklyHours, rule.StandardOtherWeekly); result.SetProp(personName, OF.StandardCmvoWeeklyHours, rule.StandardCmvoWeekly); result.SetProp(personName, OF.StandardHmvoHolidayReduction, rule.StandardHighwayReduction); result.SetProp(personName, OF.StandardHmvoWeeklyHours, rule.StandardHighwayWeekly); // Daily result result.SetProp(personName, OF.DailyOTHours, dailyResult); return(result); }
public void ShouldCalculateWeeklyWithHoliday() { // Arrange var schedule = new MvoSchedule() { Hours = new List <HourSet>() { new HourSet(1, 2, 3, false), new HourSet(1, 2, 3, true), new HourSet(4, 5, 6, false), } }; // Act var person = new MotorVehiclePerson() { WeeklySchedule = schedule }; // Assert Assert.Equal(5, person.WeeklyCmvoHours); Assert.Equal(7, person.WeeklyHmvoHours); Assert.Equal(9, person.WeeklyOtherHours); Assert.Equal(1, person.NumHolidays); }
public void ShouldWorkNormally() { // Arrange decimal fakeDailyResult = 9m; decimal fakeAggregateResult = 10m; var openFiscaLib = A.Fake <IOpenFisca>(); var dailyRequestBuilder = A.Fake <IBuildDailyRequests>(); var aggregateRequestBuilder = A.Fake <IBuildAggregateRequests>(); var dailyResultExtractor = A.Fake <IExtractDailyResults>(); var aggregateResultExtractor = A.Fake <IExtractAggregateResults>(); A.CallTo(() => dailyResultExtractor.Extract(A <OpenFiscaResource> ._)) .Returns(fakeDailyResult); A.CallTo(() => aggregateResultExtractor.Extract(A <OpenFiscaResource> ._)) .Returns(fakeAggregateResult); // Act var sut = new MotorVehicleRuleExecutor( openFiscaLib, dailyRequestBuilder, aggregateRequestBuilder, dailyResultExtractor, aggregateResultExtractor); var simulationCase = A.Fake <MotorVehicleSimulationCase>(); var person = new MotorVehiclePerson(); var result = sut.Execute(simulationCase, person); // Assert A.CallTo(() => openFiscaLib.Calculate(A <OpenFiscaResource> ._)) .MustHaveHappenedTwiceExactly(); A.CallTo(() => dailyRequestBuilder.Build(A <MotorVehicleSimulationCase> ._, A <MotorVehiclePerson> ._)) .MustHaveHappenedOnceExactly(); A.CallTo(() => aggregateRequestBuilder.Build(A <MotorVehicleSimulationCase> ._, A <MotorVehiclePerson> ._, fakeDailyResult)) .MustHaveHappenedOnceExactly(); A.CallTo(() => dailyResultExtractor.Extract(A <OpenFiscaResource> ._)) .MustHaveHappenedOnceExactly(); A.CallTo(() => aggregateResultExtractor.Extract(A <OpenFiscaResource> ._)) .MustHaveHappenedOnceExactly(); // Could just make sure calls happened Assert.Equal(fakeAggregateResult, result); }
public void ShouldSucceedInAllScenarios() { var sut = GetSystem(); var simulationCase = GetBaseCase(); var testCases = GetSchedules(); foreach (var testCase in testCases) { var person = new MotorVehiclePerson() { WeeklySchedule = testCase.Item1 }; var result = sut.Execute(simulationCase, person); Assert.Equal(testCase.Item2, result); } }
private MotorVehiclePerson BuildPerson(MVSimulationViewModel vm) { var weeklySchedule = new MvoSchedule() { Hours = new List <HourSet>() }; foreach (var vmHour in vm.Person.Hours) { weeklySchedule.Hours.Add(new HourSet(vmHour.HoursCmvo.Value, vmHour.HoursHmvo.Value, vmHour.HoursOther.Value, vmHour.IsHoliday)); } var result = new MotorVehiclePerson() { Id = Guid.NewGuid(), WeeklySchedule = weeklySchedule }; return(result); }
public OpenFiscaResource Build(MotorVehicleSimulationCase rule, MotorVehiclePerson person) { var result = new OpenFiscaResource(); for (int i = 0; i < person.WeeklySchedule.Hours.Count; i++) { var hourSet = person.WeeklySchedule.Hours[i]; var personName = $"day_{i+1}"; result.CreatePerson(personName); result.SetProp(personName, OF.DailyOTHours, null); result.SetProp(personName, OF.DailyHmvoHours, hourSet.HoursHmvo); result.SetProp(personName, OF.DailyCmvoHours, hourSet.HoursCmvo); result.SetProp(personName, OF.DailyBusHours, 0); result.SetProp(personName, OF.DailyOtherHours, hourSet.HoursOther); result.SetProp(personName, OF.StandardClcDailyHours, rule.StandardOtherDaily); result.SetProp(personName, OF.StandardCmvoDailyHours, rule.StandardCmvoDaily); result.SetProp(personName, OF.IsHoliday, hourSet.IsHoliday); } return(result); }
public MotorVehicleResultsViewModel(SimulationFull <MotorVehicleSimulationCase> simulation, MotorVehiclePerson person) { FullSimulation = simulation; Person = person; }