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