コード例 #1
0
        public void Remove_InterfaceRemoved()
        {
            // Arrange

            //Act
            LoopbackInterface res            = LoopbackNET.Loopback.Create();
            string            createdIFaceId = res.NetworkInterface.Id;

            res.Remove();

            // Assert
            Assert.IsFalse(NetworkInterface.GetAllNetworkInterfaces().Any(iface => iface.Id == createdIFaceId),
                           "Expected NO interfaces with the created interface id, but found at least 1");
        }
コード例 #2
0
        public void RemoveNamed_TwoLoopbacksExist_OtherLoopbackNotRemoved()
        {
            // Arrange
            Random r          = new Random();
            string ifaceName1 = "TestInterface" + r.Next();
            string ifaceName2 = "TestInterface" + r.Next();
            //  Creating the interfaces
            LoopbackInterface loop1 = LoopbackNET.Loopback.Create(ifaceName1);
            LoopbackInterface loop2 = LoopbackNET.Loopback.Create(ifaceName2);


            //Act
            loop1.Remove();
            LoopbackInterface loop3 = LoopbackNET.Loopback.Create(ifaceName2); // should return same as loop2



            // Assert
            Assert.IsNotNull(loop3);
            Assert.IsNotNull(loop3.NetworkInterface);
            Assert.AreEqual(loop3.NetworkInterface.Id, loop2.NetworkInterface.Id,
                            $"Expected Network Interfaces ID of new interface '2' to be the same as one retrieved before removal of '1'");
        }