예제 #1
0
        public static TECScopeTemplates TestScopeTemplates(TECCatalogs catalogs, Random rand)
        {
            TECScopeTemplates templates = new TECScopeTemplates();

            //Parameters
            rand.RepeatAction(() => templates.Parameters.Add(TestParameters(rand)), 5);

            //Systems
            rand.RepeatAction(() => templates.SystemTemplates.Add(TestSystem(catalogs, rand)), 10);

            //Equipment
            rand.RepeatAction(() => templates.EquipmentTemplates.Add(TestEquipment(catalogs, rand)), 10);

            //SubScope
            rand.RepeatAction(() => templates.SubScopeTemplates.Add(TestSubScope(catalogs, rand)), 10);

            //Controllers
            rand.RepeatAction(() => templates.ControllerTemplates.Add(TestProvidedController(catalogs, rand)), 10);

            //Misc Costs
            rand.RepeatAction(() => templates.MiscCostTemplates.Add(TestMisc(catalogs, rand, CostType.TEC)), 10);
            rand.RepeatAction(() => templates.MiscCostTemplates.Add(TestMisc(catalogs, rand, CostType.Electrical)), 10);

            //Panels
            rand.RepeatAction(() => templates.PanelTemplates.Add(TestPanel(catalogs, rand)), 10);

            return(templates);
        }
예제 #2
0
        public void LinkExistingTest()
        {
            //Arrange
            TECScopeTemplates templates = new TECScopeTemplates();

            TemplateSynchronizer <TECSubScope> synchronizer =
                new TemplateSynchronizer <TECSubScope>(copySubScope, item => { }, syncSubScope, templates);

            TECSubScope templateSS = new TECSubScope();

            templateSS.Name = "Template SubScope";

            List <TECSubScope> newReferenceSS = new List <TECSubScope>();

            newReferenceSS.Add(new TECSubScope());
            newReferenceSS.Add(new TECSubScope());

            //Act
            synchronizer.LinkExisting(templateSS, newReferenceSS);
            templateSS.Description = "Test Description";

            //Assert
            foreach (TECSubScope refSS in newReferenceSS)
            {
                Assert.AreEqual(templateSS.Description, refSS.Description);
            }
        }
예제 #3
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.");
        }
예제 #4
0
        public void NewItemNoGroupTest()
        {
            //Arrange
            TECScopeTemplates templates = new TECScopeTemplates();

            TemplateSynchronizer <TECSubScope> synchronizer =
                new TemplateSynchronizer <TECSubScope>(copySubScope, item => { }, syncSubScope, templates);

            TECSubScope templateSS = new TECSubScope();

            templateSS.Name = "Template SubScope";

            //Act
            TECSubScope copySS = synchronizer.NewItem(templateSS);

            //Assert
            Assert.AreEqual(templateSS.Name, copySS.Name);
            Assert.AreNotEqual(templateSS.Guid, copySS.Guid);
        }
예제 #5
0
        public void ChangeInstanceTest()
        {
            //Arrange
            TECScopeTemplates templates = new TECScopeTemplates();

            TemplateSynchronizer <TECSubScope> synchronizer =
                new TemplateSynchronizer <TECSubScope>(copySubScope, item => { }, syncSubScope, templates);

            TECSubScope templateSS = new TECSubScope();

            templateSS.Name = "Template SubScope";

            TECSubScope copySS = synchronizer.NewItem(templateSS);

            //Act
            copySS.Description = "Test Description";

            //Assert
            Assert.AreEqual(templateSS.Description, copySS.Description);
        }