public void ConnectTest4() { 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 subScope1 = new TECSubScope(); subScope1.Devices.Add(compatibleDevice); TECSubScope subScope2 = new TECSubScope(); subScope2.Devices.Add(compatibleDevice); TECSubScope subScope3 = new TECSubScope(); subScope3.Devices.Add(compatibleDevice); TECSubScope subScope4 = new TECSubScope(); subScope4.Devices.Add(compatibleDevice); List <IConnectable> connectables = new List <IConnectable> { subScope1, subScope2, subScope3, subScope4 }; TECControllerType type = new TECControllerType(new TECManufacturer()); type.IO.Add(new TECIO(firstProtocol)); TECProvidedController controller = new TECProvidedController(type); foreach (var subScope in connectables) { TECNetworkConnection connection = controller.Connect(subScope, firstProtocol) as TECNetworkConnection; Assert.IsTrue(connection.Children.Contains(subScope)); Assert.IsTrue(controller.ChildrenConnections.Contains(connection)); Assert.IsTrue((subScope as IConnectable).GetParentConnection() == connection); Assert.IsTrue(connection.Protocol == firstProtocol); } }
public void CanChangeTypeTest() { 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()); otherCType.IO.Add(new TECIO(protocol)); otherCType.IO.Add(new TECIO(IOType.AI)); 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.IsTrue(controller.CanChangeType(otherCType)); }
public void AddConnection() { //Arrange TECControllerType controllerType = new TECControllerType(bid.Catalogs.Manufacturers[0]); bid.Catalogs.Add(controllerType); TECTypical typical = new TECTypical(); bid.Systems.Add(typical); TECController controller = new TECProvidedController(controllerType); typical.AddController(controller); TECEquipment typEquip = new TECEquipment(); typical.Equipment.Add(typEquip); TECSubScope typSS = new TECSubScope(); typEquip.SubScope.Add(typSS); ObservableCollection <TECConnectionType> connectionTypes = new ObservableCollection <TECConnectionType>(); connectionTypes.Add(bid.Catalogs.ConnectionTypes[0]); TECDevice dev = new TECDevice(connectionTypes, new List <TECProtocol>(), bid.Catalogs.Manufacturers[0]); bid.Catalogs.Add(dev); typSS.Devices.Add(dev); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); //Act IControllerConnection connection = controller.Connect(typSS, (typSS as IConnectable).AvailableProtocols.First()); connection.Length = 50; connection.ConduitLength = 50; connection.ConduitType = bid.Catalogs.ConduitTypes[0]; TECSystem instance = typical.AddInstance(); TECSubScope instanceSubScope = instance.GetAllSubScope()[0]; //Assert AssertMaterialVMMatchesCostBatch(matVM, connection.CostBatch); }
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); }
public void RemoveDeviceFromConnectedHardwired() { TECControllerType type = new TECControllerType(new TECManufacturer()); 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); TECHardwiredConnection connection = controller.Connect(subScope, subScope.HardwiredProtocol()) as TECHardwiredConnection; subScope.RemoveDevice(device); Assert.IsNull((subScope as IConnectable).GetParentConnection()); Assert.IsFalse(controller.ChildrenConnections.Contains(connection)); }
public void AddTypicalSubScopeConnectionToController() { //Arrange TECControllerType controllerType = new TECControllerType(bid.Catalogs.Manufacturers[0]); bid.Catalogs.Add(controllerType); TECController controller = new TECProvidedController(controllerType); bid.AddController(controller); TECTypical typical = new TECTypical(); TECEquipment equip = new TECEquipment(); typical.Equipment.Add(equip); TECSubScope ss = new TECSubScope(); equip.SubScope.Add(ss); TECDevice dev = bid.Catalogs.Devices[0]; ss.Devices.Add(dev); bid.Systems.Add(typical); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); //Act IControllerConnection connection = controller.Connect(ss, (ss as IConnectable).AvailableProtocols.First(y => y is TECHardwiredProtocol)); connection.Length = 100; connection.ConduitLength = 100; connection.ConduitType = bid.Catalogs.ConduitTypes[0]; AssertMaterialVMMatchesCostBatch(matVM, connection.CostBatch); }
public void RemoveDeviceFromConnectedNetwork() { 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); IControllerConnection connection = controller.Connect(subScope, protocol); subScope.RemoveDevice(device); Assert.IsNull((subScope as IConnectable).GetParentConnection()); Assert.IsTrue(controller.ChildrenConnections.Contains(connection)); }
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()); type.IO.Add(new TECIO(IOType.AO)); TECProvidedController controller = new TECProvidedController(type); TECHardwiredConnection connection = controller.Connect(subScope, subScope.AvailableProtocols.First(x => x is TECHardwiredProtocol)) as TECHardwiredConnection; Assert.IsNull(connection); }
public void RemovePointFromConnectedNetwork() { 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); TECPoint point = new TECPoint(); point.Type = IOType.AI; subScope.AddPoint(point); TECPoint otherPoint = new TECPoint(); otherPoint.Type = IOType.AI; controller.Connect(subScope, protocol); subScope.RemovePoint(point); Assert.IsFalse(subScope.Points.Contains(point)); Assert.IsTrue(controller.AvailableIO.IONumber(IOType.AI) == 1); subScope.RemovePoint(otherPoint); Assert.IsFalse(subScope.Points.Contains(otherPoint)); Assert.IsTrue(controller.AvailableIO.IONumber(IOType.AI) == 1); }
private void addTypicalExecute() { TECTypical typical = new TECTypical(); typical.Name = "test"; TECEquipment equipment = new TECEquipment(); equipment.Name = "test equipment"; TECSubScope ss = new TECSubScope(); ss.Name = "Test Subscope"; ss.AddDevice(bid.Catalogs.Devices[0]); TECPoint point = new TECPoint(); point.Type = IOType.AI; point.Quantity = 1; ss.AddPoint(point); equipment.SubScope.Add(ss); typical.Equipment.Add(equipment); TECSubScope connected = new TECSubScope(); connected.Name = "Connected"; connected.AddDevice(bid.Catalogs.Devices[0]); TECPoint point2 = new TECPoint(); point2.Type = IOType.AI; point2.Quantity = 1; connected.AddPoint(point2); equipment.SubScope.Add(connected); TECSubScope toConnect = new TECSubScope(); toConnect.Name = "To Connect"; toConnect.AddDevice(bid.Catalogs.Devices[0]); TECPoint point3 = new TECPoint(); point3.Type = IOType.AI; point3.Quantity = 1; toConnect.AddPoint(point3); equipment.SubScope.Add(toConnect); TECControllerType controllerType = new TECControllerType(new TECManufacturer()); controllerType.IOModules.Add(bid.Catalogs.IOModules[0]); TECIO io = new TECIO(IOType.AI); io.Quantity = 10; controllerType.IO.Add(io); bid.Catalogs.IOModules[0].IO.Add(io); controllerType.Name = "Test Type"; TECProvidedController controller = new TECProvidedController(controllerType); controller.IOModules.Add(bid.Catalogs.IOModules[0]); controller.Name = "Test Controller"; typical.AddController(controller); TECProvidedController otherController = new TECProvidedController(controllerType); otherController.Name = "Other Controller"; typical.AddController(otherController); IControllerConnection connection = controller.Connect(connected, (connected as IConnectable).AvailableProtocols.First()); connection.Length = 10; connection.ConduitLength = 20; connection.ConduitType = bid.Catalogs.ConduitTypes[1]; TECPanelType panelType = new TECPanelType(new TECManufacturer()); panelType.Name = "test type"; TECPanel panel = new TECPanel(panelType); panel.Name = "Test Panel"; typical.Panels.Add(panel); TECMisc misc = new TECMisc(CostType.TEC); misc.Name = "test Misc"; typical.MiscCosts.Add(misc); bid.Systems.Add(typical); typical.AddInstance(); }
public void RemoveAllChildConnectionsTest() { TECConnectionType connectionType = new TECConnectionType(); 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> { connectionType }, 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; TECDevice compatibleHardDevice = new TECDevice(new List <TECConnectionType> { connectionType }, new List <TECProtocol>(), new TECManufacturer()); TECSubScope hardSubScope = new TECSubScope(); hardSubScope.Devices.Add(compatibleDevice); TECPoint point = new TECPoint(); point.Type = IOType.AI; hardSubScope.Points.Add(point); type.IO.Add(new TECIO(IOType.AI)); TECHardwiredConnection hardConnection = controller.Connect(hardSubScope, hardSubScope.AvailableProtocols.First(x => x is TECHardwiredProtocol)) as TECHardwiredConnection; TECController parentController = new TECProvidedController(type); parentController.Connect(controller, secondProtocol); Assert.IsNotNull(controller.ParentConnection); controller.RemoveAllChildConnections(); Assert.IsFalse(connection.Children.Contains(subScope)); Assert.IsFalse(controller.ChildrenConnections.Contains(connection)); Assert.IsNull((subScope as IConnectable).GetParentConnection()); Assert.IsFalse(controller.ChildrenConnections.Contains(hardConnection)); Assert.IsNull((hardSubScope as IConnectable).GetParentConnection()); Assert.IsNotNull(controller.ParentConnection); }
public static TECBid CreateTestBid() { TECBid bid = new TECBid(); //Bid Info bid.Name = "Bid Name"; bid.BidNumber = "1701-117"; bid.DueDate = DateTime.Now; bid.Salesperson = "Mrs. Test"; bid.Estimator = "Mr. Test"; //Bid Objects bid.ExtraLabor = CreateTestExtraLabor(bid.Guid); bid.Parameters = CreateTestParameters(bid.Guid); bid.Catalogs = CreateTestCatalogs(); //Internal Notes TECInternalNote internalNote = new TECInternalNote(); internalNote.Label = "Test internal"; internalNote.Body = "Test body"; bid.InternalNotes.Add(internalNote); //Locations var cellar = new TECLocation(); cellar.Name = "Cellar"; cellar.Label = "C"; var location1 = new TECLocation(); location1.Name = "1st Floor"; location1.Label = "1"; var location2 = new TECLocation(); location2.Name = "2nd Floor"; location2.Label = "2"; var location3 = new TECLocation(); location3.Name = "3rd Floor"; location3.Label = "3"; bid.Locations.Add(cellar); bid.Locations.Add(location1); bid.Locations.Add(location2); bid.Locations.Add(location3); //Scope Branches var branch1 = new TECScopeBranch(false); branch1.Label = "Branch 1"; var branch2 = new TECScopeBranch(false); branch2.Label = "Branch 2"; var branch3 = new TECScopeBranch(false); branch3.Label = "Branch 3"; bid.ScopeTree.Add(branch1); branch1.Branches.Add(branch2); branch2.Branches.Add(branch3); //Notes var note1 = new TECLabeled(); note1.Label = "Note 1"; bid.Notes.Add(note1); //Exclusions var exclusion1 = new TECLabeled(); exclusion1.Label = "Exclusion 1"; bid.Exclusions.Add(exclusion1); //Controller TECController expectedController = new TECProvidedController(Guid.NewGuid(), bid.Catalogs.ControllerTypes[0], false); expectedController.Name = "Test Controller"; expectedController.Description = "Test description"; bid.AddController(expectedController); //Misc Cost TECMisc cost = new TECMisc(CostType.TEC, false); cost.Name = "Test Cost"; cost.Cost = 69.69; cost.Quantity = 69; bid.MiscCosts.Add(cost); //Misc wiring TECMisc wiring = new TECMisc(CostType.Electrical, false); wiring.Name = "Test Wiring"; wiring.Cost = 69.69; wiring.Quantity = 69; bid.MiscCosts.Add(wiring); //Panels TECPanel panel = new TECPanel(bid.Catalogs.PanelTypes[0], false); panel.Name = "Test Panel"; panel.Controllers.Add(expectedController); panel.AssociatedCosts.Add(bid.Catalogs.AssociatedCosts[0]); panel.AssociatedCosts.Add(bid.Catalogs.AssociatedCosts[0]); bid.Panels.Add(panel); //Systems var system1 = CreateTestTypical(bid.Catalogs); system1.Name = "System 1"; system1.Description = "Locations all the way"; system1.Location = cellar; var system2 = CreateTestTypical(bid.Catalogs); system2.Name = "System 2"; system2.Description = "Description 2"; var system3 = CreateTestTypical(bid.Catalogs); system3.Name = "System 3"; system3.Description = ""; bid.Systems.Add(system1); bid.Systems.Add(system2); bid.Systems.Add(system3); system1.AddInstance(bid); system2.AddInstance(bid); system3.AddInstance(bid); system1.AddInstance(bid); system2.AddInstance(bid); system3.AddInstance(bid); //Equipment var equipment1 = new TECEquipment(true); equipment1.Name = "Equipment 1"; equipment1.Description = "Description 1"; var equipment2 = new TECEquipment(true); equipment2.Name = "Equipment 2"; equipment2.Description = "Description 2"; system1.Equipment.Add(equipment1); system3.Equipment.Add(equipment2); //SubScope var subScope1 = new TECSubScope(true); subScope1.Name = "SubScope 1"; subScope1.Description = "Description 1"; subScope1.AssociatedCosts.Add(bid.Catalogs.AssociatedCosts[0]); subScope1.AssociatedCosts.Add(bid.Catalogs.AssociatedCosts[0]); subScope1.AssociatedCosts.Add(bid.Catalogs.AssociatedCosts[0]); var subScope2 = new TECSubScope(true); subScope2.Name = "Empty SubScope"; subScope2.Description = "Description 2"; subScope2.AssociatedCosts.Add(bid.Catalogs.AssociatedCosts[0]); equipment1.SubScope.Add(subScope1); equipment2.SubScope.Add(subScope2); //Points var point1 = new TECPoint(true); point1.Label = "Point 1"; point1.Type = IOType.AI; point1.Quantity = 2; subScope1.Points.Add(point1); var point2 = new TECPoint(true); point2.Label = "Point 2"; point2.Type = IOType.AI; point2.Quantity = 2; subScope2.Points.Add(point2); //Devices subScope1.Devices.Add(bid.Catalogs.Devices[0]); //Connections TECSubScope instanceSubScope = system1.GetInstancesFromTypical(subScope1)[0]; IControllerConnection testConnection = expectedController.Connect(instanceSubScope, (instanceSubScope as IConnectable).AvailableProtocols.First()); testConnection.ConduitType = bid.Catalogs.ConduitTypes[0]; testConnection.Length = 42; AssignAllSecondaryProperties(bid); TECTypical noLocation = new TECTypical(); noLocation.Name = "No Location"; noLocation.Equipment.Add(new TECEquipment(true)); noLocation.Equipment[0].SubScope.Add(new TECSubScope(true)); bid.Systems.Add(noLocation); return(bid); }
public void ConnectTest6() { 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>()); TECConnectionType connectionType = new TECConnectionType(); TECDevice hardDevice = new TECDevice(new List <TECConnectionType> { connectionType }, new List <TECProtocol>(), new TECManufacturer()); TECSubScope hSubScope1 = new TECSubScope(); hSubScope1.Devices.Add(hardDevice); hSubScope1.Points.Add(new TECPoint { Type = IOType.AI }); TECSubScope hSubScope2 = new TECSubScope(); hSubScope2.Devices.Add(hardDevice); hSubScope2.Points.Add(new TECPoint { Type = IOType.AI }); TECSubScope hSubScope3 = new TECSubScope(); hSubScope3.Devices.Add(hardDevice); hSubScope3.Points.Add(new TECPoint { Type = IOType.AI }); TECSubScope hSubScope4 = new TECSubScope(); hSubScope4.Devices.Add(hardDevice); hSubScope4.Points.Add(new TECPoint { Type = IOType.AI }); TECSubScope hSubScope5 = new TECSubScope(); hSubScope5.Devices.Add(hardDevice); hSubScope5.Points.Add(new TECPoint { Type = IOType.AI }); TECDevice compatibleDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>() { secondProtocol, firstProtocol, fourthProtocol }, new TECManufacturer()); TECSubScope subScope1 = new TECSubScope(); subScope1.Devices.Add(compatibleDevice); TECSubScope subScope2 = new TECSubScope(); subScope2.Devices.Add(compatibleDevice); TECSubScope subScope3 = new TECSubScope(); subScope3.Devices.Add(compatibleDevice); TECSubScope subScope4 = new TECSubScope(); subScope4.Devices.Add(compatibleDevice); List <IConnectable> connectables = new List <IConnectable> { subScope1, subScope2, subScope3, subScope4, hSubScope1, hSubScope2, hSubScope3, hSubScope4, hSubScope5 }; TECControllerType type = new TECControllerType(new TECManufacturer()); TECIOModule module = new TECIOModule(new TECManufacturer()); module.IO.Add(new TECIO(firstProtocol)); TECIOModule hModule = new TECIOModule(new TECManufacturer()); hModule.IO.Add(new TECIO(IOType.AI) { Quantity = 2 }); type.IOModules.Add(module); type.IOModules.Add(hModule); type.IOModules.Add(hModule); type.IOModules.Add(hModule); TECProvidedController controller = new TECProvidedController(type); foreach (var subScope in connectables) { IProtocol protocol = subScope.HardwiredProtocol() as IProtocol ?? firstProtocol; IControllerConnection connection = controller.Connect(subScope, protocol); bool containsChild = connection is TECNetworkConnection netConnect? netConnect.Children.Contains(subScope) : (connection as TECHardwiredConnection).Child == subScope; Assert.IsTrue(containsChild); Assert.IsTrue(controller.ChildrenConnections.Contains(connection)); Assert.IsTrue((subScope as IConnectable).GetParentConnection() == connection); Assert.AreEqual(connection.Protocol, protocol); } }