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 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); } }