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 SaveAs_Bid_SystemInstances() { TECBid saveBid = new TECBid(); saveBid.Catalogs = ModelCreation.TestCatalogs(rand, 5); TECTypical system = ModelCreation.TestTypical(saveBid.Catalogs, rand); saveBid.Systems.Add(system); //Act path = Path.GetTempFileName(); DatabaseManager <TECBid> manager = new DatabaseManager <TECBid>(path); manager.New(saveBid); TECBid loadedBid = manager.Load() as TECBid; TECTypical loadedSystem = loadedBid.Systems[0]; Assert.AreEqual(system.Instances.Count, loadedSystem.Instances.Count); foreach (TECSystem loadedInstance in loadedSystem.Instances) { foreach (TECSystem saveInstance in system.Instances) { if (loadedInstance.Guid == saveInstance.Guid) { Assert.AreEqual(loadedInstance.Equipment.Count, saveInstance.Equipment.Count); Assert.AreEqual(loadedInstance.Panels.Count, saveInstance.Panels.Count); Assert.AreEqual(loadedInstance.Controllers.Count, saveInstance.Controllers.Count); Assert.IsTrue(compareCosts(loadedInstance.CostBatch, saveInstance.CostBatch)); } } } }
public static TECTypical CreateTestTypical(TECCatalogs catalogs) { TECTypical outScope = new TECTypical(); outScope.Tags.Add(catalogs.Tags[0]); outScope.ProposeEquipment = true; var panel = CreateTestPanel(true, catalogs); outScope.Panels.Add(panel); var equipment = CreateTestEquipment(true, catalogs); outScope.Equipment.Add(equipment); var controller = CreateTestController(true, catalogs); outScope.AddController(controller); ConnectEquipmentToController(equipment, controller); panel.Controllers.Add(controller); var scopeBranch = new TECScopeBranch(true); outScope.ScopeBranches.Add(scopeBranch); var tecMisc = CreateTestMisc(CostType.TEC, true); var elecMisc = CreateTestMisc(CostType.Electrical, true); outScope.MiscCosts.Add(tecMisc); outScope.MiscCosts.Add(elecMisc); outScope.AssociatedCosts.Add(catalogs.AssociatedCosts[0]); return(outScope); }
public void AddElectricalCostToSystem() { //Arrange TECAssociatedCost cost = null; foreach (TECAssociatedCost assoc in bid.Catalogs.AssociatedCosts) { if (assoc.Type == CostType.Electrical) { cost = assoc; break; } } if (cost == null) { Assert.Fail("No electrical cost in catalogs."); } TECTypical typical = new TECTypical(); bid.Systems.Add(typical); TECSystem instance = typical.AddInstance(); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); //Act typical.AssociatedCosts.Add(cost); //Assert AssertMaterialVMMatchesCostBatch(matVM, cost.CostBatch); }
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 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 EditInstances() { TECBid bid = new TECBid(); int qty = 3; bid.Catalogs = ModelCreation.TestCatalogs(rand); TECTypical system = ModelCreation.TestTypical(bid.Catalogs, rand); bid.Systems.Add(system); for (int x = 0; x < qty; x++) { system.AddInstance(); } system.Equipment.Add(ModelCreation.TestEquipment(bid.Catalogs, rand)); system.AddController(ModelCreation.TestProvidedController(bid.Catalogs, rand)); system.Panels.Add(ModelCreation.TestPanel(bid.Catalogs, rand)); foreach (TECSystem instance in system.Instances) { Assert.AreEqual(system.Equipment.Count, instance.Equipment.Count); Assert.AreEqual(system.Controllers.Count, instance.Controllers.Count); Assert.AreEqual(system.Panels.Count, instance.Panels.Count); } }
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 UpdateInstanceConnectionsTest() { Random rand = new Random(); TECCatalogs catalogs = ModelCreation.TestCatalogs(rand); TECTypical typical = ModelCreation.TestTypical(catalogs, rand); typical.AddInstance(); foreach (var controller in typical.Controllers) { foreach (var connection in controller.ChildrenConnections) { connection.Length = 324; } } typical.UpdateInstanceConnections(); foreach (var instance in typical.Instances) { foreach (var controller in instance.Controllers) { foreach (var connection in controller.ChildrenConnections) { Assert.AreEqual(324, connection.Length); } } } }
public void AddTECCostToSystem() { //Arrange TECAssociatedCost cost = null; int x = 0; while (cost == null) { TECAssociatedCost randomCost = bid.Catalogs.AssociatedCosts[x]; if (randomCost.Type == CostType.TEC) { cost = randomCost; } x++; } TECTypical typical = new TECTypical(); bid.Systems.Add(typical); typical.AddInstance(); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); //Act typical.AssociatedCosts.Add(cost); //Assert AssertMaterialVMMatchesCostBatch(matVM, cost.CostBatch); }
private void addExecute() { for (int x = 0; x < Quantity; x++) { if (parent is TECBid bid) { TECTypical typical = new TECTypical(toAdd, bid); bid.Systems.Add(typical); typical.AddInstance(); Added?.Invoke(typical); } else if (parent is TECTemplates) { TECSystem system = null; if (underlyingTemplate != null) { system = new TECSystem(underlyingTemplate, synchronizers: new Tuple <TemplateSynchronizer <TECEquipment>, TemplateSynchronizer <TECSubScope> >(templates.EquipmentSynchronizer, templates.SubScopeSynchronizer)); system.CopyPropertiesFromScope(ToAdd); } else { system = ToAdd; } parent.Templates.SystemTemplates.Add(system); Added?.Invoke(system); } } }
public void RemoveTECCost() { //Arrange TECAssociatedCost cost = null; int x = 0; while (cost == null) { TECAssociatedCost randomCost = bid.Catalogs.AssociatedCosts[x]; if (randomCost.Type == CostType.TEC) { cost = randomCost; } x++; } TECTypical system = new TECTypical(); bid.Systems.Add(system); system.AddInstance(); system.AssociatedCosts.Add(cost); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); CostBatch initial = MatVMToCostBatch(matVM); //Act system.AssociatedCosts.Remove(cost); //Assert AssertMaterialVMMatchesCostBatch(matVM, initial - cost.CostBatch); }
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 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 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 static TECTypical TestTypical(TECCatalogs catalogs, Random rand) { TECTypical typ = new TECTypical(); typ.Description = "Typical"; typ.AssignRandomSystemProperties(catalogs, rand); return(typ); }
public SystemSummaryItem(TECTypical typical, TECParameters parameters, double duration = 0.0) { this.Typical = typical; Estimate = new TECEstimator(Typical, parameters, new TECExtraLabor(Guid.NewGuid()), duration, new ChangeWatcher(Typical)); UnitPrice = Estimate.TotalPrice / Typical.Instances.Count; Estimate.PropertyChanged += (x, y) => { UnitPrice = Estimate.TotalPrice / Typical.Instances.Count; }; }
public AddInstanceVM(TECTypical typical, TECBid bid) : base(bid) { toAdd = new TECSystem(typical); parent = typical; this.bid = bid; Locations = this.bid.Locations; AddCommand = new RelayCommand(addExecute, canAdd); AddPatternCommand = new RelayCommand(addPatternExecute, canAddPattern); }
/// <summary> /// Creates the typical, instances scope dictionary of a system after loading. /// </summary> /// <param name="typical">The typical system</param> /// <param name="guidDictionary">The dictionary of typical to instances guids loaded</param> private static void createScopeDictionary(TECTypical typical, Dictionary <Guid, List <Guid> > guidDictionary) { if (guidDictionary.Count == 0) { return; } foreach (TECSystem instance in typical.Instances) { foreach (TECEquipment equipment in typical.Equipment) { linkCharacteristicWithInstances(equipment, instance.Equipment, guidDictionary, typical.TypicalInstanceDictionary); foreach (TECSubScope subscope in equipment.SubScope) { foreach (TECEquipment instanceEquipment in instance.Equipment) { linkCharacteristicWithInstances(subscope, instanceEquipment.SubScope, guidDictionary, typical.TypicalInstanceDictionary); foreach (TECSubScope instanceSubScope in instanceEquipment.SubScope) { foreach (TECPoint point in subscope.Points) { linkCharacteristicWithInstances(point, instanceSubScope.Points, guidDictionary, typical.TypicalInstanceDictionary); } foreach (TECInterlockConnection interlock in subscope.Interlocks) { linkCharacteristicWithInstances(interlock, instanceSubScope.Interlocks, guidDictionary, typical.TypicalInstanceDictionary); } foreach (TECScopeBranch branch in subscope.ScopeBranches) { linkCharacteristicWithInstances(branch, instanceSubScope.ScopeBranches, guidDictionary, typical.TypicalInstanceDictionary); } } } } } foreach (TECController controller in typical.Controllers) { linkCharacteristicWithInstances(controller, instance.Controllers, guidDictionary, typical.TypicalInstanceDictionary); } foreach (TECPanel panel in typical.Panels) { linkCharacteristicWithInstances(panel, instance.Panels, guidDictionary, typical.TypicalInstanceDictionary); } foreach (TECMisc misc in typical.MiscCosts) { linkCharacteristicWithInstances(misc, instance.MiscCosts, guidDictionary, typical.TypicalInstanceDictionary); } foreach (TECScopeBranch branch in typical.ScopeBranches) { linkCharacteristicWithInstances(branch, instance.ScopeBranches, guidDictionary, typical.TypicalInstanceDictionary); } } }
private void testNetworkExecute() { TECControllerType type = new TECControllerType(bid.Catalogs.Manufacturers[0]); type.Name = "Controller Type"; type.IO.Add(new TECIO(IOType.AI)); bid.Catalogs.Add(type); TECProvidedController controller = new TECProvidedController(type); controller.Name = "Test Server"; controller.Description = "For testing."; controller.IsServer = true; bid.AddController(controller); TECProvidedController child = new TECProvidedController(type); child.Name = "Child"; bid.AddController(child); TECProvidedController emptyController = new TECProvidedController(type); emptyController.Name = "EmptyController"; bid.AddController(emptyController); TECNetworkConnection connection = controller.AddNetworkConnection(bid.Catalogs.Protocols[0]); connection.AddChild(child); TECTypical typical = new TECTypical(); TECEquipment equip = new TECEquipment(); 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); equip.SubScope.Add(ss); typical.Equipment.Add(equip); bid.Systems.Add(typical); typical.AddInstance(); }
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 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); }
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 AddInstanceSystem() { //Arrange TECTypical typical = ModelCreation.TestTypical(bid.Catalogs, rand); typical.AssignRandomScopeProperties(bid.Catalogs, rand); bid.Systems.Add(typical); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); //Act TECSystem instance = typical.AddInstance(); //Assert AssertMaterialVMMatchesCostBatch(matVM, instance.CostBatch); }
public void AddInstanceTest() { Random rand = new Random(0); TECCatalogs catalogs = ModelCreation.TestCatalogs(rand); TECTypical typical = ModelCreation.TestTypical(catalogs, rand); TECSystem system = typical.AddInstance(); Assert.AreEqual(typical.Equipment.Count, system.Equipment.Count); Assert.AreEqual(typical.ScopeBranches.Count, system.ScopeBranches.Count); Assert.AreEqual(typical.ProposalItems.Count, system.ProposalItems.Count); Assert.AreEqual(typical.Controllers.Count, system.Controllers.Count); Assert.AreEqual(typical.Panels.Count, system.Panels.Count); Assert.AreEqual(typical.MiscCosts.Count, system.MiscCosts.Count); Assert.AreEqual(typical.Controllers.Aggregate(0, (total, next) => total += next.GetAll <TECConnection>().Count), system.GetAll <TECConnection>().Count); }
public void TotalMatches() { var bid = new TECBid(); var parameters = ModelCreation.TestParameters(rand, bid); var catalogs = ModelCreation.TestCatalogs(rand); bid.Parameters = parameters; bid.Catalogs = catalogs; ChangeWatcher watcher = new ChangeWatcher(bid); SystemSummaryVM summaryVM = new SystemSummaryVM(bid, watcher); List <Tuple <TECEstimator, TECTypical> > estimates = new List <Tuple <TECEstimator, TECTypical> >(); int x = 6; for (int i = 0; i < x; i++) { TECTypical typical1 = createTypical(bid); TECEstimator estimate1 = new TECEstimator(typical1, bid.Parameters, new TECExtraLabor(Guid.NewGuid()), bid.Duration, new ChangeWatcher(typical1)); estimates.Add(new Tuple <TECEstimator, TECTypical>(estimate1, typical1)); } double previous = estimates[0].Item1.TotalPrice; foreach (var thing in estimates) { Assert.AreEqual(thing.Item1.TotalPrice, previous); previous = thing.Item1.TotalPrice; } int y = 0; foreach (var item in estimates) { foreach (SystemSummaryItem system in summaryVM.Systems) { Assert.AreEqual(item.Item1.TotalPrice, system.Estimate.TotalPrice); if (system.Typical == item.Item2) { Assert.AreEqual(system.Estimate.TotalPrice, item.Item1.TotalPrice); y++; break; } } } }
public void AddEquipmentToTypicalWithInstance() { TECBid bid = new TECBid(); TECTypical typical = new TECTypical(); bid.Systems.Add(typical); TECSystem instance = typical.AddInstance(); TECEquipment toAdd = new TECEquipment(); typical.Equipment.Add(toAdd); TECEquipment instanceEquipment = typical.TypicalInstanceDictionary.GetInstances(toAdd)[0] as TECEquipment; Assert.IsNotNull(instanceEquipment, "Not added to instance dictionary"); Assert.IsTrue(instance.Equipment.Contains(instanceEquipment)); }
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 AddElectricalMiscToSystem() { //Arrange TECMisc misc = ModelCreation.TestMisc(bid.Catalogs, rand, CostType.Electrical); TECTypical typical = new TECTypical(); bid.Systems.Add(typical); typical.AddInstance(); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); //Act typical.MiscCosts.Add(misc); //Assert AssertMaterialVMMatchesCostBatch(matVM, misc.CostBatch); }
public void SaveAs_Bid_System() { //Arrange TECBid bid = new TECBid(); bid.Catalogs = ModelCreation.TestCatalogs(rand, 5); TECTypical expectedSystem = ModelCreation.TestTypical(bid.Catalogs, rand); bid.Systems.Add(expectedSystem); expectedSystem.AddInstance(); path = Path.GetTempFileName(); //Act DatabaseManager <TECBid> manager = new DatabaseManager <TECBid>(path); manager.New(bid); TECBid loadedBid = manager.Load() as TECBid; TECTypical actualSystem = null; foreach (TECTypical system in loadedBid.Systems) { if (system.Guid == expectedSystem.Guid) { actualSystem = system; break; } } //Assert Assert.AreEqual(expectedSystem.Name, actualSystem.Name); Assert.AreEqual(expectedSystem.Description, actualSystem.Description); Assert.AreEqual(expectedSystem.Instances.Count, actualSystem.Instances.Count); Assert.AreEqual(expectedSystem.Equipment.Count, actualSystem.Equipment.Count); Assert.AreEqual(expectedSystem.Controllers.Count, actualSystem.Controllers.Count); Assert.AreEqual(expectedSystem.Panels.Count, actualSystem.Panels.Count); Assert.AreEqual(expectedSystem.ScopeBranches.Count, actualSystem.ScopeBranches.Count); Assert.AreEqual(expectedSystem.AssociatedCosts.Count, actualSystem.AssociatedCosts.Count); Assert.AreEqual(expectedSystem.MiscCosts.Count, actualSystem.MiscCosts.Count); Assert.AreEqual(expectedSystem.TypicalInstanceDictionary.GetFullDictionary().Count, actualSystem.TypicalInstanceDictionary.GetFullDictionary().Count); Assert.IsTrue(compareCosts(expectedSystem.CostBatch, actualSystem.CostBatch)); }