public void TransportationDeviceTest() { using (var db = new DatabaseSetup(Utili.GetCurrentMethodAndClass())) { db.ClearTable(TransportationDeviceCategory.TableName); db.ClearTable(TransportationDevice.TableName); var tdc = new TransportationDeviceCategory("tdc1", null, db.ConnectionString, "desc", true, Guid.NewGuid().ToStrGuid()); tdc.SaveToDB(); VLoadType chargingloadType = (VLoadType)VLoadType.CreateNewItem(null, db.ConnectionString); chargingloadType.SaveToDB(); var sl = new TransportationDevice("name", null, db.ConnectionString, "desc", 1, SpeedUnit.Kmh, tdc, 100, 10, 10, 10, chargingloadType, Guid.NewGuid().ToStrGuid()); var slocs = new ObservableCollection <TransportationDevice>(); sl.SaveToDB(); var categories = new ObservableCollection <TransportationDeviceCategory> { tdc }; var loadTypes = new ObservableCollection <VLoadType>(); var mylt = new VLoadType("myloadtype", "", "W", "kWh", 1, 1, new TimeSpan(1, 0, 0), 1, db.ConnectionString, LoadTypePriority.RecommendedForHouseholds, true, Guid.NewGuid().ToStrGuid()); mylt.SaveToDB(); loadTypes.Add(mylt); loadTypes.Add(chargingloadType); sl.AddLoad(mylt, 10); TransportationDevice.LoadFromDatabase(slocs, db.ConnectionString, false, categories, loadTypes); db.Cleanup(); (slocs.Count).Should().Be(1); TransportationDevice td = slocs[0]; (td.ChargingLoadType).Should().Be(chargingloadType); } }
public void SiteLocationTest() { using (DatabaseSetup db = new DatabaseSetup(Utili.GetCurrentMethodAndClass())) { db.ClearTable(Site.TableName); db.ClearTable(SiteLocation.TableName); Location loc = new Location("loc1", null, db.ConnectionString, Guid.NewGuid().ToStrGuid()); loc.SaveToDB(); Site site = new Site("site1", null, db.ConnectionString, "desc", Guid.NewGuid().ToStrGuid()); TransportationDeviceCategory cat = new TransportationDeviceCategory("bla", 1, db.ConnectionString, "desc", true, Guid.NewGuid().ToStrGuid()); VLoadType lt = new VLoadType("mylt", "desc", "w", "kwh", 1, 1, new TimeSpan(0, 1, 0), 1, db.ConnectionString, LoadTypePriority.All, false, Guid.NewGuid().ToStrGuid()); lt.SaveToDB(); cat.SaveToDB(); site.SaveToDB(); //site.AddChargingStation(cat, lt, 1); site.AddLocation(loc); //loading ObservableCollection <Site> slocs = new ObservableCollection <Site>(); ObservableCollection <Location> locs = new ObservableCollection <Location> { loc }; Site.LoadFromDatabase(slocs, db.ConnectionString, false, locs); //Site mysite = slocs[0]; //(mysite.ChargingStations.Count).Should().Be(1); db.Cleanup(); (slocs.Count).Should().Be(1); } }
public void TravelRouteTest() { using (DatabaseSetup db = new DatabaseSetup(Utili.GetCurrentMethodAndClass())) { db.ClearTable(TravelRoute.TableName); db.ClearTable(TravelRouteStep.TableName); Location loc = new Location("loc1", null, db.ConnectionString, Guid.NewGuid().ToStrGuid()); loc.SaveToDB(); Site siteA = new Site("site1", null, db.ConnectionString, "desc", Guid.NewGuid().ToStrGuid()); siteA.SaveToDB(); Site siteB = new Site("site2", null, db.ConnectionString, "desc", Guid.NewGuid().ToStrGuid()); siteB.SaveToDB(); TransportationDeviceCategory td = new TransportationDeviceCategory("transportationdevicecategory", null, db.ConnectionString, "desc", true, Guid.NewGuid().ToStrGuid()); td.SaveToDB(); TravelRoute tr = new TravelRoute(null, db.ConnectionString, "route", "desc", siteA, siteB, Guid.NewGuid().ToStrGuid(), null); tr.SaveToDB(); tr.AddStep("name1", td, 100, 1, "key1"); tr.AddStep("name3", td, 100, 10, "key3"); tr.AddStep("name2", td, 100, 2, "key2"); //test the sorting of steps while adding based on step number ("name1").Should().Be(tr.Steps[0].Name); ("name2").Should().Be(tr.Steps[1].Name); ("name3").Should().Be(tr.Steps[2].Name); ("key1").Should().Be(tr.Steps[0].StepKey); ("key2").Should().Be(tr.Steps[1].StepKey); ("key3").Should().Be(tr.Steps[2].StepKey); foreach (TravelRouteStep step in tr.Steps) { Logger.Info(step.Name); } //loading ObservableCollection <Site> sites = new ObservableCollection <Site> { siteA, siteB }; ObservableCollection <TransportationDeviceCategory> transportationDeviceCategories = new ObservableCollection <TransportationDeviceCategory> { td }; ObservableCollection <TravelRoute> routes = new ObservableCollection <TravelRoute>(); TravelRoute.LoadFromDatabase(routes, db.ConnectionString, false, transportationDeviceCategories, sites); (routes.Count).Should().Be(1); tr = routes[0]; ("name1").Should().Be(tr.Steps[0].Name); ("name2").Should().Be(tr.Steps[1].Name); ("name3").Should().Be(tr.Steps[2].Name); ("key1").Should().Be(tr.Steps[0].StepKey); ("key2").Should().Be(tr.Steps[1].StepKey); ("key3").Should().Be(tr.Steps[2].StepKey); db.Cleanup(); } }
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); } }
public void TransportationDeviceSetTest() { using (DatabaseSetup db = new DatabaseSetup(Utili.GetCurrentMethodAndClass())) { db.ClearTable(TransportationDeviceSet.TableName); db.ClearTable(TransportationDevice.TableName); db.ClearTable(TransportationDeviceCategory.TableName); TransportationDeviceSet tds = new TransportationDeviceSet("transportationdeviceset", null, db.ConnectionString, "desc", System.Guid.NewGuid().ToStrGuid()); tds.SaveToDB(); TransportationDeviceCategory tdc = new TransportationDeviceCategory("transportationdevicecategory", null, db.ConnectionString, "desc", true, System.Guid.NewGuid().ToStrGuid()); tdc.SaveToDB(); VLoadType vlt = (VLoadType)VLoadType.CreateNewItem(null, db.ConnectionString); vlt.SaveToDB(); TransportationDevice tdev = new TransportationDevice("mydevice", null, db.ConnectionString, "", 1, SpeedUnit.Kmh, tdc, 1000, 10, 100, 100, vlt, System.Guid.NewGuid().ToStrGuid()); tdev.SaveToDB(); ObservableCollection <TransportationDevice> transportationDevices = new ObservableCollection <TransportationDevice> { tdev }; tds.AddDevice(tdev); /*ObservableCollection<TransportationDeviceCategory> categories = new ObservableCollection<TransportationDeviceCategory> * { * tdc * };*/ ObservableCollection <TransportationDeviceSet> result = new ObservableCollection <TransportationDeviceSet>(); TransportationDeviceSet.LoadFromDatabase(result, db.ConnectionString, false, transportationDevices); db.Cleanup(); (result.Count).Should().Be(1); (result[0].TransportationDeviceSetEntries.Count).Should().Be(1); } }
public void RunChargingStationSetTests() { using (DatabaseSetup db = new DatabaseSetup(Utili.GetCurrentMethodAndClass())) { db.ClearTable(ChargingStationSet.TableName); Location loc = new Location("loc1", null, db.ConnectionString, Guid.NewGuid().ToStrGuid()); loc.SaveToDB(); ChargingStationSet sl = new ChargingStationSet("blub", null, db.ConnectionString, "desc", Guid.NewGuid().ToStrGuid()); sl.SaveToDB(); TransportationDeviceCategory tdc = new TransportationDeviceCategory("tdc", null, db.ConnectionString, "desc", false, Guid.NewGuid().ToStrGuid()); tdc.SaveToDB(); VLoadType vlt = (VLoadType)VLoadType.CreateNewItem(s => false, db.ConnectionString); vlt.SaveToDB(); Site site = (Site)Site.CreateNewItem(_ => false, db.ConnectionString); site.SaveToDB(); sl.AddChargingStation(tdc, vlt, 10, site, vlt); ObservableCollection <VLoadType> lts = new ObservableCollection <VLoadType> { vlt }; ObservableCollection <TransportationDeviceCategory> cats = new ObservableCollection <TransportationDeviceCategory> { tdc }; ObservableCollection <ChargingStationSet> css = new ObservableCollection <ChargingStationSet>(); ObservableCollection <Site> sites = new ObservableCollection <Site> { site }; ChargingStationSet.LoadFromDatabase(css, db.ConnectionString, false, lts, cats, sites); db.Cleanup(); (css.Count).Should().Be(1); (css[0].ChargingStations.Count).Should().Be(1); } }