Ejemplo n.º 1
0
        public void Constructor_Valid( )
        {
            var iface = new SUTest(fakeDevice, "eth0");

            Assert.AreEqual("eth0", iface.Name);
            Assert.AreEqual(fakeDevice, iface.Parent);
        }
Ejemplo n.º 2
0
        public void Disconnect_NotConnected( )
        {
            var iface = new SUTest(fakeDevice, "eth1");

            iface.Disconnect( );

            Assert.AreEqual(null, iface.GetOtherInterface( ));
        }
Ejemplo n.º 3
0
        internal static object GetOtherInterface(this SUTest obj)
        {
            var fieldName = "otherInterface";
            var type      = typeof(SUTest);
            var field     = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic);

            return(field.GetValue(obj));
        }
        public void Connect_Other( )
        {
            var iface = new SUTest(fakeDevice, "eth1");
            var iface2 = new SUTest(fakeDevice, "eth2");
            iface.Connect(iface2);

            Assert.AreEqual(iface2, iface.GetOtherInterface( ));
            Assert.AreEqual(iface, iface2.GetOtherInterface( ));
        }
Ejemplo n.º 5
0
        public void Connect_Connected( )
        {
            var iface = new SUTest(fakeDevice, "eth1");

            var otherFakeDevice = new Abstract.Fakes.StubINetDevice( );
            var iface2          = new SUTest(otherFakeDevice, "eth1");

            iface.Connect(iface2);
            iface.Connect(iface2);
        }
        public void Connect_Connected( )
        {
            var iface = new SUTest(fakeDevice, "eth1");

            var otherFakeDevice = new Abstract.Fakes.StubINetDevice( );
            var iface2 = new SUTest(otherFakeDevice, "eth1");

            iface.Connect(iface2);
            iface.Connect(iface2);
        }
Ejemplo n.º 7
0
        public void Connect_Other( )
        {
            var iface  = new SUTest(fakeDevice, "eth1");
            var iface2 = new SUTest(fakeDevice, "eth2");

            iface.Connect(iface2);

            Assert.AreEqual(iface2, iface.GetOtherInterface( ));
            Assert.AreEqual(iface, iface2.GetOtherInterface( ));
        }
Ejemplo n.º 8
0
        public void Connect_OtherFromOtherDevice_OtherName( )
        {
            var iface = new SUTest(fakeDevice, "eth1");

            var otherFakeDevice = new Abstract.Fakes.StubINetDevice( );
            var iface2          = new SUTest(otherFakeDevice, "eth2");

            iface.Connect(iface2);

            Assert.AreEqual(iface2, iface.GetOtherInterface( ));
            Assert.AreEqual(iface, iface2.GetOtherInterface( ));
        }
        public void Connect_OtherFromOtherDevice_TheSameName( )
        {
            var iface = new SUTest(fakeDevice, "eth1");

            var otherFakeDevice = new Abstract.Fakes.StubINetDevice( );
            var iface2 = new SUTest(otherFakeDevice, "eth1");

            iface.Connect(iface2);

            Assert.AreEqual(iface2, iface.GetOtherInterface( ));
            Assert.AreEqual(iface, iface2.GetOtherInterface( ));
        }
Ejemplo n.º 10
0
        public void ReceiveData_ValidTarget( )
        {
            var iface = new SUTest(fakeDevice, "eth1");

            var received   = false;
            var fakePacket = new Abstract.Fakes.StubINetPacket( );

            ((Abstract.Fakes.StubINetDevice)fakeDevice).ReceiveDataINetPacketINetHwInterface = (INetPacket iNetPacket, INetHwInterface myIface) => received = fakePacket == iNetPacket;

            fakePacket.DestinationHardwareAddressGet = () => iface.HardwareAddress;

            iface.ReceiveData(fakePacket);

            Assert.IsTrue(received);
        }
Ejemplo n.º 11
0
        public void Disconnect_Connected( )
        {
            var iface = new SUTest(fakeDevice, "eth1");

            #region Connect
            var otherFakeDevice = new Abstract.Fakes.StubINetDevice( );
            var iface2          = new SUTest(otherFakeDevice, "eth1");
            iface.Connect(iface2);
            #endregion

            iface.Disconnect( );

            Assert.AreEqual(null, iface.GetOtherInterface( ));
            Assert.AreEqual(null, iface2.GetOtherInterface( ));
        }
Ejemplo n.º 12
0
        public void SendData( )
        {
            using (ShimsContext.Create( )) {
                var iface = new SUTest(fakeDevice, "eth1");

                var             sended      = false;
                INetPacket      fakePacket  = new Abstract.Fakes.StubINetPacket( );
                INetDevice      otherDevice = new Abstract.Fakes.StubINetDevice( );
                INetHwInterface otherIface  = new SUTest(otherDevice, "eth1");
                Simulator.Fakes.ShimNetHwInterface.AllInstances.ReceiveDataINetPacket =
                    (SUTest instance, INetPacket iNetPacket) => {
                    Assert.AreEqual(iface.HardwareAddress, iNetPacket.SourceHardwareAddress);
                    Assert.AreEqual(otherIface.HardwareAddress, iNetPacket.DestinationHardwareAddress);
                    Assert.AreEqual(fakePacket.SourceAddress, iNetPacket.SourceAddress);
                    Assert.AreEqual(fakePacket.DestinationAddress, iNetPacket.DestinationAddress);
                    sended = true;
                };
                iface.Connect(otherIface);

                iface.SendData(fakePacket);

                Assert.IsTrue(sended);
            }
        }
Ejemplo n.º 13
0
        public void Connect_Null( )
        {
            var iface = new SUTest(fakeDevice, "eth1");

            iface.Connect(null);
        }
        public void Constructor_Valid( )
        {
            var iface = new SUTest(fakeDevice, "eth0");

            Assert.AreEqual("eth0", iface.Name);
            Assert.AreEqual(fakeDevice, iface.Parent);
        }
Ejemplo n.º 15
0
        public void Constructor_ExistingIfaceName( )
        {
            var iface = new SUTest(fakeDevice, "eth0");

            new SUTest(fakeDevice, "eth0");
        }
        public void Disconnect_NotConnected( )
        {
            var iface = new SUTest(fakeDevice, "eth1");

            iface.Disconnect( );

            Assert.AreEqual(null, iface.GetOtherInterface( ));
        }
        public void SendData( )
        {
            using (ShimsContext.Create( )) {
                var iface = new SUTest(fakeDevice, "eth1");

                var sended = false;
                INetPacket fakePacket = new Abstract.Fakes.StubINetPacket( );
                INetDevice otherDevice = new Abstract.Fakes.StubINetDevice( );
                INetHwInterface otherIface = new SUTest(otherDevice, "eth1");
                Simulator.Fakes.ShimNetHwInterface.AllInstances.ReceiveDataINetPacket =
                    (SUTest instance, INetPacket iNetPacket) => {
                        Assert.AreEqual(iface.HardwareAddress, iNetPacket.SourceHardwareAddress);
                        Assert.AreEqual(otherIface.HardwareAddress, iNetPacket.DestinationHardwareAddress);
                        Assert.AreEqual(fakePacket.SourceAddress, iNetPacket.SourceAddress);
                        Assert.AreEqual(fakePacket.DestinationAddress, iNetPacket.DestinationAddress);
                        sended = true;
                    };
                iface.Connect(otherIface);

                iface.SendData(fakePacket);

                Assert.IsTrue(sended);
            }
        }
        public void ReceiveData_Null( )
        {
            var iface = new SUTest(fakeDevice, "eth1");

            iface.ReceiveData(null);
        }
        public void ReceiveData_WrongTarget( )
        {
            var iface = new SUTest(fakeDevice, "eth1");

            var received = false;
            var fakePacket = new Abstract.Fakes.StubINetPacket( );
            ((Abstract.Fakes.StubINetDevice)fakeDevice).ReceiveDataINetPacketINetHwInterface = (INetPacket iNetPacket, INetHwInterface myIface) => received = fakePacket == iNetPacket;

            var otherIface = new SUTest(fakeDevice, "eth2");
            fakePacket.DestinationHardwareAddressGet = ( ) => otherIface.HardwareAddress;

            iface.ReceiveData(fakePacket);

            Assert.IsFalse(received);
        }
 public void Constructor_ExistingIfaceName( )
 {
     var iface = new SUTest(fakeDevice, "eth0");
     new SUTest(fakeDevice, "eth0");
 }
        public void Connect_ReConnected( )
        {
            var iface = new SUTest(fakeDevice, "eth1");

            #region Disconnect
            var otherFakeDevice = new Abstract.Fakes.StubINetDevice( );
            var iface2 = new SUTest(otherFakeDevice, "eth1");
            iface.Connect(iface2);
            iface.Disconnect( );
            #endregion

            iface.Connect(iface2);

            Assert.AreEqual(iface2, iface.GetOtherInterface( ));
            Assert.AreEqual(iface, iface2.GetOtherInterface( ));
        }
Ejemplo n.º 22
0
        public void Connect_TheSame( )
        {
            var iface = new SUTest(fakeDevice, "eth1");

            iface.Connect(iface);
        }
Ejemplo n.º 23
0
        public void ReceiveData_Null( )
        {
            var iface = new SUTest(fakeDevice, "eth1");

            iface.ReceiveData(null);
        }
 public void Connect_TheSame( )
 {
     var iface = new SUTest(fakeDevice, "eth1");
     iface.Connect(iface);
 }
 public void Connect_Null( )
 {
     var iface = new SUTest(fakeDevice, "eth1");
     iface.Connect(null);
 }