Пример #1
0
        public void DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver_GetDescription()
        {
            DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver resolver = new DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver(Mock.Of <IDeviceService>(MockBehavior.Strict));

            ScopeResolverDescription description = resolver.GetDescription();

            Assert.NotNull(description);

            Assert.Equal(nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver), description.TypeName);

            Assert.NotNull(description.Properties);
            Assert.Equal(3, description.Properties.Count());

            {
                ScopeResolverPropertyDescription propertyDescription = description.Properties.First();

                Assert.Equal(nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.VlanNumber), propertyDescription.PropertyName);
                Assert.Equal(ScopeResolverPropertyValueTypes.VLANId, propertyDescription.PropertyValueType);
            }
            {
                ScopeResolverPropertyDescription propertyDescription = description.Properties.ElementAt(1);

                Assert.Equal(nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.PortNumber), propertyDescription.PropertyName);
                Assert.Equal(ScopeResolverPropertyValueTypes.Byte, propertyDescription.PropertyValueType);
            }
            {
                ScopeResolverPropertyDescription propertyDescription = description.Properties.ElementAt(2);

                Assert.Equal(nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.DeviceId), propertyDescription.PropertyName);
                Assert.Equal(ScopeResolverPropertyValueTypes.Device, propertyDescription.PropertyValueType);
            }
        }
Пример #2
0
        public void DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver_AreValuesValid_MissingKeys()
        {
            Random random = new Random();

            var mock = new Mock <ISerializer>(MockBehavior.Strict);

            DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver resolver = new DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver(Mock.Of <IDeviceService>(MockBehavior.Strict));

            List <Dictionary <String, String> > invalidInputs = new List <Dictionary <string, string> >
            {
                null,
                new Dictionary <string, string>(),
                new Dictionary <string, string>()
                {
                    { random.GetAlphanumericString(10), random.GetAlphanumericString(10) }
                },
                new Dictionary <string, string>()
                {
                    //{ nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.DeviceId), "ea6a012a-04d9-474c-9ff5-2d9eff61b710" },
                    { nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.PortNumber), "2" },
                    { nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.VlanNumber), "1" },
                },
                new Dictionary <string, string>()
                {
                    { nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.DeviceId), "ea6a012a-04d9-474c-9ff5-2d9eff61b710" },
                    //{ nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.PortNumber), "2" },
                    { nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.VlanNumber), "1" },
                },
                new Dictionary <string, string>()
                {
                    { nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.DeviceId), "ea6a012a-04d9-474c-9ff5-2d9eff61b710" },
                    { nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.PortNumber), "2" },
                    //{ nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.VlanNumber), "1" },
                },
            };

            foreach (var item in invalidInputs)
            {
                Boolean result = resolver.ArePropertiesAndValuesValid(item, mock.Object);
                Assert.False(result);
            }
        }
Пример #3
0
        public void DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver_AreValuesValid_InvalidDeviceId()
        {
            Random random = new Random();

            var mock = new Mock <ISerializer>(MockBehavior.Strict);

            DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver resolver = new DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver(Mock.Of <IDeviceService>(MockBehavior.Strict));

            List <Dictionary <String, String> > invalidInputs = new List <Dictionary <string, string> >
            {
                new Dictionary <string, string>()
                {
                    { nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.DeviceId), "" },
                    { nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.PortNumber), "2" },
                    { nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.VlanNumber), "1" },
                },
                new Dictionary <string, string>()
                {
                    { nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.DeviceId), null },
                    { nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.PortNumber), "2" },
                    { nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.VlanNumber), "1" },
                },
                new Dictionary <string, string>()
                {
                    { nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.DeviceId), "eb2d5f55-414e-4ff0-86c6-b886c70aae6" },
                    { nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.PortNumber), "2" },
                    { nameof(DeviceBasedDHCPv4SimpleCiscoSGSeriesResolver.VlanNumber), "1" },
                },
            };

            foreach (var item in invalidInputs)
            {
                Boolean result = resolver.ArePropertiesAndValuesValid(item, mock.Object);
                Assert.False(result);
            }
        }