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); } }
public void DeviceBasedDHCPv4SimpleZyxelIESResolver_GetDescription() { var resolver = new DeviceBasedDHCPv4SimpleZyxelIESResolver(Mock.Of <IDeviceService>()); ScopeResolverDescription description = resolver.GetDescription(); Assert.NotNull(description); Assert.Equal(nameof(DeviceBasedDHCPv4SimpleZyxelIESResolver), description.TypeName); Assert.NotNull(description.Properties); Assert.Equal(3, description.Properties.Count()); { ScopeResolverPropertyDescription propertyDescription = description.Properties.First(); Assert.Equal(nameof(DeviceBasedDHCPv4SimpleZyxelIESResolver.LinecardNumber), propertyDescription.PropertyName); Assert.Equal(ScopeResolverPropertyValueTypes.Byte, propertyDescription.PropertyValueType); } { ScopeResolverPropertyDescription propertyDescription = description.Properties.ElementAt(1); Assert.Equal(nameof(DeviceBasedDHCPv4SimpleZyxelIESResolver.PortNumber), propertyDescription.PropertyName); Assert.Equal(ScopeResolverPropertyValueTypes.Byte, propertyDescription.PropertyValueType); } { ScopeResolverPropertyDescription propertyDescription = description.Properties.ElementAt(2); Assert.Equal(nameof(DeviceBasedDHCPv4SimpleZyxelIESResolver.DeviceId), propertyDescription.PropertyName); Assert.Equal(ScopeResolverPropertyValueTypes.Device, propertyDescription.PropertyValueType); } }
public void DHCPv4SimpleCiscoSGSeriesResolver_GetDescription() { DHCPv4SimpleCiscoSGSeriesResolver resolver = new DHCPv4SimpleCiscoSGSeriesResolver(); ScopeResolverDescription description = resolver.GetDescription(); Assert.NotNull(description); Assert.Equal(nameof(DHCPv4SimpleCiscoSGSeriesResolver), description.TypeName); Assert.NotNull(description.Properties); Assert.Equal(3, description.Properties.Count()); { ScopeResolverPropertyDescription propertyDescription = description.Properties.First(); Assert.Equal(nameof(DHCPv4SimpleCiscoSGSeriesResolver.VlanNumber), propertyDescription.PropertyName); Assert.Equal(ScopeResolverPropertyValueTypes.VLANId, propertyDescription.PropertyValueType); } { ScopeResolverPropertyDescription propertyDescription = description.Properties.ElementAt(1); Assert.Equal(nameof(DHCPv4SimpleCiscoSGSeriesResolver.PortNumber), propertyDescription.PropertyName); Assert.Equal(ScopeResolverPropertyValueTypes.Byte, propertyDescription.PropertyValueType); } { ScopeResolverPropertyDescription propertyDescription = description.Properties.ElementAt(2); Assert.Equal(nameof(DHCPv4SimpleCiscoSGSeriesResolver.DeviceMacAddress), propertyDescription.PropertyName); Assert.Equal(ScopeResolverPropertyValueTypes.ByteArray, propertyDescription.PropertyValueType); } }
public void DHCPv4RelayAgentSubnetResolver_GetDescription() { List <ScopeResolverPropertyDescription> expectedDescriptions = new List <ScopeResolverPropertyDescription> { new ScopeResolverPropertyDescription("Mask", ScopeResolverPropertyValueTypes.IPv4Subnetmask), new ScopeResolverPropertyDescription("NetworkAddress", ScopeResolverPropertyValueTypes.IPv4Address), }; DHCPv4RelayAgentSubnetResolver resolver = new DHCPv4RelayAgentSubnetResolver(); ScopeResolverDescription description = resolver.GetDescription(); Assert.NotNull(description); Assert.Equal("DHCPv4RelayAgentSubnetResolver", description.TypeName); Assert.NotNull(description.Properties); Assert.Equal(expectedDescriptions.Count, description.Properties.Count()); foreach (var item in description.Properties) { ScopeResolverPropertyDescription expectedDescription = expectedDescriptions.FirstOrDefault(x => x.PropertyName == item.PropertyName); Assert.NotNull(expectedDescription); Assert.Equal(expectedDescription.PropertyValueType, item.PropertyValueType); Assert.Equal(expectedDescription.PropertyName, item.PropertyName); expectedDescriptions.Remove(expectedDescription); } Assert.Empty(expectedDescriptions); }
public void GetDescription() { var expected = new ScopeResolverDescription("DHCPv6RelayAgentResolver", new[] { new ScopeResolverPropertyDescription("RelayAgentAddress", ScopeResolverPropertyDescription.ScopeResolverPropertyValueTypes.IPv6Address), }); var resolver = new DHCPv6RelayAgentResolver(); var actual = resolver.GetDescription(); Assert.Equal(expected, actual); }
public void GetDescription() { var expected = new ScopeResolverDescription("DeviceBasedDHCPv6ClientDUIDResolver", new[] { new ScopeResolverPropertyDescription("DeviceId", ScopeResolverPropertyDescription.ScopeResolverPropertyValueTypes.Device), }); var resolver = new DeviceBasedDHCPv6ClientDUIDResolver(Mock.Of <IDeviceService>(MockBehavior.Strict)); var actual = resolver.GetDescription(); Assert.Equal(expected, actual); }
public void GetDescription() { var expected = new ScopeResolverDescription("DHCPv6ClientDUIDResolver", new[] { new ScopeResolverPropertyDescription("ClientDuid", ScopeResolverPropertyDescription.ScopeResolverPropertyValueTypes.ByteArray), }); var resolver = new DHCPv6ClientDUIDResolver(); var actual = resolver.GetDescription(); Assert.Equal(expected, actual); }
public void GetDescription() { var expected = new ScopeResolverDescription("DHCPv6PeerAddressResolver", new[] { new ScopeResolverPropertyDescription("IsUnique", ScopeResolverPropertyDescription.ScopeResolverPropertyValueTypes.Boolean), new ScopeResolverPropertyDescription("PeerAddress", ScopeResolverPropertyDescription.ScopeResolverPropertyValueTypes.IPv6Address), }); var resolver = new DHCPv6PeerAddressResolver(); var actual = resolver.GetDescription(); Assert.Equal(expected, actual); }
public void GetDescription() { var expected = new ScopeResolverDescription("DHCPv6MilegateResolver", new[] { new ScopeResolverPropertyDescription("Value", ScopeResolverPropertyDescription.ScopeResolverPropertyValueTypes.String), new ScopeResolverPropertyDescription("Index", ScopeResolverPropertyDescription.ScopeResolverPropertyValueTypes.UInt32), new ScopeResolverPropertyDescription("IsCaseSenstiveMatch", ScopeResolverPropertyDescription.ScopeResolverPropertyValueTypes.Boolean), }); var resolver = new DHCPv6MilegateResolver(); var actual = resolver.GetDescription(); Assert.Equal(expected, actual); }
public void GetDescription() { var expected = new ScopeResolverDescription("DHCPv6SimpleZyxelIESResolver", new[] { new ScopeResolverPropertyDescription("Index", ScopeResolverPropertyDescription.ScopeResolverPropertyValueTypes.UInt32), new ScopeResolverPropertyDescription("SlotId", ScopeResolverPropertyDescription.ScopeResolverPropertyValueTypes.UInt32), new ScopeResolverPropertyDescription("PortId", ScopeResolverPropertyDescription.ScopeResolverPropertyValueTypes.UInt32), new ScopeResolverPropertyDescription("DeviceMacAddress", ScopeResolverPropertyDescription.ScopeResolverPropertyValueTypes.ByteArray), }); var resolver = new DHCPv6SimpleZyxelIESResolver(); var actual = resolver.GetDescription(); Assert.Equal(expected, actual); }
public IEnumerable <ScopeResolverDescription> GetRegisterResolverDescription() { List <ScopeResolverDescription> result = new List <ScopeResolverDescription>(); foreach (var item in _resolverMapper) { IScopeResolver <TPacket, TAddress> resolver = item.Value(); ScopeResolverDescription resolverDescription = resolver.GetDescription(); result.Add(resolverDescription); } return(result); }
public void GetDescription() { var expected = new ScopeResolverDescription("DeviceBasedDHCPv6SimpleZyxelIESResolver", new[] { new ScopeResolverPropertyDescription("Index", ScopeResolverPropertyDescription.ScopeResolverPropertyValueTypes.UInt32), new ScopeResolverPropertyDescription("SlotId", ScopeResolverPropertyDescription.ScopeResolverPropertyValueTypes.UInt32), new ScopeResolverPropertyDescription("PortId", ScopeResolverPropertyDescription.ScopeResolverPropertyValueTypes.UInt32), new ScopeResolverPropertyDescription("DeviceId", ScopeResolverPropertyDescription.ScopeResolverPropertyValueTypes.Device), }); var resolver = new DeviceBasedDHCPv6SimpleZyxelIESResolver(Mock.Of <IDeviceService>(MockBehavior.Strict)); var actual = resolver.GetDescription(); Assert.Equal(expected, actual); }
protected void TestDescription(IScopeResolver <DHCPv6Packet, IPv6Address> resolver, String expectedName) { ScopeResolverDescription description = resolver.GetDescription(); Assert.NotNull(description); Assert.Equal(expectedName, description.TypeName); Assert.NotNull(description.Properties); Assert.Single(description.Properties); ScopeResolverPropertyDescription propertyDescription = description.Properties.First(); Assert.Equal("InnerResolvers", propertyDescription.PropertyName); Assert.Equal(ScopeResolverPropertyValueTypes.Resolvers, propertyDescription.PropertyValueType); }
public void DHCPv4RelayAgentResolver_GetDescription() { DHCPv4RelayAgentResolver resolver = new DHCPv4RelayAgentResolver(); ScopeResolverDescription description = resolver.GetDescription(); Assert.NotNull(description); Assert.Equal(nameof(DHCPv4RelayAgentResolver), description.TypeName); Assert.NotNull(description.Properties); Assert.Single(description.Properties); ScopeResolverPropertyDescription propertyDescription = description.Properties.First(); Assert.Equal(nameof(DHCPv4RelayAgentResolver.AgentAddresses), propertyDescription.PropertyName); Assert.Equal(ScopeResolverPropertyValueTypes.IPv4AddressList, propertyDescription.PropertyValueType); }
public void GetRegisterResolver_Default() { DHCPv6ScopeResolverManager manager = new DHCPv6ScopeResolverManager( Mock.Of <ISerializer>(MockBehavior.Strict), Mock.Of <IDeviceService>(MockBehavior.Strict), Mock.Of <ILogger <DHCPv6ScopeResolverManager> >()); List <ScopeResolverDescription> descriptions = new List <ScopeResolverDescription> { //new DHCPv6AndResolver().GetDescription(), //new DHCPv6OrResolver().GetDescription(), new DHCPv6PseudoResolver().GetDescription(), new DHCPv6RemoteIdentifierEnterpriseNumberResolver(Mock.Of <ILogger <DHCPv6RemoteIdentifierEnterpriseNumberResolver> >()).GetDescription(), new DHCPv6RelayAgentSubnetResolver().GetDescription(), new DHCPv6RelayAgentResolver().GetDescription(), new DHCPv6MilegateResolver().GetDescription(), new DHCPv6PeerAddressResolver().GetDescription(), new DeviceBasedDHCPv6PeerAddressResolver(Mock.Of <IDeviceService>(MockBehavior.Strict)).GetDescription(), new DHCPv6ClientDUIDResolver().GetDescription(), new DeviceBasedDHCPv6ClientDUIDResolver(Mock.Of <IDeviceService>(MockBehavior.Strict)).GetDescription(), new DHCPv6SimpleZyxelIESResolver().GetDescription(), new DeviceBasedDHCPv6SimpleZyxelIESResolver(Mock.Of <IDeviceService>(MockBehavior.Strict)).GetDescription(), }; IEnumerable <ScopeResolverDescription> result = manager.GetRegisterResolverDescription(); Assert.NotNull(result); for (int i = 0; i < descriptions.Count; i++) { ScopeResolverDescription expected = descriptions[i]; ScopeResolverDescription actual = result.ElementAt(i); Assert.Equal(expected, actual); } Assert.Equal(descriptions.Count, result.Count()); }
public void GetRegisterResolver_NonEmpty() { DHCPv6ScopeResolverManager manager = new DHCPv6ScopeResolverManager( Mock.Of <ISerializer>(MockBehavior.Strict), Mock.Of <IDeviceService>(MockBehavior.Strict), Mock.Of <ILogger <DHCPv6ScopeResolverManager> >()); Random random = new Random(); Int32 amount = random.Next(30, 100); List <ScopeResolverDescription> expectedResult = new List <ScopeResolverDescription>(manager.GetRegisterResolverDescription()); for (int i = 0; i < amount; i++) { Mock <IScopeResolver <DHCPv6Packet, IPv6Address> > resolverMock = new Mock <IScopeResolver <DHCPv6Packet, IPv6Address> >(MockBehavior.Strict); ScopeResolverDescription description = new ScopeResolverDescription( $"lower-resolvername-{random.Next()}", new List <ScopeResolverPropertyDescription>() { new ScopeResolverPropertyDescription($"property-name-{random.Next()}", ScopeResolverPropertyValueTypes.UInt32), new ScopeResolverPropertyDescription($"property-name-{random.Next()}", ScopeResolverPropertyValueTypes.NullableUInt32), }); resolverMock.Setup(x => x.GetDescription()).Returns(description); expectedResult.Add(description); manager.AddOrUpdateScopeResolver(description.TypeName, () => resolverMock.Object); } IEnumerable <ScopeResolverDescription> result = manager.GetRegisterResolverDescription(); Assert.NotNull(result); Assert.Equal(expectedResult, result); }