无法在Linux上的Monodevelop上使用NUnit进行测试

时间:2014-05-11 11:40:33

标签: linux nunit monodevelop tcpclient

我试图对我制作的服务器进行一些测试。但无法运行它。 这是代码:

[SetUp]
public override void setUp()
{
    base.setUp ();
    tcpClient = new TcpClient ("132.72.214.127",6666);
}

[Test]
public void TestSuperUserConnection()
{
    Console.WriteLine ("Starting SuperUser Test");
    string ans = sendAndReceive (""+0, "admin,1234");
    Assert.IsTrue(ans.Contains("{"));
}

public string sendAndReceive(string type, string args)
{
    try{
        string message = buildJson (type, args);
        Console.WriteLine ("Building Json: {0}", message);
        Byte[] data = System.Text.Encoding.ASCII.GetBytes(message);
        NetworkStream stream = tcpClient.GetStream();
        Console.WriteLine ("Sending data");
        stream.Write(data, 0, data.Length);
        data = new Byte[1024];
        StringBuilder ans = new StringBuilder ();
        int bytes;
        string responseData;
        Console.WriteLine ("Receiving data");
        while((bytes = stream.Read(data, 0, data.Length)) > 0)
        {
            responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
            ans.Append (responseData);
        }
        ServerResponse sr = JsonConvert.DeserializeObject<ServerResponse>(ans.ToString());
        Console.WriteLine("Received: {0}", ans.ToString());
        return ans.ToString ();
    }
    catch(Exception e) {
        Console.WriteLine ("Error received: {0}", e);
    }
    return "";
}

我尝试在调试模式和发布模式下运行它。也在sudo下。服务器总是收到我的请求,但我的输出上看不到任何内容,测试永远不会结束。 console.writeline可能有任何问题吗? 有什么想法吗? 我使用monodevelop 4.2.2,使用nunit 2.6.0.0 输出只是:&#34;运行测试ServerTest ....&#34; 而且没有更多

0 个答案:

没有答案