Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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 GetCostsTest()
        {
            TECElectricalMaterial type  = new TECElectricalMaterial();
            TECAssociatedCost     aCost = new TECAssociatedCost(CostType.TEC);

            aCost.Cost = 3;
            TECAssociatedCost rCost = new TECAssociatedCost(CostType.TEC);

            rCost.Cost = 5;
            type.Cost  = 2;
            type.Labor = 1;

            type.AssociatedCosts.Add(aCost);
            type.RatedCosts.Add(rCost);

            var costs        = type.GetCosts(2);
            var tecExpected  = 2 * (5) + 3;
            var elecExpected = 2 * (2);

            Assert.AreEqual(tecExpected, costs.GetCost(CostType.TEC));
            Assert.AreEqual(elecExpected, costs.GetCost(CostType.Electrical));
            var tecLaborExpected  = 0;
            var elecLabroExpected = 2 * (1);

            Assert.AreEqual(tecLaborExpected, costs.GetLabor(CostType.TEC));
            Assert.AreEqual(elecLabroExpected, costs.GetLabor(CostType.Electrical));
        }
        public void CostBatchTest3()
        {
            TECAssociatedCost aCost1 = new TECAssociatedCost(CostType.TEC);

            aCost1.Cost  = 10;
            aCost1.Labor = 11;

            TECAssociatedCost aCost2 = new TECAssociatedCost(CostType.TEC);

            aCost2.Cost  = 10;
            aCost2.Labor = 11;

            TECAssociatedCost aCost3 = new TECAssociatedCost(CostType.Electrical);

            aCost3.Cost  = 10;
            aCost3.Labor = 11;

            CostBatch ogCost = new CostBatch(new List <ICost>()
            {
                aCost1, aCost2, aCost3
            });


            CostBatch cost = new CostBatch(ogCost);

            Assert.AreEqual(20, cost.GetCost(CostType.TEC));
            Assert.AreEqual(22, cost.GetLabor(CostType.TEC));

            Assert.AreEqual(10, cost.GetCost(CostType.Electrical));
            Assert.AreEqual(11, cost.GetLabor(CostType.Electrical));
        }
        public void RemoveTest()
        {
            TECAssociatedCost aCost1 = new TECAssociatedCost(CostType.TEC);

            aCost1.Cost  = 10;
            aCost1.Labor = 11;

            TECAssociatedCost aCost2 = new TECAssociatedCost(CostType.Electrical);

            aCost2.Cost  = 12;
            aCost2.Labor = 13;

            CostBatch cost = new CostBatch(new List <ICost>()
            {
                aCost1, aCost2
            });

            cost.Remove(CostType.TEC, 10, 11);
            Assert.AreEqual(0, cost.GetCost(CostType.TEC));
            Assert.AreEqual(0, cost.GetLabor(CostType.TEC));

            cost.Remove(CostType.Electrical, 12, 13);
            Assert.AreEqual(0, cost.GetCost(CostType.Electrical));
            Assert.AreEqual(0, cost.GetLabor(CostType.Electrical));
        }
Exemplo n.º 7
0
        public void DragDropCopyTest()
        {
            TECAssociatedCost cost       = new TECAssociatedCost(CostType.TEC);
            TECAssociatedCost copiedCost = cost.DropData() as TECAssociatedCost;

            Assert.AreEqual(cost, copiedCost);
        }
Exemplo n.º 8
0
        public static TECAssociatedCost TestCost(TECCatalogs catalogs, Random rand, CostType type)
        {
            TECAssociatedCost cost = new TECAssociatedCost(type);

            cost.Description = string.Format("Test Associated {0} Cost", type);
            cost.AssignRandomCostProperties(catalogs, rand);
            return(cost);
        }
Exemplo n.º 9
0
        public void CatalogCopyTest()
        {
            TECAssociatedCost cost       = new TECAssociatedCost(CostType.TEC);
            TECAssociatedCost copiedCost = cost.CatalogCopy();

            Assert.AreEqual(cost.Name, copiedCost.Name);
            Assert.AreEqual(cost.Type, copiedCost.Type);
            Assert.AreEqual(cost.Labor, copiedCost.Labor);
            Assert.IsTrue(cost.Tags.SequenceEqual(copiedCost.Tags));
        }
Exemplo n.º 10
0
        public void SubScopeTemplateChanged()
        {
            //Arrange
            TECTemplates templates = new TECTemplates();

            TECSubScope templateSS = new TECSubScope();

            templateSS.Name = "Template SubScope";
            templates.Templates.SubScopeTemplates.Add(templateSS);

            TemplateSynchronizer <TECSubScope> ssSynchronizer = templates.SubScopeSynchronizer;
            TECSubScope refSS = ssSynchronizer.NewItem(templateSS);

            TECEquipment equip = new TECEquipment();

            templates.Templates.EquipmentTemplates.Add(equip);
            equip.SubScope.Add(refSS);

            TECDevice dev = new TECDevice(new List <TECConnectionType>(),
                                          new List <TECProtocol>(),
                                          new TECManufacturer());

            templates.Catalogs.Add(dev);

            TECPoint point = new TECPoint();

            point.Label    = "Test Point";
            point.Type     = IOType.AI;
            point.Quantity = 5;

            TECAssociatedCost cost = new TECAssociatedCost(CostType.TEC);

            templates.Catalogs.Add(cost);

            TECTag tag = new TECTag();

            templates.Catalogs.Add(tag);

            //Act
            templateSS.Description = "Test Description";
            templateSS.Devices.Add(dev);
            templateSS.AddPoint(point);
            templateSS.AssociatedCosts.Add(cost);
            templateSS.Tags.Add(tag);

            //Assert
            //Assert.AreEqual(templateSS.Description, refSS.Description, "Description didn't sync properly between SubScope.");
            Assert.AreEqual(templateSS.Devices[0], refSS.Devices[0], "Devices didn't sync properly between SubScope.");
            Assert.AreEqual(templateSS.Points[0].Label, refSS.Points[0].Label, "Points didn't sync properly between SubScope.");
            Assert.AreEqual(templateSS.Points[0].Type, refSS.Points[0].Type, "Points didn't sync properly between SubScope.");
            Assert.AreEqual(templateSS.Points[0].Quantity, refSS.Points[0].Quantity, "Points didn't sync properly between SubScope.");
            Assert.AreEqual(templateSS.AssociatedCosts[0], refSS.AssociatedCosts[0], "Associated costs didn't sync properly between SubScope.");
            Assert.AreEqual(templateSS.Tags[0], refSS.Tags[0], "Tags didn't sync properly between SubScope.");
        }
Exemplo n.º 11
0
        public void CostBatchTest1()
        {
            TECAssociatedCost aCost = new TECAssociatedCost(CostType.TEC);

            aCost.Cost  = 10;
            aCost.Labor = 11;

            CostBatch cost = new CostBatch(aCost);

            Assert.AreEqual(10, cost.GetCost(CostType.TEC));
            Assert.AreEqual(11, cost.GetLabor(CostType.TEC));
        }
Exemplo n.º 12
0
        private void addAsociatedCostExecute()
        {
            TECAssociatedCost associatedCost = new TECAssociatedCost(AssociatedCostType);

            associatedCost.Name  = this.AssociatedCostName;
            associatedCost.Cost  = this.AssociatedCostCost;
            associatedCost.Labor = this.AssociatedCostLabor;

            this.Templates.Catalogs.Add(associatedCost);

            this.AssociatedCostName  = "";
            this.AssociatedCostCost  = 0;
            this.AssociatedCostLabor = 0;
        }
        public static void ClassInitialize(TestContext TestContext)
        {
            rand = new Random(0);
            //Arrange
            expectedTemplates = ModelCreation.TestTemplates(rand);
            ModelCreation.AddSyncronizerItems(expectedTemplates);
            expectedSystem         = expectedTemplates.Templates.SystemTemplates.First();
            expectedEquipment      = expectedTemplates.Templates.EquipmentTemplates.First();
            expectedSubScope       = expectedTemplates.Templates.SubScopeTemplates.First();
            expectedDevice         = expectedTemplates.Catalogs.Devices.First();
            expectedManufacturer   = expectedTemplates.Catalogs.Manufacturers.First();
            expectedTag            = expectedTemplates.Catalogs.Tags[0];
            expectedController     = (TECProvidedController)expectedTemplates.Templates.ControllerTemplates.First(sys => sys is TECProvidedController);
            expectedAssociatedCost = expectedTemplates.Catalogs.AssociatedCosts[0];
            expectedConnectionType = expectedTemplates.Catalogs.ConnectionTypes[0];
            expectedConduitType    = expectedTemplates.Catalogs.ConduitTypes[0];

            path = Path.GetTempFileName();

            //Act
            DatabaseManager <TECTemplates> manager = new DatabaseManager <TECTemplates>(path);
            bool success = manager.New(expectedTemplates);

            Assert.IsTrue(success, "New method in DatabaseManager returned false.");
            actualTemplates = manager.Load();

            if (actualTemplates.Templates.SystemTemplates.Count == 0)
            {
                string failDirectory = Path.GetTempPath() + "Estimating Tools\\";
                Directory.CreateDirectory(failDirectory);
                string failPath = failDirectory + "SaveNewTemplatesTestFailed.tdb";
                if (File.Exists(failPath))
                {
                    File.Delete(failPath);
                }
                File.Copy(path, failPath);
                Assert.Fail(string.Format("No systems loaded into templates. File saved at: {0}", failPath));
            }

            actualSystem         = actualTemplates.Templates.SystemTemplates.First(x => x.Guid == expectedSystem.Guid);
            actualEquipment      = actualTemplates.Templates.EquipmentTemplates.First(x => x.Guid == expectedEquipment.Guid);
            actualSubScope       = actualTemplates.Templates.SubScopeTemplates.First(x => x.Guid == expectedSubScope.Guid);
            actualDevice         = actualTemplates.Catalogs.Devices.First(x => x.Guid == expectedDevice.Guid);
            actualManufacturer   = actualTemplates.Catalogs.Manufacturers.First(x => x.Guid == expectedManufacturer.Guid);
            actualTag            = actualTemplates.Catalogs.Tags.First(x => x.Guid == expectedTag.Guid);
            actualController     = actualTemplates.Templates.ControllerTemplates.First(x => x.Guid == expectedController.Guid) as TECProvidedController;
            actualAssociatedCost = actualTemplates.Catalogs.AssociatedCosts.First(x => x.Guid == expectedAssociatedCost.Guid);
            actualConnectionType = actualTemplates.Catalogs.ConnectionTypes.First(x => x.Guid == expectedConnectionType.Guid);
            actualConduitType    = actualTemplates.Catalogs.ConduitTypes.First(x => x.Guid == expectedConduitType.Guid);
        }
        public static void AssignRandomScopeProperties(this TECScope scope, TECCatalogs catalogs, Random rand)
        {
            scope.AssignRandomTaggedProperties(catalogs, rand);
            TECAssociatedCost randTECCost  = catalogs.RandomCost(rand, CostType.TEC);
            TECAssociatedCost randElecCost = catalogs.RandomCost(rand, CostType.Electrical);

            if (randTECCost != null)
            {
                scope.AssociatedCosts.Add(randTECCost);
            }
            if (randElecCost != null)
            {
                scope.AssociatedCosts.Add(randElecCost);
            }
        }
        public static void AssignRandomElectricalMaterialProperties(this TECElectricalMaterial mat, TECCatalogs catalogs, Random rand)
        {
            mat.AssignRandomCostProperties(catalogs, rand);
            TECAssociatedCost randTECCost  = catalogs.RandomCost(rand, CostType.TEC);
            TECAssociatedCost randElecCost = catalogs.RandomCost(rand, CostType.Electrical);

            if (randTECCost != null)
            {
                mat.RatedCosts.Add(randTECCost);
            }
            if (randElecCost != null)
            {
                mat.RatedCosts.Add(randElecCost);
            }
        }
        public void Load_Templates_AssociatedCosts()
        {
            Guid     expectedTECGuid  = new Guid("1c2a7631-9e3b-4006-ada7-12d6cee52f08");
            string   expectedTECName  = "Test TEC Associated Cost";
            double   expectedTECCost  = 31;
            double   expectedTECLabor = 13;
            CostType expectedTECType  = CostType.TEC;

            Guid     expectedElectricalGuid  = new Guid("63ed1eb7-c05b-440b-9e15-397f64ff05c7");
            string   expectedElectricalName  = "Test Electrical Associated Cost";
            double   expectedElectricalCost  = 42;
            double   expectedElectricalLabor = 24;
            CostType expectedElectricalType  = CostType.Electrical;

            TECAssociatedCost actualTECCost        = null;
            TECAssociatedCost actualElectricalCost = null;

            foreach (TECAssociatedCost cost in actualTemplates.Catalogs.AssociatedCosts)
            {
                if (cost.Guid == expectedTECGuid)
                {
                    actualTECCost = cost;
                }
                else if (cost.Guid == expectedElectricalGuid)
                {
                    actualElectricalCost = cost;
                }
                if (actualTECCost != null && actualElectricalCost != null)
                {
                    break;
                }
            }

            //Assert
            Assert.AreEqual(expectedTECName, actualTECCost.Name, "TEC cost name didn't load properly.");
            Assert.AreEqual(expectedTECCost, actualTECCost.Cost, "TEC cost cost didn't load properly.");
            Assert.AreEqual(expectedTECLabor, actualTECCost.Labor, "TEC cost labor didn't load properly.");
            Assert.AreEqual(expectedTECType, actualTECCost.Type, "TEC cost type didn't load properly.");

            Assert.AreEqual(expectedElectricalName, actualElectricalCost.Name, "Electrical cost name didn't load properly.");
            Assert.AreEqual(expectedElectricalCost, actualElectricalCost.Cost, "Electrical cost cost didn't load properly.");
            Assert.AreEqual(expectedElectricalLabor, actualElectricalCost.Labor, "Electrical cost labor didn't load properly.");
            Assert.AreEqual(expectedElectricalType, actualElectricalCost.Type, "Electrical cost type didn't load properly.");
        }
        public void Undo_Template_SubScope_AssociatedCost()
        {
            //Arrange
            var Template           = ModelCreation.TestTemplates(rand);
            var subScope           = Template.Templates.SubScopeTemplates[0];
            int expectedCount      = subScope.AssociatedCosts.Count;
            TECAssociatedCost edit = new TECAssociatedCost(CostType.Electrical);

            //Act
            ChangeWatcher watcher = new ChangeWatcher(Template); DoStacker testStack = new DoStacker(watcher);

            subScope.AssociatedCosts.Add(edit);
            testStack.Undo();

            //assert
            int actual = subScope.AssociatedCosts.Count;

            Assert.AreEqual(expectedCount, actual, "Not Undone");
        }
Exemplo n.º 18
0
        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 GetCostsTest()
        {
            TECConnectionType type  = new TECConnectionType();
            TECAssociatedCost aCost = new TECAssociatedCost(CostType.TEC);

            aCost.Cost = 3;
            TECAssociatedCost rCost = new TECAssociatedCost(CostType.TEC);

            rCost.Cost = 5;
            type.Cost  = 2;
            type.Labor = 1;

            type.AssociatedCosts.Add(aCost);
            type.RatedCosts.Add(rCost);

            var costs        = type.GetCosts(2);
            var tecExpected  = 2 * (5) + 3;
            var elecExpected = 2 * (2);

            Assert.AreEqual(tecExpected, costs.GetCost(CostType.TEC));
            Assert.AreEqual(elecExpected, costs.GetCost(CostType.Electrical));
            var tecLaborExpected  = 0;
            var elecLabroExpected = 2 * (1);

            Assert.AreEqual(tecLaborExpected, costs.GetLabor(CostType.TEC));
            Assert.AreEqual(elecLabroExpected, costs.GetLabor(CostType.Electrical));

            type.PlenumCost  = 1;
            type.PlenumLabor = 1;
            costs            = type.GetCosts(2, true);
            tecExpected      = 2 * (5) + 3;
            elecExpected     = 2 * (2 + 1);
            Assert.AreEqual(tecExpected, costs.GetCost(CostType.TEC));
            Assert.AreEqual(elecExpected, costs.GetCost(CostType.Electrical));
            tecLaborExpected  = 0;
            elecLabroExpected = 2 * (1 + 1);
            Assert.AreEqual(tecLaborExpected, costs.GetLabor(CostType.TEC));
            Assert.AreEqual(elecLabroExpected, costs.GetLabor(CostType.Electrical));
        }
Exemplo n.º 20
0
        public void AddCostTest()
        {
            CostBatch cost = new CostBatch();

            TECAssociatedCost aCost1 = new TECAssociatedCost(CostType.TEC);

            aCost1.Cost  = 10;
            aCost1.Labor = 11;

            TECAssociatedCost aCost2 = new TECAssociatedCost(CostType.Electrical);

            aCost2.Cost  = 10;
            aCost2.Labor = 11;

            cost.AddCost(aCost1);
            Assert.AreEqual(10, cost.GetCost(CostType.TEC));
            Assert.AreEqual(11, cost.GetLabor(CostType.TEC));

            cost.AddCost(aCost2);
            Assert.AreEqual(10, cost.GetCost(CostType.Electrical));
            Assert.AreEqual(11, cost.GetLabor(CostType.Electrical));
        }
        internal static void AddControllersSheet(XLWorkbook workbook, TECBid bid, TECEstimator estimate, string sheetName = "Controllers")
        {
            List <TECController>         controllers         = getAllControllers(bid);
            List <TECProvidedController> providedControllers = new List <TECProvidedController>();

            foreach (TECController controller in controllers)
            {
                if (controller is TECProvidedController provided)
                {
                    providedControllers.Add(provided);
                }
            }
            List <TECIOModule>         modules         = getAllIOModules(bid);
            List <HardwareSummaryItem> controllerItems = consolidateHardware(providedControllers.Select(provided => provided.Type));
            List <CostSummaryItem>     costItems       = consolidateCostInControllers(controllers);
            List <HardwareSummaryItem> modulesItems    = consolidateHardware(modules);

            IXLWorksheet worksheet = workbook.Worksheets.Add(sheetName);
            int          row       = 1;

            row = worksheet.insertTitleRow(sheetName, row);
            row++;

            row = worksheet.insertHardwareHeaders(row);
            foreach (HardwareSummaryItem item in controllerItems)
            {
                row = worksheet.insertHardwareItem(item, row);
            }
            row++;

            row = worksheet.insertTitleRow("IO Modules", row);
            row++;

            row = worksheet.insertHardwareHeaders(row);
            foreach (HardwareSummaryItem item in modulesItems)
            {
                row = worksheet.insertHardwareItem(item, row);
            }
            row++;

            row = worksheet.insertTitleRow("Associated Costs", row);
            row++;

            row = worksheet.insertCostHeaders(row);
            foreach (CostSummaryItem item in costItems)
            {
                row = worksheet.insertCostItem(item, row);
            }
            row++;

            row = worksheet.insertCostHeaders(row);
            TECAssociatedCost softwareCost = new TECAssociatedCost(CostType.TEC);

            softwareCost.Name = "Software Point License";
            softwareCost.Cost = estimate.TECSoftwareCost;
            CostSummaryItem softwareSummary = new CostSummaryItem(softwareCost);

            row = worksheet.insertCostItem(softwareSummary, row);
            row++;

            worksheet.formatFinal();
        }
Exemplo n.º 22
0
        public void EquipmentReferenceChanged()
        {
            //Arrange
            TECTemplates templates = new TECTemplates();

            TECEquipment templateEquip = new TECEquipment();

            templateEquip.Name = "Template Equip";
            templates.Templates.EquipmentTemplates.Add(templateEquip);

            TemplateSynchronizer <TECEquipment> equipSynchronizer = templates.EquipmentSynchronizer;
            TECEquipment refEquip = equipSynchronizer.NewItem(templateEquip);

            TECSystem sys = new TECSystem();

            templates.Templates.SystemTemplates.Add(sys);
            sys.Equipment.Add(refEquip);

            TECDevice dev = new TECDevice(new List <TECConnectionType>(),
                                          new List <TECProtocol>(),
                                          new TECManufacturer());

            templates.Catalogs.Add(dev);

            TECPoint point = new TECPoint();

            point.Label    = "Test Point";
            point.Type     = IOType.AI;
            point.Quantity = 5;

            TECAssociatedCost cost = new TECAssociatedCost(CostType.TEC);

            templates.Catalogs.Add(cost);

            TECTag tag = new TECTag();

            templates.Catalogs.Add(tag);

            TECSubScope ss = new TECSubScope();

            ss.Description = "Test Description";
            ss.Devices.Add(dev);
            ss.AddPoint(point);
            ss.AssociatedCosts.Add(cost);
            ss.Tags.Add(tag);

            templates.Templates.SubScopeTemplates.Add(ss);

            //Act
            refEquip.Description = "Test Description";
            refEquip.SubScope.Add(ss);
            refEquip.AssociatedCosts.Add(cost);
            refEquip.Tags.Add(tag);

            //Assert
            //Assert.AreEqual(refEquip.Description, templateEquip.Description, "Description didn't sync properly between Equipment.");

            Assert.IsNotNull(templateEquip.SubScope[0], "SubScope didn't sync properly between Equipment.");

            TECSubScope templateSubScope = templateEquip.SubScope[0];
            TECSubScope refSubScope      = refEquip.SubScope[0];

            //Assert.AreEqual(refSubScope.Description, templateSubScope.Description, "Description didn't sync properly between SubScope in Equipment.");
            Assert.AreEqual(refSubScope.Devices[0], templateSubScope.Devices[0], "Devices didn't sync properly between SubScope in Equipment.");
            Assert.AreEqual(refSubScope.Points[0].Label, templateSubScope.Points[0].Label, "Points didn't sync properly between SubScope in Equipment.");
            Assert.AreEqual(refSubScope.Points[0].Type, templateSubScope.Points[0].Type, "Points didn't sync properly between SubScope in Equipment.");
            Assert.AreEqual(refSubScope.Points[0].Quantity, templateSubScope.Points[0].Quantity, "Points didn't sync properly between SubScope in Equipment.");
            Assert.AreEqual(refSubScope.AssociatedCosts[0], templateSubScope.AssociatedCosts[0], "AssociatedCosts didn't sync properly between SubScope in Equipment.");
            Assert.AreEqual(refSubScope.Tags[0], templateSubScope.Tags[0], "Tags didn't sync properly between SubScope.");

            Assert.AreEqual(refEquip.AssociatedCosts[0], templateEquip.AssociatedCosts[0], "AssociatedCosts didn't sync properly between Equipment.");
            Assert.AreEqual(refEquip.Tags[0], templateEquip.Tags[0], "Tags didn't sync properly in Equipment.");
        }
Exemplo n.º 23
0
        public static TECCatalogs CreateTestCatalogs()
        {
            TECCatalogs outCatalogs = new TECCatalogs();

            //Associated Costs
            TECAssociatedCost elecCost = new TECAssociatedCost(CostType.Electrical);

            elecCost.Name  = "Elec Cost";
            elecCost.Cost  = 156.61;
            elecCost.Labor = 456.64;
            elecCost.Type  = CostType.Electrical;
            outCatalogs.AssociatedCosts.Add(elecCost);

            TECAssociatedCost tecCost = new TECAssociatedCost(CostType.TEC);

            tecCost.Name  = "TEC Cost";
            tecCost.Cost  = 46.43;
            tecCost.Labor = 61.45;
            tecCost.Type  = CostType.TEC;
            outCatalogs.AssociatedCosts.Add(tecCost);

            //Tags
            var tag1 = new TECTag();

            tag1.Label = "Tag 1";
            var tag2 = new TECTag();

            tag2.Label = "Test Tag";

            outCatalogs.Tags.Add(tag1);
            outCatalogs.Tags.Add(tag2);

            //Conduit Types
            var conduitType1 = new TECElectricalMaterial();

            conduitType1.Name  = "Test Conduit 1";
            conduitType1.Cost  = 64.49;
            conduitType1.Labor = 463.87;
            AssignSecondaryProperties(conduitType1, outCatalogs);
            conduitType1.RatedCosts.Add(tecCost);
            conduitType1.RatedCosts.Add(elecCost);

            outCatalogs.ConduitTypes.Add(conduitType1);

            var conduitType2 = new TECElectricalMaterial();

            conduitType2.Name  = "Test Conduit 2";
            conduitType2.Cost  = 13.45;
            conduitType2.Labor = 9873.40;
            AssignSecondaryProperties(conduitType2, outCatalogs);
            conduitType2.RatedCosts.Add(tecCost);
            conduitType2.RatedCosts.Add(elecCost);

            outCatalogs.ConduitTypes.Add(conduitType2);

            //ConnectionTypes
            var connectionType1 = new TECConnectionType();

            connectionType1.Name  = "FourC18";
            connectionType1.Cost  = 64.63;
            connectionType1.Labor = 98.16;
            AssignSecondaryProperties(connectionType1, outCatalogs);
            connectionType1.RatedCosts.Add(tecCost);
            connectionType1.RatedCosts.Add(elecCost);

            var connectionType2 = new TECConnectionType();

            connectionType2.Name  = "ThreeC18";
            connectionType2.Cost  = 73.16;
            connectionType2.Labor = 35.49;
            AssignSecondaryProperties(connectionType1, outCatalogs);
            connectionType1.RatedCosts.Add(tecCost);
            connectionType1.RatedCosts.Add(elecCost);

            outCatalogs.ConnectionTypes.Add(connectionType1);
            outCatalogs.ConnectionTypes.Add(connectionType2);

            //Manufacturers
            var manufacturer1 = new TECManufacturer();

            manufacturer1.Label      = "Test";
            manufacturer1.Multiplier = .51;

            outCatalogs.Manufacturers.Add(manufacturer1);

            //Devices
            ObservableCollection <TECConnectionType> contypes4 = new ObservableCollection <TECConnectionType>();

            contypes4.Add(connectionType1);
            TECDevice device1 = new TECDevice(Guid.NewGuid(), contypes4, new List <TECProtocol>(), manufacturer1);

            device1.Name        = "Device 1";
            device1.Description = "Description 1";
            device1.Price       = 64.96;
            device1.Tags.Add(tag1);
            AssignSecondaryProperties(device1, outCatalogs);

            outCatalogs.Devices.Add(device1);

            //IO Modules
            TECIOModule testIOModule = new TECIOModule(manufacturer1);

            testIOModule.Name         = "Test IO Module";
            testIOModule.Price        = 13.46;
            testIOModule.Manufacturer = manufacturer1;
            outCatalogs.IOModules.Add(testIOModule);

            //Controller Types
            TECControllerType controllerType = new TECControllerType(manufacturer1);

            controllerType.Name  = "Test Controller Type";
            controllerType.Price = 196.73;
            controllerType.Labor = 61.34;
            AssignSecondaryProperties(controllerType, outCatalogs);

            TECIO io = new TECIO(IOType.AI);

            io.Quantity = 100;
            controllerType.IO.Add(io);

            io          = new TECIO(IOType.UI);
            io.Quantity = 100;
            controllerType.IO.Add(io);

            io          = new TECIO(IOType.UO);
            io.Quantity = 100;
            controllerType.IO.Add(io);

            outCatalogs.ControllerTypes.Add(controllerType);

            //Panel Types
            TECPanelType panelType = new TECPanelType(manufacturer1);

            panelType.Price = 16.64;
            panelType.Labor = 91.46;
            panelType.Name  = "Test Panel Type";
            AssignSecondaryProperties(panelType, outCatalogs);

            outCatalogs.PanelTypes.Add(panelType);

            TECPanelType otherPanelType = new TECPanelType(manufacturer1);

            otherPanelType.Price = 46.61;
            otherPanelType.Labor = 64.19;
            otherPanelType.Name  = "Other Test Panel Type";
            AssignSecondaryProperties(otherPanelType, outCatalogs);

            outCatalogs.PanelTypes.Add(otherPanelType);

            //Valves
            TECDevice actuator = new TECDevice(new ObservableCollection <TECConnectionType>()
            {
                connectionType1
            },
                                               new List <TECProtocol>(),
                                               manufacturer1);

            actuator.Name = "actuator";
            outCatalogs.Devices.Add(actuator);
            TECValve valve = new TECValve(manufacturer1, actuator);

            outCatalogs.Valves.Add(valve);

            //Protocols
            TECProtocol protocol = new TECProtocol(new List <TECConnectionType> {
                connectionType1
            });

            protocol.Label = "BACnet IP";
            outCatalogs.Protocols.Add(protocol);

            controllerType.IO.Add(new TECIO(protocol));

            TECDevice netDevice = new TECDevice(Guid.NewGuid(), new List <TECConnectionType>(), new List <TECProtocol> {
                protocol
            }, manufacturer1);

            outCatalogs.Devices.Add(netDevice);

            return(outCatalogs);
        }
Exemplo n.º 24
0
        public static TECTemplates CreateTestTemplates()
        {
            TECTemplates templates = new TECTemplates();

            //Labor
            //templates.Labor = CreateTestLabor();
            templates.Parameters.Add(CreateTestParameters(Guid.NewGuid()));
            templates.Catalogs = CreateTestCatalogs();

            //Tags
            TECTag testTag = new TECTag();

            testTag.Label = "Test Tag";
            TECTag sysTag = new TECTag();

            sysTag.Label = "System Tag";
            TECTag equipTag = new TECTag();

            equipTag.Label = "Equipment Tag";
            TECTag ssTag = new TECTag();

            ssTag.Label = "SubScope Tag";
            TECTag devTag = new TECTag();

            devTag.Label = "Device Tag";

            templates.Catalogs.Tags.Add(testTag);
            templates.Catalogs.Tags.Add(sysTag);
            templates.Catalogs.Tags.Add(equipTag);
            templates.Catalogs.Tags.Add(ssTag);
            templates.Catalogs.Tags.Add(devTag);

            //Manufacturers
            TECManufacturer testMan = new TECManufacturer();

            testMan.Label      = "Test Manufacturer";
            testMan.Multiplier = 0.654;
            TECManufacturer testDevMan = new TECManufacturer();

            testDevMan.Label      = "Child Manufacturer (Test Device)";
            testDevMan.Multiplier = 0.446;
            TECManufacturer childDevMan = new TECManufacturer();

            childDevMan.Label      = "Child Manufacturer (Child Device)";
            childDevMan.Multiplier = 0.916;

            templates.Catalogs.Manufacturers.Add(testMan);
            templates.Catalogs.Manufacturers.Add(testDevMan);
            templates.Catalogs.Manufacturers.Add(childDevMan);

            //Connection Types
            TECConnectionType testDevConnType = new TECConnectionType();

            testDevConnType.Name = "FourC18";

            TECConnectionType childDevConnType = new TECConnectionType();

            childDevConnType.Name = "ThreeC18";

            templates.Catalogs.ConnectionTypes.Add(testDevConnType);
            templates.Catalogs.ConnectionTypes.Add(childDevConnType);

            //Conduit Types
            TECElectricalMaterial testConduitType = new TECElectricalMaterial();

            testConduitType.Name  = "EMT";
            testConduitType.Cost  = 12;
            testConduitType.Labor = 2;

            templates.Catalogs.ConduitTypes.Add(testConduitType);

            TECElectricalMaterial otherConduitType = new TECElectricalMaterial();

            otherConduitType.Name  = "RGS";
            otherConduitType.Cost  = 18;
            otherConduitType.Labor = 4;

            templates.Catalogs.ConduitTypes.Add(otherConduitType);

            //Associated Costs
            TECAssociatedCost testAssociatedCost = new TECAssociatedCost(CostType.Electrical);

            testAssociatedCost.Name = "Flex";
            testAssociatedCost.Cost = 42;

            templates.Catalogs.AssociatedCosts.Add(testAssociatedCost);

            var testCost2 = new TECAssociatedCost(CostType.TEC);

            testCost2.Name = "Other Cost";
            templates.Catalogs.AssociatedCosts.Add(testCost2);

            //IO Modules
            TECIOModule testIOModule = new TECIOModule(testMan);

            testIOModule.Name         = "Test IO Module";
            testIOModule.Price        = 42;
            testIOModule.Manufacturer = testMan;
            templates.Catalogs.IOModules.Add(testIOModule);

            //Devices
            ObservableCollection <TECConnectionType> contypes2 = new ObservableCollection <TECConnectionType>();

            contypes2.Add(testDevConnType);
            TECDevice testDev = new TECDevice(Guid.NewGuid(), contypes2, new List <TECProtocol>(), testDevMan);

            testDev.Name        = "Test Device";
            testDev.Description = "Device Description";
            testDev.Price       = 20.3;

            ObservableCollection <TECConnectionType> contypes3 = new ObservableCollection <TECConnectionType>();

            contypes3.Add(childDevConnType);
            TECDevice childDev = new TECDevice(Guid.NewGuid(), contypes3, new List <TECProtocol>(), childDevMan);

            childDev.Name        = "Child Device";
            childDev.Description = "Child Device Description";
            childDev.Price       = 54.1;

            testDev.Tags.Add(devTag);
            childDev.Tags.Add(devTag);

            templates.Catalogs.Devices.Add(testDev);
            templates.Catalogs.Devices.Add(childDev);

            //System
            TECSystem system = new TECSystem(false);

            system.Name        = "Test System";
            system.Description = "System Description";

            TECEquipment sysEquip = new TECEquipment(false);

            sysEquip.Name        = "System Equipment";
            sysEquip.Description = "Child Equipment";
            TECSubScope sysSS = new TECSubScope(false);

            sysSS.Name        = "System SubScope";
            sysSS.Description = "Child SubScope";
            sysSS.AssociatedCosts.Add(testAssociatedCost);
            TECPoint sysPoint = new TECPoint(false);

            sysPoint.Type  = IOType.AI;
            sysPoint.Label = "System Point";

            sysSS.Points.Add(sysPoint);
            sysSS.Devices.Add(childDev);
            sysSS.Tags.Add(ssTag);

            sysEquip.SubScope.Add(sysSS);
            sysEquip.Tags.Add(equipTag);

            system.Equipment.Add(sysEquip);
            system.Tags.Add(sysTag);

            templates.SystemTemplates.Add(system);

            //Equipment
            TECEquipment equipment = new TECEquipment(false);

            equipment.Name        = "Test Equipment";
            equipment.Description = "Equipment Description";
            TECSubScope equipSS = new TECSubScope(false);

            equipSS.Name        = "Equipment SubScope";
            equipSS.Description = "Child SubScope";
            TECPoint equipPoint = new TECPoint(false);

            equipPoint.Type  = IOType.AI;
            equipPoint.Label = "Equipment Point";

            equipSS.Points.Add(equipPoint);
            equipSS.Devices.Add(childDev);
            equipSS.Tags.Add(ssTag);

            equipment.SubScope.Add(equipSS);
            equipment.Tags.Add(equipTag);

            templates.EquipmentTemplates.Add(equipment);

            //SubScope
            TECSubScope subScope = new TECSubScope(false);

            subScope.Name        = "Test SubScope";
            subScope.Description = "SubScope Description";
            TECPoint ssPoint = new TECPoint(false);

            ssPoint.Type  = IOType.DO;
            ssPoint.Label = "SubScope Point";

            subScope.Points.Add(ssPoint);
            subScope.Devices.Add(childDev);
            subScope.Tags.Add(ssTag);
            subScope.AssociatedCosts.Add(testAssociatedCost);

            templates.SubScopeTemplates.Add(subScope);

            //Controller
            var expectedControllerType = new TECControllerType(testMan);

            expectedControllerType.Price = 42.6;
            TECIO ioToAdd = new TECIO(IOType.AI);

            ioToAdd.Quantity = 5;
            TECIO otherIO = new TECIO(IOType.UI);

            otherIO.Quantity = 3;
            expectedControllerType.IO.Add(ioToAdd);
            expectedControllerType.IO.Add(otherIO);
            templates.Catalogs.ControllerTypes.Add(expectedControllerType);

            TECController expectedController = new TECProvidedController(expectedControllerType, false);

            expectedController.Name        = "Test Controller";
            expectedController.Description = "Test description";

            TECController controlledController = new TECProvidedController(expectedControllerType, false);

            controlledController.Name = "Controlled Controller";

            templates.ControllerTemplates.Add(expectedController);

            //Misc Cost
            TECMisc cost = new TECMisc(CostType.TEC, false);

            cost.Name     = "Test Cost";
            cost.Cost     = 79.79;
            cost.Quantity = 67;

            templates.MiscCostTemplates.Add(cost);

            //Misc wiring
            TECMisc wiring = new TECMisc(CostType.Electrical, false);

            wiring.Name     = "Test Wiring";
            wiring.Cost     = 69.69;
            wiring.Quantity = 69;

            templates.MiscCostTemplates.Add(wiring);

            //Panel Types
            TECPanelType panelType = new TECPanelType(testMan);

            panelType.Price = 123.4;
            panelType.Name  = "Test Panel Type";

            templates.Catalogs.PanelTypes.Add(panelType);

            //Panels
            TECPanel panel = new TECPanel(panelType, false);

            panel.Name = "Test Panel";
            panel.AssociatedCosts.Add(testAssociatedCost);
            panel.AssociatedCosts.Add(testAssociatedCost);

            TECPanel controlledPanel = new TECPanel(panelType, false);

            controlledPanel.Name = "Controlled Panel";

            templates.PanelTemplates.Add(panel);

            //Synchronizer
            TemplateSynchronizer <TECEquipment> equipSynchronizer = templates.EquipmentSynchronizer;
            TemplateSynchronizer <TECSubScope>  ssSynchronizer    = templates.SubScopeSynchronizer;

            TECSystem syncSys = new TECSystem(false);

            syncSys.Name = "Sync System";
            templates.SystemTemplates.Add(syncSys);

            TECEquipment syncEquip = new TECEquipment(false);

            syncEquip.Name = "Sync Equip";
            templates.EquipmentTemplates.Add(syncEquip);
            syncSys.Equipment.Add(equipSynchronizer.NewItem(syncEquip));

            TECSubScope syncSubScope = new TECSubScope(false);

            syncSubScope.Name = "Sync SS";
            templates.SubScopeTemplates.Add(syncSubScope);
            syncEquip.SubScope.Add(ssSynchronizer.NewItem(syncSubScope));

            return(templates);
        }