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 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 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 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 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 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); }
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); }
private static CostBatch MatVMToCostBatch(MaterialSummaryVM vm) { CostBatch cb = new CostBatch(); cb.Add(CostType.TEC, vm.TotalTECCost, vm.TotalTECLabor); cb.Add(CostType.Electrical, vm.TotalElecCost, vm.TotalElecLabor); return(cb); }
private static void AssertMaterialVMMatchesCostBatch(MaterialSummaryVM vm, CostBatch cb) { Assert.AreEqual(vm.TotalTECCost, cb.GetCost(CostType.TEC), GeneralTestingUtilities.DELTA, "Total tec cost didn't update properly."); Assert.AreEqual(vm.TotalTECLabor, cb.GetLabor(CostType.TEC), GeneralTestingUtilities.DELTA, "Total tec labor didn't update properly."); Assert.AreEqual(vm.TotalElecCost, cb.GetCost(CostType.Electrical), GeneralTestingUtilities.DELTA, "Total elec cost didn't update properly."); Assert.AreEqual(vm.TotalElecLabor, cb.GetLabor(CostType.Electrical), GeneralTestingUtilities.DELTA, "Total elec labor didn't update properly."); }
public void AddElectricalMiscToBid() { //Arrange TECMisc misc = ModelCreation.TestMisc(bid.Catalogs, rand, CostType.Electrical); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); //Act bid.MiscCosts.Add(misc); //Assert AssertMaterialVMMatchesCostBatch(matVM, misc.CostBatch); }
public void AddController() { //Arrange TECController controller = ModelCreation.TestProvidedController(bid.Catalogs, rand); controller.AssignRandomScopeProperties(bid.Catalogs, rand); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); //Act bid.AddController(controller); //Assert AssertMaterialVMMatchesCostBatch(matVM, controller.CostBatch); }
public void AddPanel() { //Arrange TECPanel panel = ModelCreation.TestPanel(bid.Catalogs, rand); panel.AssignRandomScopeProperties(bid.Catalogs, rand); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); //Act bid.Panels.Add(panel); //Assert AssertMaterialVMMatchesCostBatch(matVM, panel.CostBatch); }
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 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 RemoveElectricalMisc() { //Arrange TECMisc misc = ModelCreation.TestMisc(bid.Catalogs, rand, CostType.Electrical); bid.MiscCosts.Add(misc); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); CostBatch initial = MatVMToCostBatch(matVM); //Act bid.MiscCosts.Remove(misc); //Assert AssertMaterialVMMatchesCostBatch(matVM, initial - misc.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 EstimateEditorVM(TECBid bid, ChangeWatcher watcher, TECEstimator estimate) { this.bid = bid; this.watcher = watcher; ScopeEditorVM = new ScopeEditorVM(bid, watcher); LaborVM = new LaborVM(bid, estimate); ReviewVM = new ReviewVM(bid, estimate); ProposalVM = new ProposalVM(bid); ItemizedSummaryVM = new ItemizedSummaryVM(bid, watcher); MaterialSummaryVM = new MaterialSummaryVM(bid, watcher); RiserVM = new RiserVM(bid, watcher); ScheduleVM = new ScheduleVM(bid, watcher); BidPropertiesVM = new BidPropertiesVM(bid); InternalNotesVM = new InternalNotesVM(bid); QuotesVM = new QuotesVM(bid, watcher); RefreshMaterialSummaryCommand = new RelayCommand(executeMaterialRefersh); }
public void RemoveElectricalCost() { //Arrange TECAssociatedCost cost = bid.Catalogs.AssociatedCosts.First(x => x.Type == CostType.Electrical); 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 AddEquipment() { //Arrange TECEquipment equipment = ModelCreation.TestEquipment(bid.Catalogs, rand); equipment.AssignRandomScopeProperties(bid.Catalogs, rand); TECTypical typical = new TECTypical(); bid.Systems.Add(typical); typical.AddInstance(); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); //Act typical.Equipment.Add(equipment); //Assert AssertMaterialVMMatchesCostBatch(matVM, equipment.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 RemoveInstanceSystem() { //Arrange TECTypical typical = ModelCreation.TestTypical(bid.Catalogs, rand); bid.Systems.Add(typical); TECSystem instance = typical.AddInstance(); CostBatch instanceCost = instance.CostBatch; MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); CostBatch initial = MatVMToCostBatch(matVM); //Act typical.Instances.Remove(instance); //Assert AssertMaterialVMMatchesCostBatch(matVM, initial - instanceCost); }
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); }
private void executeMaterialRefersh() { MaterialSummaryVM = new MaterialSummaryVM(bid, watcher); RaisePropertyChanged("MaterialSummaryVM"); }