public void TestRemotePort() { TcpAppender appender = new TcpAppender(); // negative tests Assert.That( () => appender.RemotePort = IPEndPoint.MinPort - 1, Throws.Exception .TypeOf<ArgumentOutOfRangeException>() .With.Property("ParamName").EqualTo("value") ); Assert.That( () => appender.RemotePort = IPEndPoint.MaxPort + 1, Throws.Exception .TypeOf<ArgumentOutOfRangeException>() .With.Property("ParamName").EqualTo("value") ); // positive test int goodPort = IPEndPoint.MinPort + 1; appender.RemotePort = goodPort; Assert.AreEqual(goodPort, appender.RemotePort); }
public void TestActivateOptions() { TcpAppender appender = new TcpAppender(); // negative test - neither the remote port or address has been configured Assert.That( () => appender.ActivateOptions(), Throws.Exception .TypeOf<ArgumentNullException>() .With.Property("ParamName").EqualTo("RemoteAddress") ); // ok, set the remote address appender.RemoteAddress = IPAddress.Parse("127.0.0.1"); // negative test - no remote port set Assert.That( () => appender.ActivateOptions(), Throws.Exception .TypeOf<ArgumentOutOfRangeException>() .With.Property("ParamName").EqualTo("RemotePort") ); // ok, set a valid port appender.RemotePort = IPEndPoint.MinPort + 1; // should pass appender.ActivateOptions(); }
public void EncodingTests() { TcpAppender appender = new TcpAppender(); appender.Encoding = Encoding.UTF32; Assert.AreEqual(Encoding.UTF32, appender.Encoding); }
public void RemoteAddressTests() { TcpAppender appender = new TcpAppender(); IPAddress address = IPAddress.Parse("127.0.0.1"); appender.RemoteAddress = address; Assert.AreEqual(address, appender.RemoteAddress); }