コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
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( ));
        }
コード例 #4
0
        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( ));
        }
コード例 #5
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( ));
        }
コード例 #6
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( );
                INetLgInterface otherIface  = new SUTest(otherDevice, "eth1");
                Simulator.Fakes.ShimNetLgInterface.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);
            }
        }
コード例 #7
0
        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( ));
        }
コード例 #8
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( );
                INetLgInterface otherIface = new SUTest(otherDevice, "eth1");
                Simulator.Fakes.ShimNetLgInterface.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);
            }
        }