Ejemplo n.º 1
0
        public void GetConnectablesTest()
        {
            TECSystem    system    = new TECSystem();
            TECEquipment equipment = new TECEquipment();

            system.Equipment.Add(equipment);
            TECSubScope first  = new TECSubScope();
            TECSubScope second = new TECSubScope();

            equipment.SubScope.Add(first);
            equipment.SubScope.Add(second);
            TECProvidedController controller = new TECProvidedController(new TECControllerType(new TECManufacturer()));

            system.AddController(controller);

            var connectables = ConnectionHelper.GetConnectables(system, obj => true);

            Assert.IsTrue(connectables.Count == 3);
            Assert.IsTrue(connectables.Contains(first));
            Assert.IsTrue(connectables.Contains(second));
            Assert.IsTrue(connectables.Contains(controller));

            connectables = ConnectionHelper.GetConnectables(system, obj => obj is TECSubScope);

            Assert.IsTrue(connectables.Count == 2);
            Assert.IsTrue(connectables.Contains(first));
            Assert.IsTrue(connectables.Contains(second));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        public void InstanceSubScopeRemovedFromReferenceEquipment()
        {
            //Arrange
            TECTemplates templates = new TECTemplates();
            TemplateSynchronizer <TECEquipment> equipSynchronizer = templates.EquipmentSynchronizer;
            TemplateSynchronizer <TECSubScope>  ssSynchronizer    = templates.SubScopeSynchronizer;

            TECEquipment templateEquip = new TECEquipment();

            templates.Templates.EquipmentTemplates.Add(templateEquip);

            TECSubScope ss = new TECSubScope();

            templateEquip.SubScope.Add(ss);

            TECEquipment refEqiup = equipSynchronizer.NewItem(templateEquip);
            TECSubScope  refSS    = refEqiup.SubScope[0];

            //Act
            refEqiup.SubScope.Remove(refSS);

            //Assert
            Assert.IsTrue(templateEquip.SubScope.Count == 0, "SubScope not removed properly from Equipment template.");

            Assert.IsFalse(ssSynchronizer.Contains(ss), "SubScope was not removed properly from synchronizer.");
            Assert.IsFalse(ssSynchronizer.Contains(refSS), "Reference SubScope was not removed properly from synchronizer.");
        }
Ejemplo n.º 4
0
 public static void ConnectEquipmentToController(TECEquipment equipment, TECController controller)
 {
     foreach (TECSubScope subscope in equipment.SubScope)
     {
         controller.Connect(subscope, (subscope as IConnectable).AvailableProtocols.First());
     }
 }
Ejemplo n.º 5
0
        private string getTemplateText(TECObject item)
        {
            TECTemplates templates = ScopeManager as TECTemplates;

            if (templates.IsTemplateObject(item))
            {
                string parentString = "";
                if (item is TECSubScope subScope)
                {
                    TECSubScope parent = templates.SubScopeSynchronizer.GetParent(subScope);
                    if (item != parent && parent != null)
                    {
                        parentString = String.Format(" of {0}",
                                                     parent.Name);
                    }
                }
                else if (item is TECEquipment equipment)
                {
                    TECEquipment parent = templates.EquipmentSynchronizer.GetParent(equipment);
                    if (item != parent && parent != null)
                    {
                        parentString = String.Format(" of {0}",
                                                     parent.Name);
                    }
                }

                return(String.Format("Reference{0}",
                                     parentString));
            }
            return("Instance Template");
        }
Ejemplo n.º 6
0
 private void addExecute()
 {
     for (int x = 0; x < Quantity; x++)
     {
         TECEquipment equipment = null;
         if (AsReference && underlyingTemplate != null)
         {
             equipment = templates.EquipmentSynchronizer.NewItem(underlyingTemplate);
         }
         else if (underlyingTemplate != null)
         {
             if (templates != null)
             {
                 equipment = new TECEquipment(underlyingTemplate, ssSynchronizer: templates.SubScopeSynchronizer);
             }
             else
             {
                 equipment = new TECEquipment(underlyingTemplate);
             }
         }
         else
         {
             equipment = new TECEquipment(ToAdd);
         }
         equipment.CopyPropertiesFromScope(ToAdd);
         add(equipment);
         if (ConnectVM != null && ConnectVM.Connect)
         {
             ConnectVM.ExecuteConnection(equipment.SubScope);
         }
         Added?.Invoke(equipment);
     }
 }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        public void TemplateEquipmentRemoved()
        {
            //Arrange
            TECTemplates templates = new TECTemplates();
            TemplateSynchronizer <TECEquipment> synchronizer = templates.EquipmentSynchronizer;

            TECEquipment templateEquip = new TECEquipment();

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

            TECSystem templateSys = new TECSystem();

            templates.Templates.SystemTemplates.Add(templateSys);
            TECEquipment equip1 = synchronizer.NewItem(templateEquip);
            TECEquipment equip2 = synchronizer.NewItem(templateEquip);

            templateSys.Equipment.Add(equip1);
            templateSys.Equipment.Add(equip2);

            //Act
            templates.Templates.EquipmentTemplates.Remove(templateEquip);

            equip2.Name = "Second Name";

            //Assert
            Assert.IsFalse(synchronizer.Contains(templateEquip));
            Assert.IsFalse(synchronizer.Contains(equip1));
            Assert.IsFalse(synchronizer.Contains(equip2));
            Assert.AreEqual("First Name", equip1.Name);
            Assert.AreEqual("Second Name", equip2.Name);
        }
Ejemplo n.º 10
0
        public void TemplatedSubScopeRemovedFromTemplateEquipment()
        {
            //Arrange
            TECTemplates templates = new TECTemplates();
            TemplateSynchronizer <TECEquipment> equipSynchronizer = templates.EquipmentSynchronizer;
            TemplateSynchronizer <TECSubScope>  ssSynchronizer    = templates.SubScopeSynchronizer;

            TECEquipment templateEquip = new TECEquipment();

            templates.Templates.EquipmentTemplates.Add(templateEquip);

            TECSubScope templateSS = new TECSubScope();

            templates.Templates.SubScopeTemplates.Add(templateSS);

            TECSubScope instanceSS = ssSynchronizer.NewItem(templateSS);

            templateEquip.SubScope.Add(instanceSS);

            TECEquipment instanceEquip = equipSynchronizer.NewItem(templateEquip);

            templates.Templates.EquipmentTemplates.Add(instanceEquip);

            //Act
            templateEquip.SubScope.Remove(instanceSS);

            //Assert
            Assert.IsTrue(instanceEquip.SubScope.Count == 0, "SubScope not removed properly from equipment reference.");

            Assert.IsFalse(ssSynchronizer.Contains(instanceSS), "Reference SubScope not removed properly from synchronizer.");
            Assert.IsTrue(ssSynchronizer.Contains(templateSS), "Template SubScope was removed from synchronizer when it shouldn't have been.");
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        public void TemplateSubScopeRemoved()
        {
            //Arrange
            TECTemplates templates = new TECTemplates();
            TemplateSynchronizer <TECSubScope> synchronizer = templates.SubScopeSynchronizer;

            TECSubScope templateSS = new TECSubScope();

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

            TECEquipment templateEquip = new TECEquipment();

            templates.Templates.EquipmentTemplates.Add(templateEquip);
            TECSubScope ss1 = synchronizer.NewItem(templateSS);
            TECSubScope ss2 = synchronizer.NewItem(templateSS);

            templateEquip.SubScope.Add(ss1);
            templateEquip.SubScope.Add(ss2);

            //Act
            templates.Templates.SubScopeTemplates.Remove(templateSS);

            ss2.Name = "Second Name";

            //Assert
            Assert.IsFalse(synchronizer.Contains(templateSS));
            Assert.IsFalse(synchronizer.Contains(ss1));
            Assert.IsFalse(synchronizer.Contains(ss2));
            Assert.AreEqual("First Name", ss1.Name);
            Assert.AreEqual("Second Name", ss2.Name);
        }
Ejemplo n.º 13
0
        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");
        }
Ejemplo n.º 14
0
        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 Undo_Template_System_Equipment()
        {
            //Arrange
            var Template = ModelCreation.TestTemplates(rand);
            var system   = Template.Templates.SystemTemplates[0];
            ObservableCollection <TECEquipment> expected = new ObservableCollection <TECEquipment>();

            foreach (TECEquipment item in system.Equipment)
            {
                expected.Add(item);
            }
            TECEquipment edit = new TECEquipment();

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

            system.Equipment.Add(edit);
            Assert.AreEqual(1, testStack.UndoCount(), "Not added to undo stack");
            testStack.Undo();

            //assert
            var actual = system.Equipment;

            Assert.AreEqual(expected.Count, actual.Count, "Not Undone");
        }
Ejemplo n.º 16
0
 private static void linkEquipmentToCatalogs(TECEquipment equip, TECCatalogs catalogs)
 {
     linkScopeChildrenToCatalogs(equip, catalogs);
     foreach (TECSubScope subScope in equip.SubScope)
     {
         linkSubScopeToCatalogs(subScope, catalogs);
     }
 }
Ejemplo n.º 17
0
 private void addSubScopeExecute(TECEquipment equipment)
 {
     SelectedVM = new AddSubScopeVM(equipment, scopeManager);
     (SelectedVM as AddVM).Added = subScope =>
     {
         SelectedSubScope = subScope as TECSubScope;
     };
 }
Ejemplo n.º 18
0
 public AddEquipmentVM(Action <TECEquipment> addMethod, TECScopeManager scopeManager) : base(scopeManager)
 {
     toAdd      = new TECEquipment();
     add        = addMethod;
     AddCommand = new RelayCommand(addExecute, addCanExecute);
     Quantity   = 1;
     PropertiesVM.DisplayReferenceProperty = false;
 }
Ejemplo n.º 19
0
 private static void linkLocation(TECEquipment equipment, IEnumerable <TECLocation> locations)
 {
     linkLocation(equipment as TECLocated, locations);
     foreach (TECSubScope ss in equipment.SubScope)
     {
         linkLocation(ss, locations);
     }
 }
Ejemplo n.º 20
0
        public static TECEquipment TestEquipment(TECCatalogs catalogs, Random rand)
        {
            TECEquipment equip = new TECEquipment();

            equip.Description = "Test Equipment";
            equip.AssignRandomScopeProperties(catalogs, rand);
            rand.RepeatAction(() => equip.SubScope.Add(TestSubScope(catalogs, rand)), 5);
            return(equip);
        }
Ejemplo n.º 21
0
 public static void LinkScopeItem(TECEquipment scope, TECBid bid)
 {
     linkScopeChildrenToCatalogs(scope, bid.Catalogs);
     linkLocation(scope, bid.Locations);
     foreach (TECSubScope ss in scope.SubScope)
     {
         LinkScopeItem(ss, bid);
     }
 }
Ejemplo n.º 22
0
        public void DeleteDeviceUserInputNo()
        {
            //Arrange
            TECTemplates      templatesManager = new TECTemplates();
            TECScopeTemplates templates        = templatesManager.Templates;

            TECManufacturer man = new TECManufacturer();

            templatesManager.Catalogs.Add(man);

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

            templatesManager.Catalogs.Add(dev);

            TECSystem sys = new TECSystem();

            templates.SystemTemplates.Add(sys);
            TECEquipment sysEquip = new TECEquipment();

            sys.Equipment.Add(sysEquip);
            TECSubScope sysSS = new TECSubScope();

            sysEquip.SubScope.Add(sysSS);
            sysSS.Devices.Add(dev);

            TECEquipment equip = new TECEquipment();

            templates.EquipmentTemplates.Add(equip);
            TECSubScope equipSS = new TECSubScope();

            equip.SubScope.Add(equipSS);
            equipSS.Devices.Add(dev);

            TECSubScope ss = new TECSubScope();

            templates.SubScopeTemplates.Add(ss);
            ss.Devices.Add(dev);

            //Act
            Mock <IUserConfirmable> mockMessageBox = new Mock <IUserConfirmable>();

            mockMessageBox
            .Setup(x => x.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>()))
            .Returns(MessageBoxResult.No);

            DeleteEndDeviceVM vm = new DeleteEndDeviceVM(dev, templatesManager);

            vm.messageBox = mockMessageBox.Object;
            vm.DeleteCommand.Execute(null);

            //Assert
            Assert.IsTrue(templatesManager.Catalogs.Devices.Contains(dev), "Device not removed from device templates properly.");
            Assert.IsTrue(sysSS.Devices.Contains(dev), "Device not removed from system template properly.");
            Assert.IsTrue(equipSS.Devices.Contains(dev), "Device not removed from equipment template properly.");
            Assert.IsTrue(ss.Devices.Contains(dev), "Device not removed from subscope template properly.");
        }
Ejemplo n.º 23
0
 public AddSubScopeVM(TECEquipment parentEquipment, TECScopeManager scopeManager) : base(scopeManager)
 {
     parent = parentEquipment;
     toAdd  = new TECSubScope();
     add    = subScope =>
     {
         parent.SubScope.Add(subScope);
     };
     setup();
 }
Ejemplo n.º 24
0
        public void RemoveEquipmentTest()
        {
            TECSystem    system    = new TECSystem();
            TECEquipment equipment = new TECEquipment();

            system.Equipment.Add(equipment);
            system.ProposalItems.Add(new TECProposalItem(equipment));

            system.Equipment.Remove(equipment);
            Assert.IsTrue(system.ProposalItems.Count == 0);
        }
Ejemplo n.º 25
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.");
        }
Ejemplo n.º 26
0
 public void SetTemplate(TECEquipment template)
 {
     underlyingTemplate = template;
     ToAdd = new TECEquipment(template);
     if (IsTemplates)
     {
         DisplayReferenceProperty = true;
     }
     if (ConnectVM != null)
     {
         ConnectVM.Update(ToAdd.SubScope);
     }
 }
        public void SaveNew_Templates_System()
        {
            //Arrange
            TECEquipment    expectedSysEquipment = expectedSystem.Equipment.First();
            TECSubScope     expectedSysSubScope  = expectedSysEquipment.SubScope.First();
            TECDevice       expectedChildDevice  = expectedSysSubScope.Devices[0] as TECDevice;
            TECPoint        expectedSysPoint     = expectedSysSubScope.Points.First();
            TECManufacturer expectedChildMan     = expectedChildDevice.Manufacturer;

            TECEquipment    actualSysEquipment = actualSystem.Equipment.First(item => item.Guid == expectedSysEquipment.Guid);
            TECSubScope     actualSysSubScope  = actualSysEquipment.SubScope.First(item => item.Guid == expectedSysSubScope.Guid);
            TECDevice       actualChildDevice  = actualSysSubScope.Devices[0] as TECDevice;
            TECPoint        actualSysPoint     = actualSysSubScope.Points.First(item => item.Guid == expectedSysPoint.Guid);
            TECManufacturer actualChildMan     = actualChildDevice.Manufacturer;

            //Assert
            Assert.AreEqual(expectedSystem.Name, actualSystem.Name);
            Assert.AreEqual(expectedSystem.Description, actualSystem.Description);
            Assert.AreEqual(expectedSystem.Tags[0].Label, actualSystem.Tags[0].Label);

            Assert.AreEqual(expectedSysEquipment.Name, actualSysEquipment.Name);
            Assert.AreEqual(expectedSysEquipment.Description, actualSysEquipment.Description);
            Assert.AreEqual(expectedSysEquipment.Tags[0].Label, actualSysEquipment.Tags[0].Label);

            Assert.AreEqual(expectedSysSubScope.Name, actualSysSubScope.Name);
            Assert.AreEqual(expectedSysSubScope.Description, actualSysSubScope.Description);
            Assert.AreEqual(expectedSysSubScope.Tags[0].Label, actualSysSubScope.Tags[0].Label);

            Assert.AreEqual(expectedChildDevice.Name, actualChildDevice.Name);
            Assert.AreEqual(expectedChildDevice.Description, actualChildDevice.Description);
            Assert.AreEqual(expectedChildDevice.Cost, actualChildDevice.Cost, DELTA);
            Assert.AreEqual(expectedChildDevice.HardwiredConnectionTypes[0].Guid, actualChildDevice.HardwiredConnectionTypes[0].Guid);
            Assert.AreEqual(expectedChildDevice.Tags[0].Label, actualChildDevice.Tags[0].Label);

            Assert.AreEqual(expectedSysPoint.Label, actualSysPoint.Label);
            Assert.AreEqual(expectedSysPoint.Quantity, actualSysPoint.Quantity);
            Assert.AreEqual(expectedSysPoint.Type, actualSysPoint.Type);

            Assert.AreEqual(expectedChildMan.Label, actualChildMan.Label);
            Assert.AreEqual(expectedChildMan.Multiplier, actualChildMan.Multiplier, DELTA);

            ////Controlled scope tests]
            //TECSystem expectedConScope = expectedSystem;
            //TECSystem actualConScope = actualSystem;
            //Assert.AreEqual(expectedConScope.Name, actualConScope.Name);
            //Assert.AreEqual(expectedConScope.Description, actualConScope.Description);
            //Assert.AreEqual(expectedConScope.Equipment[0].Name, actualConScope.Equipment[0].Name);
            //Assert.AreEqual(expectedConScope.Panels[0].Name, actualConScope.Panels[0].Name);
            //Assert.AreEqual(expectedConScope.Controllers[0].Name, actualConScope.Controllers[0].Name);
            //Assert.AreEqual(42, actualConScope.Controllers[0].ChildrenConnections[0].Length);
        }
        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 void DragDropCopyTest()
        {
            Random       rand  = new Random(0);
            TECBid       bid   = ModelCreation.TestBid(rand);
            TECEquipment equip = ModelCreation.TestEquipment(bid.Catalogs, rand);

            bid.Systems.First().Equipment.Add(equip);

            TECEquipment copy = equip.DropData() as TECEquipment;

            Assert.AreEqual(equip.Name, copy.Name);
            Assert.AreEqual(equip.SubScope.Count, copy.SubScope.Count);
            Assert.IsTrue(equip.CostBatch.CostsEqual(copy.CostBatch));
        }
Ejemplo n.º 30
0
        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();
        }