public void IsAffordanceAvailableTestRealDeviceIsThere() { // Location: realdevice // affordance: same realdevice Config.IsInUnitTesting = true; var col = new ColorRGB(255, 0, 0); var deviceActions = new ObservableCollection <DeviceAction>(); var aff = new Affordance("bla", null, null, false, PermittedGender.All, 1, col, string.Empty, null, string.Empty, string.Empty, true, true, 0, 100, false, ActionAfterInterruption.GoBackToOld, false, Guid.NewGuid().ToStrGuid(), BodilyActivityLevel.Low); var rd1 = new RealDevice("rd1", 1, string.Empty, null, string.Empty, false, false, string.Empty, Guid.NewGuid().ToStrGuid()); var allDevices1 = new List <IAssignableDevice> { // check if only the device is there rd1 }; var connectionString = string.Empty; var lt = new VLoadType("lt", string.Empty, "bla", "blub", 1, 1, new TimeSpan(0, 1, 0), 1, connectionString, LoadTypePriority.Mandatory, true, Guid.NewGuid().ToStrGuid()); var tbp = new TimeBasedProfile("name", 1, connectionString, TimeProfileType.Absolute, "data source", Guid.NewGuid().ToStrGuid()); aff.AffordanceDevices.Add(new AffordanceDevice(rd1, tbp, null, 0, null, new ObservableCollection <RealDevice>(), new ObservableCollection <DeviceCategory>(), "name", lt, string.Empty, 1, Guid.NewGuid().ToStrGuid())); (aff.IsAffordanceAvailable(allDevices1, deviceActions)).Should().BeTrue(); }
public void IsAffordanceAvailableTestCheckDeviceActionGroupInDeviceActionGroup() { // Location: device action group // affordance: device Action Group Config.IsInUnitTesting = true; var col = new ColorRGB(255, 0, 0); var deviceActions = new ObservableCollection <DeviceAction>(); var aff = new Affordance("bla", null, null, false, PermittedGender.All, 1, col, string.Empty, null, string.Empty, string.Empty, true, true, 0, 100, false, ActionAfterInterruption.GoBackToOld, false, Guid.NewGuid().ToStrGuid(), BodilyActivityLevel.Low); var rd1 = new RealDevice("rd1", 1, string.Empty, null, string.Empty, false, false, string.Empty, Guid.NewGuid().ToStrGuid()); var dg = new DeviceActionGroup("group", string.Empty, string.Empty, Guid.NewGuid().ToStrGuid()); var da = new DeviceAction("device action 1", null, "blub", string.Empty, dg, rd1, Guid.NewGuid().ToStrGuid()); deviceActions.Add(da); var devices = new ObservableCollection <RealDevice> { rd1 }; // check if it works with a device category that has the device var dc1 = new DeviceCategory("dc1", 0, string.Empty, false, devices, Guid.NewGuid().ToStrGuid(), null, true); rd1.DeviceCategory = dc1; dc1.RefreshSubDevices(); (dc1.SubDevices.Count).Should().Be(1); var connectionString = string.Empty; var lt = new VLoadType("lt", string.Empty, "bla", "blub", 1, 1, new TimeSpan(0, 1, 0), 1, connectionString, LoadTypePriority.Mandatory, true, Guid.NewGuid().ToStrGuid()); var tbp = new TimeBasedProfile("name", 1, connectionString, TimeProfileType.Absolute, "data source", Guid.NewGuid().ToStrGuid()); aff.AffordanceDevices.Add(new AffordanceDevice(dg, tbp, null, 0, null, new ObservableCollection <RealDevice>(), new ObservableCollection <DeviceCategory>(), "name", lt, string.Empty, 1, Guid.NewGuid().ToStrGuid())); var allDevices3 = new List <IAssignableDevice> { dg }; if (da.DeviceActionGroup == null) { throw new LPGException("device action group was null"); } var relevantDeviceActionGroup = da.DeviceActionGroup.GetDeviceActions(deviceActions); (relevantDeviceActionGroup.Count).Should().Be(1); (aff.IsAffordanceAvailable(allDevices3, deviceActions)).Should().BeTrue(); }
public void IsAffordanceAvailableTestAffordanceHasNoDevice() { // Location: realdevice // affordance: nothing Config.IsInUnitTesting = true; var col = new ColorRGB(255, 0, 0); var deviceActions = new ObservableCollection <DeviceAction>(); var aff = new Affordance("bla", null, null, false, PermittedGender.All, 1, col, string.Empty, null, string.Empty, string.Empty, true, true, 0, 100, false, ActionAfterInterruption.GoBackToOld, false, Guid.NewGuid().ToStrGuid(), BodilyActivityLevel.Low); var rd2 = new RealDevice("rd2", 1, string.Empty, null, string.Empty, false, false, string.Empty, Guid.NewGuid().ToStrGuid()); // check if the device is not there var allDevices2 = new List <IAssignableDevice> { rd2 }; var result = aff.IsAffordanceAvailable(allDevices2, deviceActions); (result).Should().BeFalse(); }