public void TransportationDeviceCategoryTest()
        {
            using (DatabaseSetup db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
            {
                db.ClearTable(TransportationDeviceCategory.TableName);
                TransportationDeviceCategory sl = new TransportationDeviceCategory("name", null, db.ConnectionString, "desc", true, System.Guid.NewGuid().ToStrGuid());
                ObservableCollection <TransportationDeviceCategory> slocs = new ObservableCollection <TransportationDeviceCategory>();

                sl.SaveToDB();

                TransportationDeviceCategory.LoadFromDatabase(slocs, db.ConnectionString, false);
                db.Cleanup();
                (slocs.Count).Should().Be(1);
            }
        }
Пример #2
0
        private List <LoadingEntry> GetLoadingActions(bool ignoreMissingTables)
        {
            var actions = new List <LoadingEntry>
            {
                new LoadingEntry("Loadtypes",
                                 () => VLoadType.LoadFromDatabase(LoadTypes.MyItems, ConnectionString, ignoreMissingTables),
                                 LoadTypes),
                new LoadingEntry("Holidays",
                                 () => Holiday.LoadFromDatabase(Holidays.MyItems, ConnectionString, ignoreMissingTables), Holidays),
                new LoadingEntry("Variables",
                                 () => Variable.LoadFromDatabase(Variables.It, ConnectionString, ignoreMissingTables), Variables),

                new LoadingEntry("Date Based Profiles",
                                 () => DateBasedProfile.LoadFromDatabase(DateBasedProfiles.MyItems, ConnectionString,
                                                                         ignoreMissingTables), DateBasedProfiles),
                new LoadingEntry("Vacations",
                                 () => Vacation.LoadFromDatabase(Vacations.MyItems, ConnectionString, ignoreMissingTables),
                                 Vacations),
                new LoadingEntry("Desires",
                                 () => Desire.LoadFromDatabase(Desires.MyItems, ConnectionString, ignoreMissingTables), Desires),
                new LoadingEntry("Time Profiles",
                                 () => TimeBasedProfile.LoadFromDatabase(Timeprofiles.MyItems, ConnectionString, ignoreMissingTables),
                                 Timeprofiles),
                new LoadingEntry("Temperature Profiles",
                                 () => TemperatureProfile.LoadFromDatabase(TemperatureProfiles.MyItems, ConnectionString,
                                                                           ignoreMissingTables), TemperatureProfiles),
                new LoadingEntry("Generators",
                                 () => Generator.LoadFromDatabase(Generators.MyItems, ConnectionString, LoadTypes.MyItems,
                                                                  DateBasedProfiles.MyItems, ignoreMissingTables), Generators),
                new LoadingEntry("Energy Storages",
                                 () => EnergyStorage.LoadFromDatabase(EnergyStorages.MyItems, ConnectionString, LoadTypes.MyItems, Variables.MyItems,
                                                                      ignoreMissingTables), EnergyStorages),
                new LoadingEntry("Transformation Devices",
                                 () => TransformationDevice.LoadFromDatabase(TransformationDevices.MyItems, ConnectionString,
                                                                             LoadTypes.MyItems, Variables.MyItems, ignoreMissingTables), TransformationDevices),
                new LoadingEntry("Device Categories", () =>
                {
                    DeviceCategory.LoadFromDatabase(DeviceCategories.MyItems, out _dcnone, ConnectionString,
                                                    RealDevices.MyItems, ignoreMissingTables);
                    DeviceCategories.DeviceCategoryNone = _dcnone;
                }, DeviceCategories),

                new LoadingEntry("Real Devices",
                                 () => RealDevice.LoadFromDatabase(RealDevices.MyItems, DeviceCategories.MyItems,
                                                                   DeviceCategories.DeviceCategoryNone, ConnectionString, LoadTypes.MyItems, Timeprofiles.MyItems,
                                                                   ignoreMissingTables), RealDevices),
                new LoadingEntry("Device Action Groups",
                                 () => DeviceActionGroup.LoadFromDatabase(DeviceActionGroups.MyItems, ConnectionString,
                                                                          ignoreMissingTables), DeviceActionGroups),
                new LoadingEntry("Device Actions",
                                 () => DeviceAction.LoadFromDatabase(DeviceActions.MyItems, ConnectionString, Timeprofiles.MyItems,
                                                                     RealDevices.MyItems, LoadTypes.MyItems, DeviceActionGroups.MyItems, ignoreMissingTables),
                                 DeviceActions),
                new LoadingEntry("Device Tagging Sets",
                                 () => DeviceTaggingSet.LoadFromDatabase(DeviceTaggingSets.MyItems, ConnectionString,
                                                                         ignoreMissingTables, RealDevices.MyItems, LoadTypes.It), DeviceTaggingSets),
                new LoadingEntry("Persons",
                                 () => Person.LoadFromDatabase(Persons.MyItems, ConnectionString,
                                                               ignoreMissingTables), Persons),
                new LoadingEntry("Locations",
                                 () => Location.LoadFromDatabase(Locations.MyItems, ConnectionString, RealDevices.MyItems,
                                                                 DeviceCategories.MyItems, LoadTypes.MyItems, ignoreMissingTables), Locations),
                new LoadingEntry("Time Limits",
                                 () => TimeLimit.LoadFromDatabase(TimeLimits.MyItems, DateBasedProfiles.MyItems, ConnectionString,
                                                                  ignoreMissingTables), TimeLimits),
                new LoadingEntry("Geographic Locations",
                                 () => GeographicLocation.LoadFromDatabase(GeographicLocations.MyItems, ConnectionString,
                                                                           Holidays.MyItems, TimeLimits.MyItems, ignoreMissingTables), GeographicLocations),
                new LoadingEntry("Subaffordances",
                                 () => SubAffordance.LoadFromDatabase(SubAffordances.MyItems, ConnectionString, Desires.MyItems,
                                                                      ignoreMissingTables, Locations.It, Variables.It), SubAffordances),
                new LoadingEntry("Affordances",
                                 () => Affordance.LoadFromDatabase(Affordances.MyItems, ConnectionString, Timeprofiles.MyItems,
                                                                   DeviceCategories.MyItems, RealDevices.MyItems, Desires.MyItems, SubAffordances.MyItems,
                                                                   LoadTypes.MyItems, TimeLimits.MyItems, DeviceActions.MyItems, DeviceActionGroups.MyItems,
                                                                   Locations.It, ignoreMissingTables, Variables.It), Affordances),
                new LoadingEntry("Affordance Tagging Sets",
                                 () => AffordanceTaggingSet.LoadFromDatabase(AffordanceTaggingSets.MyItems, ConnectionString,
                                                                             ignoreMissingTables, Affordances.MyItems, LoadTypes.It), AffordanceTaggingSets),
                new LoadingEntry("Trait Tags",
                                 () => TraitTag.LoadFromDatabase(TraitTags.MyItems, ConnectionString, ignoreMissingTables),
                                 TraitTags),
                new LoadingEntry("Household Traits",
                                 () => HouseholdTrait.LoadFromDatabase(HouseholdTraits.MyItems, ConnectionString, Locations.MyItems,
                                                                       Affordances.MyItems, RealDevices.MyItems, DeviceCategories.MyItems, Timeprofiles.MyItems,
                                                                       LoadTypes.MyItems, TimeLimits.MyItems, Desires.MyItems, DeviceActions.It, DeviceActionGroups.It,
                                                                       TraitTags.It, ignoreMissingTables, Variables.It), HouseholdTraits),
                new LoadingEntry("Device Selections",
                                 () => DeviceSelection.LoadFromDatabase(DeviceSelections.MyItems, ConnectionString,
                                                                        DeviceCategories.MyItems, RealDevices.MyItems, DeviceActions.It, DeviceActionGroups.It,
                                                                        ignoreMissingTables), DeviceSelections),
                new LoadingEntry("Household Tags",
                                 () => HouseholdTag.LoadFromDatabase(HouseholdTags.It, ConnectionString, ignoreMissingTables),
                                 HouseholdTags),
                new LoadingEntry("Modular Households",
                                 () => ModularHousehold.LoadFromDatabase(ModularHouseholds.MyItems, ConnectionString,
                                                                         HouseholdTraits.MyItems, DeviceSelections.MyItems, ignoreMissingTables, Persons.MyItems,
                                                                         Vacations.It, HouseholdTags.It, TraitTags.It), ModularHouseholds),
                new LoadingEntry("Household Templates",
                                 () => HouseholdTemplate.LoadFromDatabase(HouseholdTemplates.MyItems, ConnectionString,
                                                                          HouseholdTraits.MyItems, ignoreMissingTables, Persons.MyItems, TraitTags.It, Vacations.It,
                                                                          HouseholdTags.It, DateBasedProfiles.It), HouseholdTemplates),
                new LoadingEntry("Template Persons",
                                 () => TemplatePerson.LoadFromDatabase(TemplatePersons.It, ConnectionString, HouseholdTraits.It,
                                                                       ignoreMissingTables, ModularHouseholds.It, Persons.It), TemplatePersons),
                new LoadingEntry("Household Plans",
                                 () => HouseholdPlan.LoadFromDatabase(HouseholdPlans.MyItems, ConnectionString, ignoreMissingTables,
                                                                      Persons.MyItems, AffordanceTaggingSets.MyItems, ModularHouseholds.MyItems),
                                 HouseholdPlans),
                new LoadingEntry("House Types",
                                 () => HouseType.LoadFromDatabase(HouseTypes.MyItems, ConnectionString, RealDevices.MyItems,
                                                                  DeviceCategories.MyItems, Timeprofiles.MyItems, TimeLimits.MyItems, LoadTypes.MyItems,
                                                                  TransformationDevices.MyItems, EnergyStorages.MyItems, Generators.MyItems, ignoreMissingTables,
                                                                  Locations.MyItems, DeviceActions.It, DeviceActionGroups.It, Variables.It), HouseTypes),
                new LoadingEntry("Transportation Device Categories",
                                 () => TransportationDeviceCategory.LoadFromDatabase(TransportationDeviceCategories.It, ConnectionString,
                                                                                     ignoreMissingTables), TransportationDeviceCategories),
                new LoadingEntry("Sites",
                                 () => Site.LoadFromDatabase(Sites.It,
                                                             ConnectionString, ignoreMissingTables,
                                                             Locations.It), Sites),
                new LoadingEntry("Transportation Devices",
                                 () => TransportationDevice.LoadFromDatabase(TransportationDevices.It, ConnectionString, ignoreMissingTables,
                                                                             TransportationDeviceCategories.It, LoadTypes.It), TransportationDevices),

                new LoadingEntry("Transportation Device Sets",
                                 () => TransportationDeviceSet.LoadFromDatabase(TransportationDeviceSets.It, ConnectionString,
                                                                                ignoreMissingTables, TransportationDevices.It), TransportationDeviceSets),

                new LoadingEntry("Travel Routes",
                                 () => TravelRoute.LoadFromDatabase(TravelRoutes.It, ConnectionString, ignoreMissingTables,
                                                                    TransportationDeviceCategories.It, Sites.It), TravelRoutes),

                new LoadingEntry("Travel Route Sets",
                                 () => TravelRouteSet.LoadFromDatabase(TravelRouteSets.It, ConnectionString, ignoreMissingTables,
                                                                       TravelRoutes.It), TravelRouteSets),
                new LoadingEntry("Charging Station Sets",
                                 () => ChargingStationSet.LoadFromDatabase(ChargingStationSets.It,
                                                                           ConnectionString, ignoreMissingTables,
                                                                           LoadTypes.It, TransportationDeviceCategories.It, Sites.It), ChargingStationSets),

                new LoadingEntry("Houses",
                                 () => House.LoadFromDatabase(Houses.MyItems, ConnectionString, TemperatureProfiles.MyItems,
                                                              GeographicLocations.MyItems, HouseTypes.MyItems,
                                                              ModularHouseholds.MyItems, ChargingStationSets.MyItems,
                                                              TransportationDeviceSets.MyItems, TravelRouteSets.MyItems,
                                                              ignoreMissingTables), Houses),
                new LoadingEntry("Settlements",
                                 () => Settlement.LoadFromDatabase(Settlements.MyItems, ConnectionString,
                                                                   TemperatureProfiles.MyItems, GeographicLocations.MyItems, ModularHouseholds.MyItems, Houses.MyItems,
                                                                   ignoreMissingTables), Settlements),
                new LoadingEntry("Settlement Templates",
                                 () => SettlementTemplate.LoadFromDatabase(SettlementTemplates.It, ConnectionString,
                                                                           HouseholdTemplates.It, HouseTypes.It, ignoreMissingTables, TemperatureProfiles.It,
                                                                           GeographicLocations.It, HouseholdTags.It, HouseholdTraits.It), SettlementTemplates),
                new LoadingEntry("Settings",
                                 () => MyGeneralConfig = GeneralConfig.LoadFromDatabase(ConnectionString, ignoreMissingTables), null),
                new LoadingEntry("Calculation Outcomes",
                                 () => CalculationOutcome.LoadFromDatabase(CalculationOutcomes.MyItems, ConnectionString,
                                                                           ignoreMissingTables), CalculationOutcomes)
            };

            return(actions);
        }