public void DisconnectTest()
        {
            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.Disconnect(subScope);

            Assert.IsFalse(connection.Children.Contains(subScope));
            Assert.IsTrue(controller.ChildrenConnections.Contains(connection));
            Assert.IsNull((subScope as IConnectable).GetParentConnection());
        }
        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());
        }
예제 #3
0
        public void RemoveConnection()
        {
            //Arrange
            TECController controller = new TECProvidedController(bid.Catalogs.ControllerTypes[0]);

            bid.AddController(controller);

            TECTypical typical = new TECTypical();

            bid.Systems.Add(typical);

            TECEquipment typEquip = new TECEquipment();

            typical.Equipment.Add(typEquip);

            TECSubScope ss = new TECSubScope();

            ss.Devices.Add(bid.Catalogs.Devices[0]);
            typEquip.SubScope.Add(ss);


            TECSystem instance = typical.AddInstance();

            TECSubScope instanceSubScope = instance.GetAllSubScope().First(sub => sub.AvailableProtocols.Any(prot => prot is TECHardwiredProtocol));
            IConnection connection       = controller.Connect(instanceSubScope, (instanceSubScope as IConnectable).AvailableProtocols.First(x => x is TECHardwiredProtocol));

            connection.Length        = 50;
            connection.ConduitLength = 50;
            connection.ConduitType   = bid.Catalogs.ConduitTypes[0];

            MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw);

            CostBatch expected = MatVMToCostBatch(matVM) - connection.CostBatch;

            //Act
            controller.Disconnect(instanceSubScope);

            //Assert
            AssertMaterialVMMatchesCostBatch(matVM, expected);
        }