public void Constructor_Valid( ) { var iface = new SUTest(fakeDevice, "eth0"); Assert.AreEqual("eth0", iface.Name); Assert.AreEqual(fakeDevice, iface.Parent); }
public void Disconnect_NotConnected( ) { var iface = new SUTest(fakeDevice, "eth1"); iface.Disconnect( ); Assert.AreEqual(null, iface.GetOtherInterface( )); }
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( )); }
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_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( )); }
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); }
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( )); }
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); } }
public void Connect_Null( ) { var iface = new SUTest(fakeDevice, "eth1"); iface.Connect(null); }
public void Constructor_ExistingIfaceName( ) { var iface = new SUTest(fakeDevice, "eth0"); new SUTest(fakeDevice, "eth0"); }
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 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( )); }
public void Connect_TheSame( ) { var iface = new SUTest(fakeDevice, "eth1"); iface.Connect(iface); }