public void AddPointToTypicalSubScope() { TECBid bid = ModelCreation.TestBid(rand); TECTypical typical = null; TECSubScope typSS = null; foreach (TECTypical typ in bid.Systems) { if (typ.Instances.Count > 0) { foreach (TECEquipment equip in typ.Equipment) { if (equip.SubScope.Count > 0) { typical = typ; typSS = equip.SubScope[0]; } } } } Assert.IsNotNull(typical); Assert.IsNotNull(typSS); TECPoint newPoint = ModelCreation.TestPoint(rand, IOType.AI); newPoint.Label = "New Point"; typSS.Points.Add(newPoint); List <TECSubScope> instanceSubScope = typical.GetInstancesFromTypical(typSS); List <TECPoint> instancePoints = typical.GetInstancesFromTypical(newPoint); foreach (TECSubScope instanceSS in instanceSubScope) { TECPoint newInstancePoint = null; foreach (TECPoint point in instanceSS.Points) { if (point.Label == newPoint.Label) { newInstancePoint = point; } } Assert.IsNotNull(newInstancePoint); Assert.IsTrue(instancePoints.Contains(newInstancePoint)); } }
public void GetInstancesFromTypicalTest() { TECSubScope subScope = new TECSubScope(); TECEquipment equipment = new TECEquipment(); TECTypical typical = new TECTypical(); equipment.SubScope.Add(subScope); typical.Equipment.Add(equipment); typical.AddInstance(); typical.AddInstance(); Assert.AreEqual(2, typical.GetInstancesFromTypical(subScope).Count); Assert.AreEqual(2, typical.GetInstancesFromTypical(equipment).Count); }
public void RemoveInstanceWithGlobalConnectionToController() { TECBid bid = new TECBid(); bid.Catalogs = ModelCreation.TestCatalogs(rand); TECControllerType type = bid.Catalogs.ControllerTypes.RandomElement(rand); TECController controller = new TECProvidedController(type); bid.AddController(controller); TECTypical typical = new TECTypical(); TECController typicalController = new TECProvidedController(type); typical.AddController(typicalController); bid.Systems.Add(typical); TECSystem system = typical.AddInstance(); TECController instanceController = typical.GetInstancesFromTypical(typicalController).First(); Assert.IsTrue(controller.CanConnect(instanceController)); IControllerConnection connection = controller.Connect(instanceController, instanceController.AvailableProtocols.First()); Assert.IsTrue(connection is TECNetworkConnection); typical.Instances.Remove(system); Assert.IsTrue((connection as TECNetworkConnection).Children.Count == 0); }
public void RemoveInstanceWithGlobalConnectionToSubScope() { TECBid bid = new TECBid(); bid.Catalogs = ModelCreation.TestCatalogs(rand); TECController controller = ModelCreation.TestProvidedController(bid.Catalogs, rand); bid.AddController(controller); TECTypical typical = new TECTypical(); TECEquipment equipment = new TECEquipment(); TECSubScope subScope = new TECSubScope(); TECDevice device = null; foreach (TECDevice item in bid.Catalogs.Devices) { foreach (TECProtocol prot in item.PossibleProtocols) { if (controller.AvailableProtocols.Contains(prot)) { device = item; break; } } if (device != null) { break; } } if (device == null) { throw new NullReferenceException("Device is Null"); } subScope.Devices.Add(device); equipment.SubScope.Add(subScope); typical.Equipment.Add(equipment); bid.Systems.Add(typical); TECSystem system = typical.AddInstance(); TECSubScope instanceSubScope = typical.GetInstancesFromTypical(subScope).First(x => x.AvailableProtocols.Any(y => y is TECProtocol && controller.AvailableProtocols.Contains(y))); IControllerConnection connection = controller.Connect(instanceSubScope, instanceSubScope.AvailableProtocols.First(y => controller.AvailableProtocols.Contains(y))); Assert.IsTrue(connection is TECNetworkConnection); typical.Instances.Remove(system); Assert.IsTrue((connection as TECNetworkConnection).Children.Count == 0); }