public void CheckRouteCompletenessTest()
        {
            TravelRouteSet trs   = new TravelRouteSet("trs", 1, "", "", Guid.NewGuid().ToStrGuid());
            List <Site>    sites = new List <Site>();

            //test with empty
            CalcTransportationDtoFactory.CheckRouteCompleteness(trs, sites);

            //test with one route
            Site sitea = new Site("sitea", 1, "", "", Guid.NewGuid().ToStrGuid());
            Site siteb = new Site("siteb", 2, "", "", Guid.NewGuid().ToStrGuid());

            sites.Add(sitea);
            sites.Add(siteb);
            trs.AddRoute(new TravelRoute(1, "", "Route1", "desc", sitea, siteb, Guid.NewGuid().ToStrGuid(), null), false);
            CalcTransportationDtoFactory.CheckRouteCompleteness(trs, sites);

            //one route missing
            Site sitec = new Site("sitec", 2, "", "", Guid.NewGuid().ToStrGuid());

            sites.Add(sitec);
            trs.AddRoute(new TravelRoute(1, "", "Route2", "desc", siteb, sitec, Guid.NewGuid().ToStrGuid(), null), false);
            Action crashfunction1 = () => CalcTransportationDtoFactory.CheckRouteCompleteness(trs, sites);

            crashfunction1.Should().Throw <DataIntegrityException>();
            //add missing route
            trs.AddRoute(new TravelRoute(1, "", "Route3", "desc", sitea, sitec, Guid.NewGuid().ToStrGuid(), null), false);
            CalcTransportationDtoFactory.CheckRouteCompleteness(trs, sites);
        }
        public void CheckReachabilityofLocationsTest()
        {
            List <Location> locations = new List <Location>();
            List <Site>     sites     = new List <Site>();

            CalcTransportationDtoFactory.CheckReachabilityofLocations(locations, sites, "calchouseholdname",
                                                                      "travelroutesetname");
            locations.Add(new Location("loc1", 1, "", Guid.NewGuid().ToStrGuid()));
            //not sites, one loc
            Action crashFunction1 = () =>
                                    CalcTransportationDtoFactory.CheckReachabilityofLocations(locations, sites, "calchouseholdname", "travelroutesetname");

            crashFunction1.Should().Throw <DataIntegrityException>();
            //two locations in the same site
            locations.Add(new Location("loc2", 2, "", Guid.NewGuid().ToStrGuid()));
            sites.Add(new Site("site1", 1, "", "bla", Guid.NewGuid().ToStrGuid()));
            sites[0].AddLocation(locations[0], false);
            sites[0].AddLocation(locations[1], false);
            CalcTransportationDtoFactory.CheckReachabilityofLocations(locations, sites, "calchouseholdname",
                                                                      "travelroutesetname");
            sites[0].Locations.Clear();
            //two locations in two sites
            sites.Add(new Site("site1", 1, "", "bla", Guid.NewGuid().ToStrGuid()));
            sites.Add(new Site("site2", 2, "", "bla", Guid.NewGuid().ToStrGuid()));
            sites[0].AddLocation(locations[0], false);
            sites[1].AddLocation(locations[1], false);
            CalcTransportationDtoFactory.CheckReachabilityofLocations(locations, sites, "calchouseholdname",
                                                                      "travelroutesetname");
        }
        public void DistanceToEnergyFactorTest()
        {
            VLoadType vlt = new VLoadType("elec", "", "W", "kWh", 1000, 1, new TimeSpan(1, 0, 0),
                                          1, "", LoadTypePriority.All, true, Guid.NewGuid().ToStrGuid(), 1);

            var result = CalcTransportationDtoFactory.DistanceToPowerFactor(100000, 15, vlt.ConversionFaktorPowerToSum);

            result.Should().BeApproximatelyWithinPercent(0.00185, 0.1);
            double distanceGained = 15000 * result * 3600;

            distanceGained.Should().BeApproximatelyWithinPercent(100000, 0.001);
            Logger.Info(result.ToString(CultureInfo.InvariantCulture));
        }
 public CalcModularHouseholdDtoFactory([NotNull] CalcLoadTypeDtoDictionary ltDict, [NotNull] Random random,
                                       [NotNull] CalcPersonDtoFactory calcPersonDtoFactory,
                                       [NotNull] CalcDeviceDtoFactory calcDeviceDtoFactory,
                                       [NotNull] CalcLocationDtoFactory calcLocationDtoFactory,
                                       [NotNull] CalcVariableDtoFactory calcVariableRepositoryDtoFactory,
                                       [NotNull] CalcAffordanceDtoFactory calcAffordanceDtoFactory,
                                       [NotNull] CalcTransportationDtoFactory transportationDtoFactory,
                                       CalcRepo calcRepo)
 {
     _ltDict = ltDict;
     _random = random;
     _calcPersonDtoFactory             = calcPersonDtoFactory;
     _calcDeviceDtoFactory             = calcDeviceDtoFactory;
     _calcLocationDtoFactory           = calcLocationDtoFactory;
     _calcVariableRepositoryDtoFactory = calcVariableRepositoryDtoFactory;
     _calcAffordanceDtoFactory         = calcAffordanceDtoFactory;
     _transportationDtoFactory         = transportationDtoFactory;
     _calcRepo = calcRepo;
 }