コード例 #1
0
        public void DHCPv4RelayAgentSubnetResolver_AreValuesValid_Valid()
        {
            Random random = new Random();

            String validMaskValue = ((Byte)random.Next(10, 20)).ToString();

            IPv4SubnetMask subnetMask = new IPv4SubnetMask(new IPv4SubnetMaskIdentifier(Convert.ToInt32(validMaskValue)));
            IPv4Address    address    = random.GetIPv4NetworkAddress(subnetMask);

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

            mock.Setup(x => x.Deserialze <String>(validMaskValue)).Returns(subnetMask.GetSlashNotation().ToString());
            mock.Setup(x => x.Deserialze <String>(address.ToString())).Returns(address.ToString());

            DHCPv4RelayAgentSubnetResolver resolver = new DHCPv4RelayAgentSubnetResolver();

            var input = new Dictionary <string, string>()
            {
                { nameof(DHCPv4RelayAgentSubnetResolver.Mask), validMaskValue },
                { nameof(DHCPv4RelayAgentSubnetResolver.NetworkAddress), address.ToString() },
            };

            Boolean result = resolver.ArePropertiesAndValuesValid(input, mock.Object);

            Assert.True(result);
        }
コード例 #2
0
        public void DHCPv4RelayAgentSubnetResolver_PacketMeetsConditions()
        {
            Random random = new Random();

            Int32 maskIdentifier = random.Next(20, 24);

            IPv4SubnetMask mask      = new IPv4SubnetMask(new IPv4SubnetMaskIdentifier(maskIdentifier));
            IPv4Address    addresses = random.GetIPv4NetworkAddress(mask);

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

            serializer.Setup(x => x.Deserialze <String>(mask.GetSlashNotation().ToString())).Returns(mask.GetSlashNotation().ToString());
            serializer.Setup(x => x.Deserialze <String>(addresses.ToString())).Returns(addresses.ToString());

            DHCPv4RelayAgentSubnetResolver resolver = new DHCPv4RelayAgentSubnetResolver();
            Dictionary <String, String>    values   = new Dictionary <String, String>()
            {
                { nameof(DHCPv4RelayAgentSubnetResolver.NetworkAddress), addresses.ToString() },
                { nameof(DHCPv4RelayAgentSubnetResolver.Mask), mask.GetSlashNotation().ToString() },
            };

            resolver.ApplyValues(values, serializer.Object);

            Int32 trys = random.Next(20, 30);

            for (int i = 0; i < trys; i++)
            {
                Boolean     shouldPass = false;
                IPv4Address gwAddress  = IPv4Address.Empty;

                if (random.NextDouble() > 0.5)
                {
                    gwAddress  = random.GetIPv4AddressWithinSubnet(mask, addresses);
                    shouldPass = true;
                }
                else
                {
                    if (random.NextDouble() > 0.5)
                    {
                        gwAddress = random.GetIPv4AddressOutWithSubnet(mask, addresses);
                    }
                }

                DHCPv4Packet packet = new DHCPv4Packet(
                    new IPv4HeaderInformation(random.GetIPv4Address(), random.GetIPv4Address()),
                    random.NextBytes(6),
                    (UInt32)random.Next(),
                    IPv4Address.Empty,
                    gwAddress,
                    IPv4Address.Empty
                    );

                Boolean actual = resolver.PacketMeetsCondition(packet);
                Assert.Equal(shouldPass, actual);
            }
        }
コード例 #3
0
        public void DHCPv4RelayAgentSubnetResolver_ApplyValues()
        {
            Random random                   = new Random();
            String validMaskValue           = ((Byte)random.Next(1, 32)).ToString();
            String validNetworkAddressValue = random.GetIPv4Address().ToString();

            IPv4SubnetMask subnetMask = new IPv4SubnetMask(new IPv4SubnetMaskIdentifier(Convert.ToInt32(validMaskValue)));
            IPv4Address    address    = IPv4Address.FromString(validNetworkAddressValue);

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

            mock.Setup(x => x.Deserialze <String>(validMaskValue)).Returns(subnetMask.GetSlashNotation().ToString());
            mock.Setup(x => x.Deserialze <String>(validNetworkAddressValue)).Returns(address.ToString());

            DHCPv4RelayAgentSubnetResolver resolver = new DHCPv4RelayAgentSubnetResolver();

            var input = new Dictionary <string, string>()
            {
                { nameof(DHCPv4RelayAgentSubnetResolver.Mask), validMaskValue },
                { nameof(DHCPv4RelayAgentSubnetResolver.NetworkAddress), validNetworkAddressValue },
            };

            resolver.ApplyValues(input, mock.Object);

            Assert.Equal(subnetMask, resolver.Mask);
            Assert.Equal(address, resolver.NetworkAddress);
        }
コード例 #4
0
        public void RawRequestPacket()
        {
            DHCPPacketBase p = DHCPPacketFactory.Read(RawData.Request);

            Assert.IsType(typeof(DHCPPacketBootRequest), p);

            IPv4Address expectedIP = new IPv4Address(new byte[] { 0, 0, 0, 0 });

            Assert.True(EHardwareType.Ethernet == p.HardwareAddressType, "Address type wasn't Ethernet");
            Assert.True(6 == p.HardwareAddressLength, "Address length wasn't 6");
            Assert.True(0 == p.Hops, "Hops wasn't 0");
            Assert.True((uint)0x3d1e == p.TransactionID, string.Format("Transaction id was '{0:x}'", p.TransactionID));
            Assert.True(6 == p.HardwareAddressLength, "Address length wasn't 6");
            Assert.True(0 == p.Seconds, "Seconds wasn't 0");
            Assert.True(0 == p.Flags, "Flags wasn't 0");
            Assert.Equal(expectedIP.ToString(), p.ClientAddress.ToString());
            Assert.Equal(expectedIP.ToString(), p.YourAddress.ToString());
            Assert.Equal(expectedIP.ToString(), p.ServerAddress.ToString());
            Assert.Equal(expectedIP.ToString(), p.RelayAgentAddress.ToString());

            HardwareAddress expectedHardwareAddress =
                new HardwareAddress(new MacAddress(new byte[] { 0x00, 0x0b, 0x82, 0x01, 0xfc, 0x42 }));

            byte[] expectedMac = expectedHardwareAddress.Address;
            byte[] actualMac   = p.ClientHardwareAddress.Address;

            for (int i = 0; i < expectedMac.Length; i++)
            {
                byte expected = expectedMac[i];
                byte actual   = actualMac[i];

                Assert.True(
                    expected == actual,
                    string.Format(
                        "Expected: '0x{0:x2}', Actual: '0x{1:x2}' at offset {2}. Expected: {3} Actual: {4}",
                        (byte)expected,
                        (byte)actual,
                        i,
                        expectedHardwareAddress,
                        p.ClientHardwareAddress));
            }

            Assert.Equal(new byte[64], p.ServerHostName);
            Assert.Equal(new byte[128], p.File);
        }
コード例 #5
0
ファイル: A.cs プロジェクト: bpaziaud/Hermod
        /// <summary>
        /// Create a new DNS A resource record.
        /// </summary>
        /// <param name="Name">The DNS name.</param>
        /// <param name="Class">The DNS class.</param>
        /// <param name="TimeToLive">The timestamp when this resource records gets invalidated.</param>
        /// <param name="IPv4Address">The IPv4 address of this resource record.</param>
        public A(String Name,
                 DNSQueryClasses Class,
                 TimeSpan TimeToLive,
                 IPv4Address IPv4Address)

            : base(Name, TypeId, Class, TimeToLive, IPv4Address.ToString())

        {
            this._IPv4Address = IPv4Address;
        }
コード例 #6
0
        public void DHCPv4RelayAgentSubnetResolver_PacketMeetsConditions2(
            String networkAddressInput,
            String maskInput,
            String relayAgentAddressInput,
            Boolean shouldPass
            )
        {
            Random random = new Random();

            IPv4SubnetMask mask           = IPv4SubnetMask.FromString(maskInput);
            IPv4Address    networkAddress = IPv4Address.FromString(networkAddressInput);

            String inputAddressValue = random.GetAlphanumericString(10);
            String inputMaskValue    = random.GetAlphanumericString(10);

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

            serializer.Setup(x => x.Deserialze <String>(mask.GetSlashNotation().ToString())).Returns(mask.GetSlashNotation().ToString());
            serializer.Setup(x => x.Deserialze <String>(networkAddress.ToString())).Returns(networkAddress.ToString());

            DHCPv4RelayAgentSubnetResolver resolver = new DHCPv4RelayAgentSubnetResolver();
            Dictionary <String, String>    values   = new Dictionary <String, String>()
            {
                { nameof(DHCPv4RelayAgentSubnetResolver.NetworkAddress), networkAddress.ToString() },
                { nameof(DHCPv4RelayAgentSubnetResolver.Mask), mask.GetSlashNotation().ToString() },
            };

            resolver.ApplyValues(values, serializer.Object);

            IPv4Address  gwAddress = IPv4Address.FromString(relayAgentAddressInput);
            DHCPv4Packet packet    = new DHCPv4Packet(
                new IPv4HeaderInformation(random.GetIPv4Address(), random.GetIPv4Address()),
                random.NextBytes(6),
                (UInt32)random.Next(),
                IPv4Address.Empty,
                gwAddress,
                IPv4Address.Empty
                );

            Boolean actual = resolver.PacketMeetsCondition(packet);

            Assert.Equal(shouldPass, actual);
        }
コード例 #7
0
ファイル: DHCPPacketTest.cs プロジェクト: raspi/DHCPNet
        public void Raw()
        {
            HardwareAddress ha = new HardwareAddress(new MacAddress(new byte[] { 00, 11, 22, 33, 44, 55 }));

            IPv4Address expectedIP = new IPv4Address(new byte[] { 1, 2, 3, 4 });

            DHCPPacketBase p = new DHCPPacketBootRequest()
            {
                HardwareAddressType = EHardwareType.Ethernet,
                Hops                  = 99,
                TransactionID         = 0x12345678,
                Seconds               = 0xf00f,
                Flags                 = 0,
                ClientAddress         = expectedIP,
                YourAddress           = expectedIP,
                ServerAddress         = expectedIP,
                RelayAgentAddress     = expectedIP,
                ClientHardwareAddress = ha,
                ServerHostName        = new byte[64],
                File                  = new byte[128],
            };

            p.Options = new List <Option>()
            {
                new OptionEnd()
            };

            Assert.Equal(EHardwareType.Ethernet, p.HardwareAddressType);
            Assert.Equal(99, p.Hops);
            Assert.Equal((uint)0x12345678, p.TransactionID);
            Assert.Equal((ushort)0xf00f, p.Seconds);
            Assert.Equal((ushort)0, p.Flags);
            Assert.Equal(expectedIP.ToString(), p.ClientAddress.ToString());
            Assert.Equal(expectedIP.ToString(), p.YourAddress.ToString());
            Assert.Equal(expectedIP.ToString(), p.ServerAddress.ToString());
            Assert.Equal(expectedIP.ToString(), p.RelayAgentAddress.ToString());
            Assert.Equal(ha.Address, p.ClientHardwareAddress.Address);
            Assert.Equal(new byte[64], p.ServerHostName);
            Assert.Equal(new byte[128], p.File);

            Assert.Equal(265, p.GetRawBytes().Length);
        }
コード例 #8
0
        public IPFormatToCidrSubnetmaskQuestion()
        {
            Random r = new Random();

            int randomMask = r.Next(0, 33);

            byte[] bytes   = Subnet.MaskToBytes(randomMask);
            var    netmask = new IPv4Address(new IPAddress(bytes));

            netMaskStr = netmask.ToString();
            CidrStr    = randomMask.ToString();
        }
コード例 #9
0
        /// <summary>Returns a <see cref="System.String" /> that represents this instance.</summary>
        /// <returns>A <see cref="System.String" /> that represents this instance.</returns>
        public override string ToString()
        {
            var l = new List <string>();

            l.Add(NetworkInterface.Name);
            if (!NetworkInterface.MacAddress.IsNullOrEmpty())
            {
                l.Add("MAC: " + NetworkInterface.MacAddress);
            }

            l.Add("IP: " + IPv4Address.ToString());
            if (DnsServer.Any())
            {
                l.Add("DNS: " + DnsServer[0]);
            }

            return(string.Join("; ", l.ToArray()));
        }
コード例 #10
0
 /// <summary>Returns a hash code for this instance.</summary>
 /// <returns>
 /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
 /// </returns>
 public override int GetHashCode()
 {
     return(NetworkInterface.GetHashCode() ^ (IPv4Address.ToString().GetHashCode()));
 }
コード例 #11
0
 public bool Evaluate(string response)
 {
     return(response == net.ToString());
 }
コード例 #12
0
        public async Task Handle(Boolean storeResult, Boolean useDynamicTime)
        {
            Random random = new Random();

            Guid scopeId = random.NextGuid();
            Guid leaseId = random.NextGuid();

            String name        = random.GetAlphanumericString();
            String description = random.GetAlphanumericString();

            IPv4Address start = random.GetIPv4Address();
            IPv4Address end   = start + 100;

            String resolverName = random.GetAlphanumericString();

            Mock <IScopeResolver <DHCPv4Packet, IPv4Address> > resolverMock = new Mock <IScopeResolver <DHCPv4Packet, IPv4Address> >(MockBehavior.Strict);

            resolverMock.Setup(x => x.GetValues()).Returns(new Dictionary <String, String>());

            Mock <IScopeResolverManager <DHCPv4Packet, IPv4Address> > scopeResolverMock = new Mock <IScopeResolverManager <DHCPv4Packet, IPv4Address> >();

            scopeResolverMock.Setup(x => x.IsResolverInformationValid(It.Is <CreateScopeResolverInformation>(y =>
                                                                                                             y.Typename == resolverName
                                                                                                             ))).Returns(true).Verifiable();
            scopeResolverMock.Setup(x => x.InitializeResolver(It.Is <CreateScopeResolverInformation>(y =>
                                                                                                     y.Typename == resolverName
                                                                                                     ))).Returns(resolverMock.Object).Verifiable();

            Mock <ILoggerFactory> factoryMock = new Mock <ILoggerFactory>(MockBehavior.Strict);

            factoryMock.Setup(x => x.CreateLogger(It.IsAny <String>())).Returns(Mock.Of <ILogger <DHCPv4RootScope> >());

            DHCPv4RootScope rootScope = new DHCPv4RootScope(random.NextGuid(), scopeResolverMock.Object, factoryMock.Object);

            rootScope.Load(new DomainEvent[] { new DHCPv4ScopeAddedEvent {
                                                   Instructions = new DHCPv4ScopeCreateInstruction
                                                   {
                                                       Name                = random.GetAlphanumericString(),
                                                       Description         = random.GetAlphanumericString(),
                                                       Id                  = scopeId,
                                                       ParentId            = null,
                                                       ResolverInformation = new CreateScopeResolverInformation
                                                       {
                                                           Typename = resolverName,
                                                       },
                                                       ScopeProperties   = new DHCPv4ScopeProperties(),
                                                       AddressProperties = DHCPv4ScopeAddressProperties.Empty,
                                                   }
                                               },
                                               new DHCPv4LeaseCreatedEvent
                                               {
                                                   EntityId       = leaseId,
                                                   Address        = start - 100,
                                                   ScopeId        = scopeId,
                                                   ClientIdenfier = DHCPv4ClientIdentifier.FromDuid(1, new UUIDDUID(random.NextGuid()), random.NextBytes(6)).GetBytes(),
                                               },
                                               new DHCPv4LeaseActivatedEvent
                                               {
                                                   EntityId = leaseId,
                                                   ScopeId  = scopeId,
                                               } });

            Mock <IDHCPv4StorageEngine> storageMock = new Mock <IDHCPv4StorageEngine>(MockBehavior.Strict);

            storageMock.Setup(x => x.Save(rootScope)).ReturnsAsync(storeResult).Verifiable();

            var command = new UpdateDHCPv4ScopeCommand(scopeId, name, description, null,
                                                       useDynamicTime == false ? new DHCPv4ScopeAddressPropertyReqest
            {
                Start                     = start.ToString(),
                End                       = end.ToString(),
                ExcludedAddresses         = Array.Empty <String>(),
                AcceptDecline             = random.NextBoolean(),
                AddressAllocationStrategy = DHCPv4ScopeAddressPropertyReqest.AddressAllocationStrategies.Next,
                InformsAreAllowd          = random.NextBoolean(),
                ReuseAddressIfPossible    = random.NextBoolean(),
                SupportDirectUnicast      = random.NextBoolean(),
                PreferredLifetime         = TimeSpan.FromDays(0.5),
                RenewalTime               = TimeSpan.FromDays(0.25),
                LeaseTime                 = TimeSpan.FromDays(1),
                MaskLength                = (Byte)random.Next(10, 29),
            } : new DHCPv4ScopeAddressPropertyReqest
            {
                Start                     = start.ToString(),
                End                       = end.ToString(),
                ExcludedAddresses         = Array.Empty <String>(),
                AcceptDecline             = random.NextBoolean(),
                AddressAllocationStrategy = DHCPv4ScopeAddressPropertyReqest.AddressAllocationStrategies.Next,
                InformsAreAllowd          = random.NextBoolean(),
                ReuseAddressIfPossible    = random.NextBoolean(),
                SupportDirectUnicast      = random.NextBoolean(),
                DynamicRenewTime          = new DHCPv4DynamicRenewTimeRequest
                {
                    Hours              = 5,
                    Minutes            = 10,
                    MinutesToEndOfLife = 45,
                    MinutesToRebound   = 35,
                },
                MaskLength = (Byte)random.Next(10, 29),
            }
                                                       ,
                                                       new CreateScopeResolverRequest
            {
                PropertiesAndValues = new Dictionary <String, String>(),
                Typename            = resolverName,
            },
                                                       new DHCPv4ScopePropertyRequest[] {
                new DHCPv4AddressListScopePropertyRequest
                {
                    OptionCode = 24,
                    Type       = DHCPv4ScopePropertyType.AddressList,
                    Addresses  = random.GetIPv4Addresses().Select(x => x.ToString()).ToArray(),
                },
                new DHCPv4AddressScopePropertyRequest
                {
                    OptionCode = 25,
                    Type       = DHCPv4ScopePropertyType.Address,
                    Address    = random.GetIPv4Address().ToString()
                },
                new DHCPv4BooleanScopePropertyRequest
                {
                    OptionCode = 26,
                    Type       = DHCPv4ScopePropertyType.Boolean,
                    Value      = random.NextBoolean()
                },
                new DHCPv4NumericScopePropertyRequest
                {
                    OptionCode  = 27,
                    Type        = DHCPv4ScopePropertyType.UInt16,
                    NumericType = DHCPv4NumericValueTypes.UInt16,
                    Value       = (UInt16)random.NextUInt16()
                },
                new DHCPv4TextScopePropertyRequest
                {
                    OptionCode = 28,
                    Type       = DHCPv4ScopePropertyType.Text,
                    Value      = random.GetAlphanumericString()
                },
                new DHCPv4TimeScopePropertyRequest
                {
                    OptionCode = 29,
                    Type       = DHCPv4ScopePropertyType.Time,
                    Value      = TimeSpan.FromSeconds(random.Next(10, 20))
                },
                new DHCPv4AddressListScopePropertyRequest
                {
                    OptionCode = 64,
                    MarkAsRemovedInInheritance = true,
                }
            }
                                                       );

            var serviceBusMock = new Mock <IServiceBus>(MockBehavior.Strict);

            serviceBusMock.Setup(x => x.Publish(It.Is <NewTriggerHappendMessage>(y => y.Triggers.Count() == 1 &&
                                                                                 ((PrefixEdgeRouterBindingUpdatedTrigger)y.Triggers.First()).OldBinding.Prefix == IPv4Address.FromString("fc70::0")
                                                                                 ))).Returns(Task.CompletedTask);
            var handler = new UpdateDHCPv4ScopeCommandHandler(storageMock.Object, serviceBusMock.Object, rootScope,
                                                              Mock.Of <ILogger <UpdateDHCPv4ScopeCommandHandler> >());

            Boolean result = await handler.Handle(command, CancellationToken.None);

            Assert.Equal(storeResult, result);

            var scope = rootScope.GetRootScopes().First();

            Assert.Equal(name, scope.Name);
            Assert.Equal(description, scope.Description);
            Assert.NotNull(scope.Resolver);
            Assert.Equal(start, scope.AddressRelatedProperties.Start);

            Assert.True(scope.Properties.IsMarkedAsRemovedFromInheritance(64));
            Assert.False(scope.Properties.IsMarkedAsRemovedFromInheritance(24));

            if (useDynamicTime == true)
            {
                Assert.True(scope.AddressRelatedProperties.UseDynamicRewnewTime);
                Assert.Equal(5, scope.AddressRelatedProperties.DynamicRenewTime.Hour);
            }
            else
            {
                Assert.False(scope.AddressRelatedProperties.UseDynamicRewnewTime);
            }

            scopeResolverMock.Verify();
            storageMock.Verify();

            serviceBusMock.Verify();
            Assert.Empty(rootScope.GetTriggers());
        }
コード例 #13
0
ファイル: BroadcastQuestion.cs プロジェクト: muqiuq/BeASwitch
 public bool Evaluate(string response)
 {
     return(response == broadcast.ToString());
 }
コード例 #14
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            IPv4Address address = (IPv4Address)value;

            writer.WriteValue(address.ToString());
        }
コード例 #15
0
ファイル: AddressConverter.cs プロジェクト: Hackberries/Ipee
 public static string IPv4toIPv6(IPv4Address address)
 {
     return(IPv4toIPv6(address.ToString()));
 }
コード例 #16
0
        public void TestToString()
        {
            IPv4Address IP = new IPv4Address(new byte[] { 123, 123, 123, 123 });

            Assert.Equal("123.123.123.123", IP.ToString());
        }
コード例 #17
0
        public async Task Handle(Boolean withDynamicRenewTime)
        {
            Random random = new Random();

            String name        = random.GetAlphanumericString();
            String description = random.GetAlphanumericString();

            IPv4Address start = random.GetIPv4Address();
            IPv4Address end   = start + 100;

            String resolverName = random.GetAlphanumericString();

            Mock <IScopeResolverManager <DHCPv4Packet, IPv4Address> > scopeResolverMock = new Mock <IScopeResolverManager <DHCPv4Packet, IPv4Address> >();

            scopeResolverMock.Setup(x => x.IsResolverInformationValid(It.Is <CreateScopeResolverInformation>(y =>
                                                                                                             y.Typename == resolverName
                                                                                                             ))).Returns(true).Verifiable();
            scopeResolverMock.Setup(x => x.InitializeResolver(It.Is <CreateScopeResolverInformation>(y =>
                                                                                                     y.Typename == resolverName
                                                                                                     ))).Returns(Mock.Of <IScopeResolver <DHCPv4Packet, IPv4Address> >()).Verifiable();

            Mock <ILoggerFactory> factoryMock = new Mock <ILoggerFactory>(MockBehavior.Strict);

            factoryMock.Setup(x => x.CreateLogger(It.IsAny <String>())).Returns(Mock.Of <ILogger <DHCPv4RootScope> >());

            DHCPv4RootScope rootScope = new DHCPv4RootScope(random.NextGuid(), scopeResolverMock.Object, factoryMock.Object);

            Mock <IDHCPv4StorageEngine> storageMock = new Mock <IDHCPv4StorageEngine>(MockBehavior.Strict);

            storageMock.Setup(x => x.Save(rootScope)).ReturnsAsync(true).Verifiable();

            var command = new CreateDHCPv4ScopeCommand(name, description, null,
                                                       withDynamicRenewTime == false ? new DHCPv4ScopeAddressPropertyReqest
            {
                Start                     = start.ToString(),
                End                       = end.ToString(),
                ExcludedAddresses         = Array.Empty <String>(),
                AcceptDecline             = random.NextBoolean(),
                AddressAllocationStrategy = DHCPv4ScopeAddressPropertyReqest.AddressAllocationStrategies.Next,
                InformsAreAllowd          = random.NextBoolean(),
                ReuseAddressIfPossible    = random.NextBoolean(),
                SupportDirectUnicast      = random.NextBoolean(),
                RenewalTime               = TimeSpan.FromDays(0.5),
                PreferredLifetime         = TimeSpan.FromDays(0.8),
                LeaseTime                 = TimeSpan.FromDays(1),
                MaskLength                = (Byte)random.Next(12, 20),
            } : new DHCPv4ScopeAddressPropertyReqest
            {
                Start                     = start.ToString(),
                End                       = end.ToString(),
                ExcludedAddresses         = Array.Empty <String>(),
                AcceptDecline             = random.NextBoolean(),
                AddressAllocationStrategy = DHCPv4ScopeAddressPropertyReqest.AddressAllocationStrategies.Next,
                InformsAreAllowd          = random.NextBoolean(),
                ReuseAddressIfPossible    = random.NextBoolean(),
                SupportDirectUnicast      = random.NextBoolean(),
                MaskLength                = (Byte)random.Next(12, 20),
                DynamicRenewTime          = new DHCPv4DynamicRenewTimeRequest
                {
                    Hours              = 3,
                    Minutes            = 15,
                    MinutesToEndOfLife = 40,
                    MinutesToRebound   = 20,
                }
            },
                                                       new CreateScopeResolverRequest
            {
                PropertiesAndValues = new Dictionary <String, String>(),
                Typename            = resolverName,
            },
                                                       new DHCPv4ScopePropertyRequest[] {
                new DHCPv4AddressListScopePropertyRequest
                {
                    OptionCode = 24,
                    Type       = DHCPv4ScopePropertyType.AddressList,
                    Addresses  = random.GetIPv4Addresses().Select(x => x.ToString()).ToArray(),
                },
                new DHCPv4AddressScopePropertyRequest
                {
                    OptionCode = 25,
                    Type       = DHCPv4ScopePropertyType.Address,
                    Address    = random.GetIPv4Address().ToString()
                },
                new DHCPv4BooleanScopePropertyRequest
                {
                    OptionCode = 26,
                    Type       = DHCPv4ScopePropertyType.Boolean,
                    Value      = random.NextBoolean()
                },
                new DHCPv4NumericScopePropertyRequest
                {
                    OptionCode  = 27,
                    Type        = DHCPv4ScopePropertyType.UInt16,
                    NumericType = DHCPv4NumericValueTypes.UInt16,
                    Value       = (UInt16)random.NextUInt16()
                },
                new DHCPv4TextScopePropertyRequest
                {
                    OptionCode = 28,
                    Type       = DHCPv4ScopePropertyType.Text,
                    Value      = random.GetAlphanumericString()
                },
                new DHCPv4TimeScopePropertyRequest
                {
                    OptionCode = 29,
                    Type       = DHCPv4ScopePropertyType.Time,
                    Value      = TimeSpan.FromSeconds(random.Next(10, 20))
                },
                new DHCPv4AddressListScopePropertyRequest
                {
                    OptionCode = 64,
                    MarkAsRemovedInInheritance = true,
                }
            }
                                                       );

            var handler = new CreateDHCPv4ScopeCommandHandler(storageMock.Object, rootScope,
                                                              Mock.Of <ILogger <CreateDHCPv4ScopeCommandHandler> >());

            Guid?result = await handler.Handle(command, CancellationToken.None);

            Assert.True(result.HasValue);

            var scope = rootScope.GetRootScopes().First();

            Assert.True(scope.Properties.IsMarkedAsRemovedFromInheritance(64));
            Assert.False(scope.Properties.IsMarkedAsRemovedFromInheritance(24));

            if (withDynamicRenewTime == false)
            {
                Assert.False(scope.AddressRelatedProperties.UseDynamicRewnewTime);
            }
            else
            {
                Assert.True(scope.AddressRelatedProperties.UseDynamicRewnewTime);
                Assert.Equal(3, scope.AddressRelatedProperties.DynamicRenewTime.Hour);
            }

            scopeResolverMock.Verify();
            storageMock.Verify();
        }