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); }