public void PacketMeetsCondition_False_WrongPacketType() { Random random = new Random(); UInt32 enterpriseNumber = random.NextUInt32(); Int32 agentIndex = 2; DHCPv6RemoteIdentifierEnterpriseNumberResolver resolver = new DHCPv6RemoteIdentifierEnterpriseNumberResolver( Mock.Of <ILogger <DHCPv6RemoteIdentifierEnterpriseNumberResolver> >()); Mock <ISerializer> serializerMock = new Mock <ISerializer>(MockBehavior.Strict); serializerMock.Setup(x => x.Deserialze <UInt32>(enterpriseNumber.ToString())).Returns(enterpriseNumber).Verifiable(); serializerMock.Setup(x => x.Deserialze <Int32?>(agentIndex.ToString())).Returns(agentIndex).Verifiable(); resolver.ApplyValues(new Dictionary <String, String> { { "EnterpriseNumber", enterpriseNumber.ToString() }, { "RelayAgentIndex", agentIndex.ToString() }, }, serializerMock.Object); DHCPv6Packet packet = DHCPv6Packet.AsInner(random.NextUInt16(), DHCPv6PacketTypes.Solicit, Array.Empty <DHCPv6PacketOption>()); Boolean result = resolver.PacketMeetsCondition(packet); Assert.False(result); serializerMock.Verify(); }
public void PacketMeetsCondition_DifferentEnterpriseId(Int32?agentIndex) { Random random = new Random(); UInt32 enterpriseNumber = random.NextUInt32(); UInt32 differenEnterpriseNumber = random.NextUInt32(); DHCPv6RemoteIdentifierEnterpriseNumberResolver resolver = new DHCPv6RemoteIdentifierEnterpriseNumberResolver( Mock.Of <ILogger <DHCPv6RemoteIdentifierEnterpriseNumberResolver> >()); Mock <ISerializer> serializerMock = new Mock <ISerializer>(MockBehavior.Strict); serializerMock.Setup(x => x.Deserialze <UInt32>(differenEnterpriseNumber.ToString())).Returns(differenEnterpriseNumber).Verifiable(); serializerMock.Setup(x => x.Deserialze <Int32?>(agentIndex.ToString())).Returns(agentIndex).Verifiable(); resolver.ApplyValues(new Dictionary <String, String> { { "EnterpriseNumber", differenEnterpriseNumber.ToString() }, { "RelayAgentIndex", agentIndex.ToString() }, }, serializerMock.Object); DHCPv6RelayPacket packet = GeneratePacket(random, enterpriseNumber); Boolean result = resolver.PacketMeetsCondition(packet); Assert.False(result); serializerMock.Verify(); }