testing - 用于服务/集成测试的 SignalR 服务模拟实现
问题描述
我希望能够模拟 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();
}
}
我缺少的唯一问题是能够从我的测试模块设置要使用的集线器 - 这可能吗?
解决方案
只需在调用“app.MapSignalR();”之前加载包含集线器的程序集
AppDomain.CurrentDomain.Load(typeof(MyHub).Assembly.FullName);
推荐阅读
- php - 如何将用户输入从 HTML 文本表单发送到我的 SQL 数据库?
- python-3.x - Hyperledger Sawtooth 供应链 Python 身份验证
- jquery - Jquery 每个循环延迟/间隔应用数组的内联样式更改。循环的
- java - 在 RxJava 2 中,如何使一个 Observable 发出另一个 Observable 发出的组合项?
- python - 如何在 Matplotlib TIFF 图中定义无数据/透明值?
- java - 如何简化多个 IF 语句?
- c# - .net core 无法作为独立应用程序运行。在码头上
- javascript - 使用嵌套 JSON 请求 API
- python - 在 Python 中区分同一类的对象
- python - Python:排序列表用作字典中的值;来自 csv 的数据