public void InstanceSubScopeRemovedFromReferenceEquipment() { //Arrange TECTemplates templates = new TECTemplates(); TemplateSynchronizer <TECEquipment> equipSynchronizer = templates.EquipmentSynchronizer; TemplateSynchronizer <TECSubScope> ssSynchronizer = templates.SubScopeSynchronizer; TECEquipment templateEquip = new TECEquipment(); templates.Templates.EquipmentTemplates.Add(templateEquip); TECSubScope ss = new TECSubScope(); templateEquip.SubScope.Add(ss); TECEquipment refEqiup = equipSynchronizer.NewItem(templateEquip); TECSubScope refSS = refEqiup.SubScope[0]; //Act refEqiup.SubScope.Remove(refSS); //Assert Assert.IsTrue(templateEquip.SubScope.Count == 0, "SubScope not removed properly from Equipment template."); Assert.IsFalse(ssSynchronizer.Contains(ss), "SubScope was not removed properly from synchronizer."); Assert.IsFalse(ssSynchronizer.Contains(refSS), "Reference SubScope was not removed properly from synchronizer."); }
public void CanConnectToNetworkTest1() { TECProtocol firstProtocol = new TECProtocol(new List <TECConnectionType>()); TECProtocol secondProtocol = new TECProtocol(new List <TECConnectionType>()); TECProtocol thirdProtocol = new TECProtocol(new List <TECConnectionType>()); TECProtocol fourthProtocol = new TECProtocol(new List <TECConnectionType>()); TECDevice compatibleDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>() { secondProtocol, firstProtocol, fourthProtocol }, new TECManufacturer()); TECSubScope subScope = new TECSubScope(); subScope.Devices.Add(compatibleDevice); TECControllerType type = new TECControllerType(new TECManufacturer()); type.IO.Add(new TECIO(firstProtocol)); type.IO.Add(new TECIO(secondProtocol)); type.IO.Add(new TECIO(thirdProtocol)); TECProvidedController controller = new TECProvidedController(type); TECNetworkConnection connection = controller.AddNetworkConnection(thirdProtocol); Assert.IsFalse(subScope.CanConnectToNetwork(connection)); }
private void addExecute() { for (int x = 0; x < Quantity; x++) { TECSubScope subScope = null; if (underlyingTemplate != null) { subScope = AsReference ? templates.SubScopeSynchronizer.NewItem(underlyingTemplate) : new TECSubScope(underlyingTemplate); subScope.CopyPropertiesFromScope(ToAdd); foreach (IEndDevice device in ToAdd.Devices.Where(item => !originalDevices.Contains(item))) { subScope.AddDevice(device); } foreach (TECPoint point in ToAdd.Points.Where(item => !originalPoints.Contains(item))) { subScope.AddPoint(point); } } else { subScope = new TECSubScope(ToAdd); } add(subScope); if (ConnectVM != null && ConnectVM.Connect) { ConnectVM.ExecuteConnection(subScope); } Added?.Invoke(subScope); } }
public void AddDeviceToConnectedNetwork() { TECControllerType type = new TECControllerType(new TECManufacturer()); TECProtocol protocol = new TECProtocol(new List <TECConnectionType>()); type.IO.Add(new TECIO(protocol)); TECProvidedController controller = new TECProvidedController(type); TECDevice device = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol> { protocol }, new TECManufacturer()); TECSubScope subScope = new TECSubScope(); subScope.Devices.Add(device); controller.Connect(subScope, protocol); TECDevice otherDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol> { protocol }, new TECManufacturer()); subScope.AddDevice(otherDevice); Assert.IsTrue(subScope.Devices.Contains(otherDevice)); TECProtocol otherProtocol = new TECProtocol(new List <TECConnectionType>()); TECDevice nextDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol> { otherProtocol }, new TECManufacturer()); subScope.AddDevice(nextDevice); Assert.IsFalse(subScope.Devices.Contains(nextDevice)); }
public void AvailableProtocols1() { TECConnectionType type1 = new TECConnectionType(); TECConnectionType type2 = new TECConnectionType(); TECProtocol prot1 = new TECProtocol(new List <TECConnectionType>()); TECProtocol prot2 = new TECProtocol(new List <TECConnectionType>()); TECProtocol prot3 = new TECProtocol(new List <TECConnectionType>()); TECDevice dev1 = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol> { prot1, prot2 }, new TECManufacturer()); TECDevice dev2 = new TECDevice(new List <TECConnectionType> { type2 }, new List <TECProtocol> { prot1, prot3 }, new TECManufacturer()); TECSubScope ss = new TECSubScope(); bool dev1Added = ss.AddDevice(dev1); bool dev2Added = ss.AddDevice(dev2); Assert.IsTrue(dev1Added); Assert.IsTrue(dev2Added); Assert.IsFalse(ss.AvailableProtocols.Any(prot => { return(prot is TECHardwiredProtocol); })); Assert.IsTrue(ss.AvailableProtocols.Contains(prot1)); Assert.IsFalse(ss.AvailableProtocols.Contains(prot2)); Assert.IsFalse(ss.AvailableProtocols.Contains(prot3)); Assert.AreEqual(1, ss.AvailableProtocols.Count); }
public void RemoveNetworkConnectionTest() { TECProtocol firstProtocol = new TECProtocol(new List <TECConnectionType>()); TECProtocol secondProtocol = new TECProtocol(new List <TECConnectionType>()); TECProtocol thirdProtocol = new TECProtocol(new List <TECConnectionType>()); TECProtocol fourthProtocol = new TECProtocol(new List <TECConnectionType>()); TECDevice compatibleDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>() { secondProtocol, firstProtocol, fourthProtocol }, new TECManufacturer()); TECSubScope subScope = new TECSubScope(); subScope.Devices.Add(compatibleDevice); TECControllerType type = new TECControllerType(new TECManufacturer()); type.IO.Add(new TECIO(firstProtocol)); type.IO.Add(new TECIO(secondProtocol)); type.IO.Add(new TECIO(thirdProtocol)); TECProvidedController controller = new TECProvidedController(type); TECNetworkConnection connection = controller.Connect(subScope, firstProtocol) as TECNetworkConnection; controller.RemoveNetworkConnection(connection); Assert.IsFalse(connection.Children.Contains(subScope)); Assert.IsFalse(controller.ChildrenConnections.Contains(connection)); Assert.IsNull((subScope as IConnectable).GetParentConnection()); }
public void AddPointToConnectedNetwork() { TECControllerType type = new TECControllerType(new TECManufacturer()); TECProtocol protocol = new TECProtocol(new List <TECConnectionType>()); type.IO.Add(new TECIO(IOType.AI)); type.IO.Add(new TECIO(protocol)); TECProvidedController controller = new TECProvidedController(type); TECDevice device = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol> { protocol }, new TECManufacturer()); TECSubScope subScope = new TECSubScope(); subScope.Devices.Add(device); controller.Connect(subScope, protocol); TECPoint point = new TECPoint(); point.Type = IOType.AI; subScope.AddPoint(point); Assert.IsTrue(subScope.Points.Contains(point)); Assert.IsTrue(controller.AvailableIO.IONumber(IOType.AI) == 1); TECPoint otherPoint = new TECPoint(); otherPoint.Type = IOType.AI; subScope.AddPoint(otherPoint); Assert.IsTrue(subScope.Points.Contains(otherPoint)); Assert.IsTrue(controller.AvailableIO.IONumber(IOType.AI) == 1); }
public void CanConnectTest4() { TECProtocol firstProtocol = new TECProtocol(new List <TECConnectionType>()); TECProtocol secondProtocol = new TECProtocol(new List <TECConnectionType>()); TECProtocol thirdProtocol = new TECProtocol(new List <TECConnectionType>()); TECProtocol fourthProtocol = new TECProtocol(new List <TECConnectionType>()); TECDevice compatibleDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>() { secondProtocol, firstProtocol, fourthProtocol }, new TECManufacturer()); TECSubScope subScope = new TECSubScope(); subScope.Devices.Add(compatibleDevice); TECControllerType type = new TECControllerType(new TECManufacturer()); TECIOModule module = new TECIOModule(new TECManufacturer()); module.IO.Add(new TECIO(firstProtocol)); module.IO.Add(new TECIO(secondProtocol)); module.IO.Add(new TECIO(thirdProtocol)); type.IOModules.Add(module); TECProvidedController controller = new TECProvidedController(type); Assert.IsTrue(controller.CanConnect(subScope, firstProtocol)); Assert.IsTrue(controller.CanConnect(subScope, secondProtocol)); Assert.IsFalse(controller.CanConnect(subScope, fourthProtocol)); }
public void ConnectTest3() { TECConnectionType connectionType = new TECConnectionType(); TECDevice compatibleDevice = new TECDevice(new List <TECConnectionType> { connectionType }, new List <TECProtocol>(), new TECManufacturer()); TECSubScope subScope = new TECSubScope(); subScope.Devices.Add(compatibleDevice); TECPoint point = new TECPoint(); point.Type = IOType.AI; subScope.Points.Add(point); TECControllerType type = new TECControllerType(new TECManufacturer()); TECIOModule module = new TECIOModule(new TECManufacturer()); module.IO.Add(new TECIO(IOType.AO)); type.IOModules.Add(module); TECProvidedController controller = new TECProvidedController(type); TECHardwiredConnection connection = controller.Connect(subScope, subScope.HardwiredProtocol()) as TECHardwiredConnection; Assert.IsNull(connection); }
private string getTemplateText(TECObject item) { TECTemplates templates = ScopeManager as TECTemplates; if (templates.IsTemplateObject(item)) { string parentString = ""; if (item is TECSubScope subScope) { TECSubScope parent = templates.SubScopeSynchronizer.GetParent(subScope); if (item != parent && parent != null) { parentString = String.Format(" of {0}", parent.Name); } } else if (item is TECEquipment equipment) { TECEquipment parent = templates.EquipmentSynchronizer.GetParent(equipment); if (item != parent && parent != null) { parentString = String.Format(" of {0}", parent.Name); } } return(String.Format("Reference{0}", parentString)); } return("Instance Template"); }
public void CanChangeTypeTest1() { TECControllerType cType = new TECControllerType(new TECManufacturer()); TECProtocol protocol = new TECProtocol(new List <TECConnectionType>()); cType.IO.Add(new TECIO(protocol)); cType.IO.Add(new TECIO(IOType.AI)); TECControllerType otherCType = new TECControllerType(new TECManufacturer()); TECProvidedController controller = new TECProvidedController(cType); TECSubScope ss1 = new TECSubScope(); TECSubScope ss2 = new TECSubScope(); TECDevice proDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>() { protocol }, new TECManufacturer()); TECDevice hardDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>(), new TECManufacturer()); ss1.Devices.Add(proDevice); ss2.Devices.Add(hardDevice); TECPoint point = new TECPoint(); point.Type = IOType.AI; ss2.AddPoint(point); controller.Connect(ss1, protocol); controller.Connect(ss2, ss2.HardwiredProtocol()); Assert.IsFalse(controller.CanChangeType(otherCType)); }
public void Undo_Template_Equipment_SubScope() { //Arrange var Template = ModelCreation.TestTemplates(rand); var equipment = Template.Templates.EquipmentTemplates[0]; ObservableCollection <TECSubScope> expected = new ObservableCollection <TECSubScope>(); foreach (TECSubScope item in equipment.SubScope) { expected.Add(item); } TECSubScope edit = new TECSubScope(); //Act ChangeWatcher watcher = new ChangeWatcher(Template); DoStacker testStack = new DoStacker(watcher); equipment.SubScope.Add(edit); Assert.AreEqual(1, testStack.UndoCount(), "Not added to undo stack"); testStack.Undo(); //assert var actual = equipment.SubScope; Assert.AreEqual(expected.Count, actual.Count, "Not Undone"); }
public void SaveNew_Templates_Equipment() { //Arrange TECSubScope actualEquipSubScope = actualEquipment.SubScope.First(item => item.Devices.Count > 0 && item.Points.Count > 0); TECDevice actualChildDevice = actualEquipSubScope.Devices[0] as TECDevice; TECPoint actualEquipPoint = actualEquipSubScope.Points[0]; TECManufacturer actualChildMan = actualChildDevice.Manufacturer; TECSubScope expectedEquipSubScope = expectedEquipment.SubScope.First(item => item.Guid == actualEquipSubScope.Guid); TECDevice expectedChildDevice = expectedEquipSubScope.Devices[0] as TECDevice; TECPoint expectedEquipPoint = expectedEquipSubScope.Points[0]; TECManufacturer expectedChildMan = expectedChildDevice.Manufacturer; //Assert Assert.AreEqual(expectedEquipment.Name, actualEquipment.Name); Assert.AreEqual(expectedEquipment.Description, actualEquipment.Description); Assert.AreEqual(expectedEquipment.Tags[0].Label, actualEquipment.Tags[0].Label); Assert.AreEqual(expectedEquipSubScope.Name, actualEquipSubScope.Name); Assert.AreEqual(expectedEquipSubScope.Description, actualEquipSubScope.Description); Assert.AreEqual(expectedEquipSubScope.Tags[0].Label, actualEquipSubScope.Tags[0].Label); Assert.AreEqual(expectedChildDevice.Name, actualChildDevice.Name); Assert.AreEqual(expectedChildDevice.Description, actualChildDevice.Description); Assert.AreEqual(expectedChildDevice.Cost, actualChildDevice.Cost, DELTA); Assert.AreEqual(expectedEquipPoint.Label, actualEquipPoint.Label); Assert.AreEqual(expectedEquipPoint.Quantity, actualEquipPoint.Quantity); Assert.AreEqual(expectedEquipPoint.Type, actualEquipPoint.Type); Assert.AreEqual(expectedChildMan.Label, actualChildMan.Label); Assert.AreEqual(expectedChildMan.Multiplier, actualChildMan.Multiplier, DELTA); }
public void GetConnectablesTest() { TECSystem system = new TECSystem(); TECEquipment equipment = new TECEquipment(); system.Equipment.Add(equipment); TECSubScope first = new TECSubScope(); TECSubScope second = new TECSubScope(); equipment.SubScope.Add(first); equipment.SubScope.Add(second); TECProvidedController controller = new TECProvidedController(new TECControllerType(new TECManufacturer())); system.AddController(controller); var connectables = ConnectionHelper.GetConnectables(system, obj => true); Assert.IsTrue(connectables.Count == 3); Assert.IsTrue(connectables.Contains(first)); Assert.IsTrue(connectables.Contains(second)); Assert.IsTrue(connectables.Contains(controller)); connectables = ConnectionHelper.GetConnectables(system, obj => obj is TECSubScope); Assert.IsTrue(connectables.Count == 2); Assert.IsTrue(connectables.Contains(first)); Assert.IsTrue(connectables.Contains(second)); }
public void ConnectTest2() { TECConnectionType connectionType = new TECConnectionType(); TECDevice compatibleDevice = new TECDevice(new List <TECConnectionType> { connectionType }, new List <TECProtocol>(), new TECManufacturer()); TECSubScope subScope = new TECSubScope(); subScope.Devices.Add(compatibleDevice); TECPoint point = new TECPoint(); point.Type = IOType.AI; subScope.Points.Add(point); TECControllerType type = new TECControllerType(new TECManufacturer()); type.IO.Add(new TECIO(IOType.AI)); TECProvidedController controller = new TECProvidedController(type); TECHardwiredConnection connection = controller.Connect(subScope, subScope.HardwiredProtocol()) as TECHardwiredConnection; Assert.IsTrue(connection.Child == subScope); Assert.IsTrue(controller.ChildrenConnections.Contains(connection)); Assert.IsTrue((subScope as IConnectable).GetParentConnection() == connection); Assert.IsTrue(connection.Protocol is TECHardwiredProtocol); }
public void AddValve() { //Arrange TECValve valve = ModelCreation.TestValve(bid.Catalogs, rand); valve.AssignRandomScopeProperties(bid.Catalogs, rand); TECTypical typical = new TECTypical(); bid.Systems.Add(typical); TECEquipment typEquip = new TECEquipment(); typical.Equipment.Add(typEquip); TECSubScope typSS = new TECSubScope(); typEquip.SubScope.Add(typSS); typical.AddInstance(); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); //Act typSS.Devices.Add(valve); //Assert AssertMaterialVMMatchesCostBatch(matVM, valve.CostBatch); }
public void DiconnectTest1() { TECConnectionType connectionType = new TECConnectionType(); TECDevice compatibleDevice = new TECDevice(new List <TECConnectionType> { connectionType }, new List <TECProtocol>(), new TECManufacturer()); TECSubScope subScope = new TECSubScope(); subScope.Devices.Add(compatibleDevice); TECPoint point = new TECPoint(); point.Type = IOType.AI; subScope.Points.Add(point); TECControllerType type = new TECControllerType(new TECManufacturer()); type.IO.Add(new TECIO(IOType.AI)); TECProvidedController controller = new TECProvidedController(type); TECHardwiredConnection connection = controller.Connect(subScope, subScope.AvailableProtocols.First(x => x is TECHardwiredProtocol)) as TECHardwiredConnection; controller.Disconnect(subScope); Assert.IsFalse(controller.ChildrenConnections.Contains(connection)); Assert.IsNull((subScope as IConnectable).GetParentConnection()); }
public void RemoveDevice() { //Arrange TECTypical typical = new TECTypical(); bid.Systems.Add(typical); TECEquipment typEquip = new TECEquipment(); typical.Equipment.Add(typEquip); TECSubScope typSS = new TECSubScope(); typEquip.SubScope.Add(typSS); TECDevice device = bid.Catalogs.Devices[0]; device.AssignRandomScopeProperties(bid.Catalogs, rand); typSS.Devices.Add(device); typical.AddInstance(); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); CostBatch initial = MatVMToCostBatch(matVM); //Act typSS.Devices.Remove(device); //Assert AssertMaterialVMMatchesCostBatch(matVM, initial - device.CostBatch); }
public void UnionizeScopeCollectionTest() { TECSubScope scope1 = new TECSubScope(); TECSubScope scope2 = new TECSubScope(); TECSubScope scopeOverwrite = new TECSubScope(scope2.Guid); TECSubScope scope3 = new TECSubScope(); List <ITECScope> first = new List <ITECScope>() { scope1, scopeOverwrite }; List <ITECScope> second = new List <ITECScope>() { scope2, scope3 }; CommonUtilities.UnionizeScopeCollection(first, second); Assert.IsTrue(first.Contains(scope3)); Assert.IsTrue(first.Contains(scope2)); Assert.IsFalse(first.Contains(scopeOverwrite)); }
public void RemoveValve() { //Arrange bid.Catalogs.Add(ModelCreation.TestValve(bid.Catalogs, rand)); ChangeWatcher cw = new ChangeWatcher(bid); TECTypical typical = new TECTypical(); bid.Systems.Add(typical); TECEquipment typEquip = new TECEquipment(); typical.Equipment.Add(typEquip); TECSubScope typSS = new TECSubScope(); typEquip.SubScope.Add(typSS); TECValve valve = bid.Catalogs.Valves[0]; valve.AssignRandomScopeProperties(bid.Catalogs, rand); typSS.Devices.Add(valve); typical.AddInstance(); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); CostBatch initial = MatVMToCostBatch(matVM); //Act typSS.Devices.Remove(valve); //Assert AssertMaterialVMMatchesCostBatch(matVM, initial - valve.CostBatch); }
public void AddDeviceToConnectedHardwired() { TECControllerType type = new TECControllerType(new TECManufacturer()); type.IO.Add(new TECIO(IOType.AI)); TECProvidedController controller = new TECProvidedController(type); TECConnectionType connectionType = new TECConnectionType(); TECDevice device = new TECDevice(new List <TECConnectionType> { connectionType }, new List <TECProtocol>(), new TECManufacturer()); TECSubScope subScope = new TECSubScope(); subScope.AddDevice(device); controller.Connect(subScope, subScope.HardwiredProtocol()); TECDevice otherDevice = new TECDevice(new List <TECConnectionType> { connectionType }, new List <TECProtocol>(), new TECManufacturer()); subScope.AddDevice(otherDevice); Assert.IsFalse(subScope.Devices.Contains(otherDevice)); TECConnectionType otherConnectionType = new TECConnectionType(); TECDevice nextDevice = new TECDevice(new List <TECConnectionType> { otherConnectionType }, new List <TECProtocol>(), new TECManufacturer()); bool deviceAdded = subScope.AddDevice(nextDevice); Assert.IsFalse(deviceAdded); Assert.IsFalse(subScope.Devices.Contains(nextDevice)); }
public void RemoveSubScope() { //Arrange TECTypical typical = new TECTypical(); bid.Systems.Add(typical); TECEquipment typEquip = new TECEquipment(); typical.Equipment.Add(typEquip); TECSubScope subScope = ModelCreation.TestSubScope(bid.Catalogs, rand); subScope.AssignRandomScopeProperties(bid.Catalogs, rand); typEquip.SubScope.Add(subScope); typical.AddInstance(); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); CostBatch initial = MatVMToCostBatch(matVM); //Act typEquip.SubScope.Remove(subScope); //Assert AssertMaterialVMMatchesCostBatch(matVM, initial - subScope.CostBatch); }
public void RemovePointFromConnectedHardwired() { TECControllerType type = new TECControllerType(new TECManufacturer()); type.IO.Add(new TECIO(IOType.AI)); TECProvidedController controller = new TECProvidedController(type); TECConnectionType connectionType = new TECConnectionType(); TECDevice device = new TECDevice(new List <TECConnectionType> { connectionType }, new List <TECProtocol>(), new TECManufacturer()); TECSubScope subScope = new TECSubScope(); subScope.Devices.Add(device); TECPoint point = new TECPoint(); point.Type = IOType.AI; subScope.AddPoint(point); controller.Connect(subScope, subScope.HardwiredProtocol()); subScope.RemovePoint(point); Assert.IsFalse(subScope.Points.Contains(point)); Assert.IsTrue(controller.AvailableIO.IONumber(IOType.AI) == 1); }
public void CompatibleProtocolsTest() { TECProtocol firstProtocol = new TECProtocol(new List <TECConnectionType>()); TECProtocol secondProtocol = new TECProtocol(new List <TECConnectionType>()); TECProtocol thirdProtocol = new TECProtocol(new List <TECConnectionType>()); TECProtocol fourthProtocol = new TECProtocol(new List <TECConnectionType>()); TECDevice compatibleDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>() { secondProtocol, firstProtocol }, new TECManufacturer()); TECSubScope subScope = new TECSubScope(); subScope.Devices.Add(compatibleDevice); TECControllerType type = new TECControllerType(new TECManufacturer()); type.IO.Add(new TECIO(firstProtocol)); type.IO.Add(new TECIO(secondProtocol)); type.IO.Add(new TECIO(thirdProtocol)); TECProvidedController controller = new TECProvidedController(type); var compatible = controller.CompatibleProtocols(subScope); Assert.AreEqual(2, compatible.Count); Assert.IsTrue(compatible.Contains(firstProtocol) && compatible.Contains(secondProtocol)); }
public void AvailableProtocols2() { TECSubScope ss = new TECSubScope(); Assert.IsFalse(ss.AvailableProtocols.Any(prot => { return(prot is TECHardwiredProtocol); })); Assert.AreEqual(0, ss.AvailableProtocols.Count); }
public void CompatibleProtocolsTest2() { TECConnectionType connectionType = new TECConnectionType(); TECDevice compatibleDevice = new TECDevice(new List <TECConnectionType> { connectionType }, new List <TECProtocol>(), new TECManufacturer()); TECSubScope subScope = new TECSubScope(); subScope.Devices.Add(compatibleDevice); TECPoint point = new TECPoint(); point.Type = IOType.AI; subScope.Points.Add(point); TECControllerType type = new TECControllerType(new TECManufacturer()); type.IO.Add(new TECIO(IOType.AI)); TECProvidedController controller = new TECProvidedController(type); var compatible = controller.CompatibleProtocols(subScope); Assert.AreEqual(1, compatible.Count); Assert.IsTrue(compatible.Any(x => x is TECHardwiredProtocol)); }
public AddSubScopeVM(Action <TECSubScope> addMethod, TECScopeManager scopeManager) : base(scopeManager) { add = addMethod; toAdd = new TECSubScope(); setup(); PropertiesVM.DisplayReferenceProperty = false; }
public void ConnectTest1() { TECProtocol firstProtocol = new TECProtocol(new List <TECConnectionType>()); TECProtocol secondProtocol = new TECProtocol(new List <TECConnectionType>()); TECProtocol thirdProtocol = new TECProtocol(new List <TECConnectionType>()); TECProtocol fourthProtocol = new TECProtocol(new List <TECConnectionType>()); TECDevice compatibleDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>() { fourthProtocol }, new TECManufacturer()); TECSubScope subScope = new TECSubScope(); subScope.Devices.Add(compatibleDevice); TECControllerType type = new TECControllerType(new TECManufacturer()); type.IO.Add(new TECIO(firstProtocol)); type.IO.Add(new TECIO(secondProtocol)); type.IO.Add(new TECIO(thirdProtocol)); TECProvidedController controller = new TECProvidedController(type); var connection = controller.Connect(subScope, firstProtocol); Assert.IsNull(connection); }
public void SaveAs_Bid_SubScope() { //Arrange TECBid bid = new TECBid(); bid.Catalogs = ModelCreation.TestCatalogs(rand, 5); TECTypical system = new TECTypical(); TECEquipment expectedEquipment = new TECEquipment(); TECSubScope expectedSubScope = ModelCreation.TestSubScope(bid.Catalogs, rand); expectedEquipment.SubScope.Add(expectedSubScope); system.Equipment.Add(expectedEquipment); bid.Systems.Add(system); path = Path.GetTempFileName(); //Act DatabaseManager <TECBid> manager = new DatabaseManager <TECBid>(path); manager.New(bid); TECBid loadedBid = manager.Load() as TECBid; TECSubScope actualSubScope = loadedBid.FindChild(expectedSubScope.Guid) as TECSubScope; //Assert Assert.AreEqual(expectedSubScope.Name, actualSubScope.Name); Assert.AreEqual(expectedSubScope.Description, actualSubScope.Description); Assert.AreEqual(expectedSubScope.Interlocks.Count, actualSubScope.Interlocks.Count); Assert.AreEqual(expectedSubScope.ScopeBranches.Count, actualSubScope.ScopeBranches.Count); Assert.IsTrue(compareCosts(expectedSubScope.CostBatch, actualSubScope.CostBatch)); }
public void TemplatedSubScopeRemovedFromTemplateEquipment() { //Arrange TECTemplates templates = new TECTemplates(); TemplateSynchronizer <TECEquipment> equipSynchronizer = templates.EquipmentSynchronizer; TemplateSynchronizer <TECSubScope> ssSynchronizer = templates.SubScopeSynchronizer; TECEquipment templateEquip = new TECEquipment(); templates.Templates.EquipmentTemplates.Add(templateEquip); TECSubScope templateSS = new TECSubScope(); templates.Templates.SubScopeTemplates.Add(templateSS); TECSubScope instanceSS = ssSynchronizer.NewItem(templateSS); templateEquip.SubScope.Add(instanceSS); TECEquipment instanceEquip = equipSynchronizer.NewItem(templateEquip); templates.Templates.EquipmentTemplates.Add(instanceEquip); //Act templateEquip.SubScope.Remove(instanceSS); //Assert Assert.IsTrue(instanceEquip.SubScope.Count == 0, "SubScope not removed properly from equipment reference."); Assert.IsFalse(ssSynchronizer.Contains(instanceSS), "Reference SubScope not removed properly from synchronizer."); Assert.IsTrue(ssSynchronizer.Contains(templateSS), "Template SubScope was removed from synchronizer when it shouldn't have been."); }