using System;
using NUnit.Framework;
using System.Threading;
using System.Diagnostics;
using grof;
namespace grof.protocols.membership{
/// <summary>
/// Description of TestTcpReceiver.
/// </summary>
[TestFixture]
public class TestTcpReceiver
{
private TcpReceiver receiver;
public TestTcpReceiver()
{
}
[SetUp]
public void SetUp()
{
this.receiver = new TcpReceiver( "127.0.0.1", 3454, "foo", this.MessageReceived );
}
[TearDown]
public void TearDown()
{
this.receiver = null;
}
/// <summary>
/// Tests whether the TcpReceiver
/// thread can be stopped and the
/// resources are cleaned.
/// </summary>
[Test]
public void TestStopping()
{
this.receiver.Start();
Console.WriteLine( "Sleeping..." );
Thread.Sleep( 2000 );
Console.WriteLine( "Stopping..." );
this.receiver.Stop();
}
public void MessageReceived( Message msg )
{
Console.WriteLine( "Message received: " + msg.ToString() );
}
}
}
|