MonoDevelop上的集成测试ServiceStack(Xamarin)

时间:2013-06-09 07:05:30

标签: mono servicestack

您好我是Mono和ServiceStack的新手,我在OSx上的Xamarin Studios上运行集成测试时遇到了麻烦。

我正在关注这里的示例AppHostListenerBaseTests.cs,但我无法通过测试。

    private const string listeningOn = "http://localhost:8080/";
    private myAppHost appHost; // extends AppHostHttpListenerBase

    [TestFixtureSetUp()]
    public void TestFixtureSetUp ()
    {
        appHost = new myAppHost ();
        appHost.Init ();
        appHost.Start (listeningOn);

        System.Console.WriteLine("ExampleAppHost Created at {0}, listening on {1}",
                                 DateTime.Now, listeningOn);
    }

    [TestFixtureTearDown()]
    public void TestFixtureTearDown ()
    {
        if (appHost == null)
            return;
        appHost.Dispose ();
        appHost = null;
    }

    [Test()]
    public void StartupWebService ()
    {
       html = listeningOn.GetStringFromUrl();
       Assert.That(html.Contains("The following operations are supported."));
    }

Mono将始终抛出 System.Net.WebException:远程服务器返回错误(404)。

令人困惑,因为构建整个Web服务工作正常。它启动并到达元页面,但尝试在具有相同代码的测试中运行它只会中断。我不确定这是Xamarin在OSx上的问题,还是我在测试用例中遗漏了一些简单的东西。有没有人以前处理过类似的问题?

1 个答案:

答案 0 :(得分:1)

在您的情况下,我假设您没有从模拟器运行集成测试,而是从真实设备运行。

如果是这种情况,那么从http://localhost:8080/开始收到404的正常情况可能仅存在于您的计算机中,而不是手机中。

相关问题