【问题标题】:SignalR Service mock implementation for Service/Integration testing用于服务/集成测试的 SignalR 服务模拟实现
【发布时间】:2019-07-20 10:53:33
【问题描述】:

我希望能够模拟 SignalR Hub 以进行服务测试。这个想法是能够通过以下方式创建测试: 启动 SignalR 服务器(应在运行时配置 url、端口和集线器类) - 为此目的,将在测试模块中创建集线器。 所以第一部分 - 启动一个运行时可配置的 SignalR 服务器是可能的:

StartOptions so = new StartOptions("http://127.0.0.1:8080");
so.AppStartup = "SrServer.Startup1"; // set the startup class (will be defined in the test module)

以下是 Startup1 的示例:

class Startup1
{
    public void Configuration(IAppBuilder app)
    {

        app.UseCors(CorsOptions.AllowAll);
        app.MapSignalR();
    }
}

我缺少的唯一问题是能够从我的测试模块设置要使用的集线器 - 这可能吗?

【问题讨论】:

    标签: testing service signalr integration


    【解决方案1】:

    只需在调用 'app.MapSignalR();' 之前加载包含集线器的程序集

    AppDomain.CurrentDomain.Load(typeof(MyHub).Assembly.FullName);
    

    来源: https://stackoverflow.com/a/21597197/10720979

    【讨论】:

    • 我正在寻找一种方法来为每个配置(webapp)设置一个集线器,如果可能的话,可以通过反射绕过集线器搜索(明确指定要使用哪个集线器)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-27
    • 2011-06-13
    • 1970-01-01
    • 2013-10-23
    • 1970-01-01
    相关资源
    最近更新 更多