コード例 #1
0
    public async Task InvokeAsync()
    {
        var options = new BusOptions
        {
            EnvelopName = "test_lpc"
        };
        var api = new MemoryStorageApi(options);

        using var mocker = AutoMock.GetLoose(builder =>
        {
            builder.RegisterInstance(api)
            .AsImplementedInterfaces();
        });
        var factory = mocker.Create <Bus.Factory>();
        var bus     = factory.Invoke(options);

        mocker.Mock <IBusFactory>()
        .Setup(x => x.Create(It.IsAny <BusOptions>()))
        .Returns(bus);

        // act
        var server   = mocker.Create <LPCServer>();
        var instance = new TestServerInstance();

        server.AddServerInstance(instance);
        await server.StartAsync();

        var request = new BusTestPage.TestRequest
        {
            Name = "newbe36524"
        };
        var response = await bus.SendRequest <BusTestPage.TestRequest, BusTestPage.TestResponse>(request);

        response.Greetings.Should().Be($"hi, {request.Name}");
    }
コード例 #2
0
 public Task <BusTestPage.TestResponse> GoAsync(BusTestPage.TestRequest request)
 {
     return(Task.FromResult(new BusTestPage.TestResponse
     {
         Greetings = $"hi, {request.Name}"
     }));
 }