public void AddRemoveSystemInstanceWithBidConnection() { var bid = new TECBid(); bid.Catalogs = ModelCreation.TestCatalogs(rand); var bidController = new TECProvidedController(bid.Catalogs.ControllerTypes.RandomElement(rand)); bid.AddController(bidController); var system = new TECTypical(); var equipment = new TECEquipment(); var subScope = new TECSubScope(); TECDevice dev = bid.Catalogs.Devices.First(x => x.HardwiredConnectionTypes.Count > 0); subScope.Devices.Add(dev); TECHardwiredProtocol hardProt = subScope.AvailableProtocols.First(x => x is TECHardwiredProtocol) as TECHardwiredProtocol; system.Equipment.Add(equipment); equipment.SubScope.Add(subScope); var instance = system.AddInstance(); var instanceSubScope = instance.GetAllSubScope().First(); bidController.Connect(instanceSubScope, hardProt); Assert.AreEqual(1, bidController.ChildrenConnections.Count, "Connection not added"); system.Instances.Remove(instance); Assert.AreEqual(0, bidController.ChildrenConnections.Count, "Connection not removed"); }
public void GetHashCodeTest() { TECConnectionType type1 = new TECConnectionType(); TECConnectionType type2 = new TECConnectionType(); TECHardwiredProtocol first = new TECHardwiredProtocol(new List <TECConnectionType>() { type1, type2 }); TECHardwiredProtocol second = new TECHardwiredProtocol(new List <TECConnectionType>() { type1, type2 }); Assert.AreEqual(first.GetHashCode(), second.GetHashCode()); }
public void EqualsTest() { TECConnectionType type1 = new TECConnectionType(); TECConnectionType type2 = new TECConnectionType(); TECHardwiredProtocol first = new TECHardwiredProtocol(new List <TECConnectionType>() { type1, type2 }); TECHardwiredProtocol second = new TECHardwiredProtocol(new List <TECConnectionType>() { type1, type2 }); Assert.AreEqual(first, second); }
public void AvailableProtocols() { 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> { type1 }, 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); TECHardwiredProtocol expectedHardProt = new TECHardwiredProtocol(new List <TECConnectionType> { type1, type2 }); Assert.IsTrue(ss.AvailableProtocols.Contains(expectedHardProt)); Assert.IsTrue(ss.AvailableProtocols.Contains(prot1)); Assert.IsFalse(ss.AvailableProtocols.Contains(prot2)); Assert.IsFalse(ss.AvailableProtocols.Contains(prot3)); Assert.AreEqual(2, ss.AvailableProtocols.Count); }