public void SaveNew_Templates_SubScope()
        {
            //Arrange
            IEndDevice      actualChildDevice = actualSubScope.Devices[0];
            TECPoint        actualSSPoint     = actualSubScope.Points[0];
            TECManufacturer actualChildMan    = (actualChildDevice as TECHardware).Manufacturer;

            IEndDevice      expectedChildDevice = expectedSubScope.Devices.First(x => x.Guid == actualChildDevice.Guid);
            TECPoint        expectedSSPoint     = expectedSubScope.Points.First(x => x.Guid == actualSSPoint.Guid);
            TECManufacturer expectedChildMan    = (expectedChildDevice as TECHardware).Manufacturer;

            //Assert
            Assert.AreEqual(expectedSubScope.Name, actualSubScope.Name);
            Assert.AreEqual(expectedSubScope.Description, actualSubScope.Description);
            Assert.AreEqual(expectedSubScope.Tags[0].Label, actualSubScope.Tags[0].Label);
            Assert.AreEqual(expectedSubScope.AssociatedCosts[0].Name, actualSubScope.AssociatedCosts[0].Name);

            Assert.AreEqual(expectedChildDevice.Name, actualChildDevice.Name);
            Assert.AreEqual(expectedChildDevice.Description, actualChildDevice.Description);
            Assert.AreEqual((expectedChildDevice as TECHardware).Cost, (actualChildDevice as TECHardware).Cost, DELTA);
            Assert.IsTrue(expectedChildDevice.HardwiredConnectionTypes.Any(x => x.Guid == actualChildDevice.HardwiredConnectionTypes[0].Guid));
            Assert.AreEqual((expectedChildDevice as TECHardware).Tags[0].Label, (actualChildDevice as TECHardware).Tags[0].Label);

            Assert.AreEqual(expectedSSPoint.Label, actualSSPoint.Label);
            Assert.AreEqual(expectedSSPoint.Quantity, actualSSPoint.Quantity);
            Assert.AreEqual(expectedSSPoint.Type, actualSSPoint.Type);

            Assert.AreEqual(expectedChildMan.Label, actualChildMan.Label);
            Assert.AreEqual(expectedChildMan.Multiplier, actualChildMan.Multiplier, DELTA);
        }
Exemplo n.º 2
0
        public DeleteEndDeviceVM(IEndDevice endDevice, TECTemplates templates)
        {
            messageBox            = new MessageBoxService();
            this.templates        = templates;
            this.EndDevice        = endDevice;
            PotentialReplacements = new List <IEndDevice>();
            populatePotentialReplacements();

            DeleteCommand           = new RelayCommand(deleteExecute);
            DeleteAndReplaceCommand = new RelayCommand(deleteAndReplaceExecute, deleteAndReplaceCanExecute);
        }
Exemplo n.º 3
0
 private bool hasRequiredProtocols(IEndDevice device, IEnumerable <IProtocol> protocols)
 {
     foreach (IProtocol protocol in protocols)
     {
         if (!device.ConnectionMethods.Contains(protocol))
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 4
0
 public bool CanChangeDevice(IEndDevice oldDevice, IEndDevice newDevice)
 {
     if (this.Connection == null)
     {
         return(true);
     }
     if (Connection.Protocol is TECProtocol && newDevice.ConnectionMethods.Contains(Connection.Protocol))
     {
         return(true);
     }
     else if (Connection.Protocol is TECHardwiredProtocol &&
              oldDevice.HardwiredConnectionTypes.SequenceEqual(newDevice.HardwiredConnectionTypes))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 5
0
 public bool AddDevice(IEndDevice device)
 {
     if (this.Connection == null)
     {
         this.Devices.Add(device);
         return(true);
     }
     else
     {
         if (Connection.Protocol is TECProtocol && device.ConnectionMethods.Contains(Connection.Protocol))
         {
             this.Devices.Add(device);
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 6
0
 public bool RemoveDevice(IEndDevice device)
 {
     return(Devices.Remove(device));
 }
Exemplo n.º 7
0
 private void deleteDeviceExecute(IEndDevice obj)
 {
     SelectedSubScope.RemoveDevice(obj);
 }
Exemplo n.º 8
0
 private bool canDeleteDevice(IEndDevice arg)
 {
     return(true);
 }
 private void deleteDeviceExecute(IEndDevice device)
 {
     toAdd.RemoveDevice(device);
 }
Exemplo n.º 10
0
        private static (int nextRow, int nextColumn) addEndDeviceRow(IXLWorksheet worksheet, IEndDevice endDevice, int startRow, int startColumn)
        {
            int    x = startRow;
            int    y = startColumn;
            string connectionString = "";

            foreach (IProtocol protocol in endDevice.ConnectionMethods)
            {
                foreach (TECConnectionType type in protocol.ConnectionTypes.Distinct())
                {
                    connectionString += String.Format("({0} Qty. {1})", type.Name,
                                                      protocol.ConnectionTypes.Count(item => item == type));
                }
            }
            worksheet.Cell(x, y).Value = connectionString;
            return(x + 1, y + 1);
        }