コード例 #1
0
        public void PartOfIPAddressCtor_CreateInstanceWithParameters_InstanceIsCorrectInitialized()
        {
            PartOfIPAddress ip = new PartOfIPAddress("1", "40");

            Assert.AreEqual("1", ip.ReferenceId);
            Assert.AreEqual("40", ip.Part);
        }
コード例 #2
0
        public void PartOfIPAddress_EqualsWithTwoInstances_InstancesAreNotEqual()
        {
            PartOfIPAddress expected = new PartOfIPAddress("1", "40");
            PartOfIPAddress actual = new PartOfIPAddress("2", "40");

            Assert.AreNotEqual(expected, actual);
        }
コード例 #3
0
        public void AddIPAddress_NewPartOfIPAddress_IPAddressIsInList()
        {
            PartOfIPAddress expected = new PartOfIPAddress("100", "x.x.x.100");
            ConfigBuilder builder = CreateFakeConfigBuilder();
            builder.AddIPAddress(expected);
            PartOfIPAddress actual = builder.GetIPAddress(expected.ReferenceId);

            Assert.AreEqual(expected, actual);
        }
コード例 #4
0
        public void IPAddressRepository_SaveChanges_IPAddressesAreWrittenIntoFile()
        {
            IPAddressRepository repository = new IPAddressRepository("EmptyConfiguration.xml");
            PartOfIPAddress expected = new PartOfIPAddress("Cam1", "x.x.x.139");
            repository.Add(expected);
            repository.SaveChanges();

            IPAddressRepository repository2 = new IPAddressRepository("EmptyConfiguration.xml");
            PartOfIPAddress actual = repository2.GetById("Cam1");

            Assert.AreEqual(expected.ReferenceId, actual.ReferenceId);
            Assert.AreEqual(expected.Part, actual.Part);
            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
 public void AddIPAddress(PartOfIPAddress address)
 {
     if (address == null) throw new ArgumentNullException("address");
     if (m_IPAddresses.Contains(address)) throw new InvalidOperationException(string.Format("An instance of PartOfIPAddress is already in list. [{0}]", address));
     m_IPAddresses.Add(address);
 }