示例#1
0
        public async Task StreamTranslator_HappyPath(string pipeName, string input, string expected)
        {
            _serviceMock
            .Setup(x => x.StringType(input))
            .Returns(expected);

            IIpcClient <ITestService> client = _factory
                                               .WithServiceImplementation(_ => _serviceMock.Object)
                                               .WithIpcHostConfiguration(hostBuilder =>
            {
                hostBuilder.AddNamedPipeEndpoint <ITestService>(options =>
                {
                    options.PipeName         = pipeName;
                    options.StreamTranslator = x => new XorStream(x);
                });
            })
                                               .CreateClient((name, services) =>
            {
                services.AddNamedPipeIpcClient <ITestService>(name, (_, options) =>
                {
                    options.PipeName         = pipeName;
                    options.StreamTranslator = x => new XorStream(x);
                });
            });

            string actual = await client.InvokeAsync(x => x.StringType(input));

            Assert.Equal(expected, actual);
        }
        public HappyPathTest(IpcApplicationFactory <ITestService> factory)
        {
            int port = _rand.Next(10000, 50000);

            _client = factory
                      .WithServiceImplementation(_ => _serviceMock.Object)
                      .WithIpcHostConfiguration(hostBuilder =>
            {
                hostBuilder.AddTcpEndpoint <ITestService>(IPAddress.Loopback, port);
            })
                      .CreateClient((name, services) =>
            {
                services.AddTcpIpcClient <ITestService>(name, IPAddress.Loopback, port);
            });
        }
示例#3
0
        public ContractTest(IpcApplicationFactory <ITestService> factory)
        {
            string pipeName = Guid.NewGuid().ToString();

            _client = factory
                      .WithServiceImplementation(_ => _serviceMock.Object)
                      .WithIpcHostConfiguration(hostBuilder =>
            {
                hostBuilder.AddNamedPipeEndpoint <ITestService>(pipeName);
            })
                      .CreateClient((name, services) =>
            {
                services.AddNamedPipeIpcClient <ITestService>(name, pipeName);
            });
        }
        public SimpleTypeNameContractTest(IpcApplicationFactory <ITestService> factory)
        {
            string pipeName = Guid.NewGuid().ToString();

            _client = factory
                      .WithServiceImplementation(_ => _serviceMock.Object)
                      .WithIpcHostConfiguration(hostBuilder =>
            {
                hostBuilder.AddNamedPipeEndpoint <ITestService>(options =>
                {
                    options.PipeName = pipeName;
                    options.IncludeFailureDetailsInResponse = true;
                });
            })
                      .CreateClient((name, services) =>
            {
                services.AddNamedPipeIpcClient <ITestService>(name, (_, options) =>
                {
                    options.UseSimpleTypeNameAssemblyFormatHandling = true;
                    options.PipeName = pipeName;
                }
                                                              );
            });
        }
        public async Task StreamTranslator_HappyPath(string pipeName, string input, string expected)
        {
            _serviceMock
            .Setup(x => x.StringType(input))
            .Returns(expected);

            IIpcClient <ITestService> client = _factory
                                               .WithServiceImplementation(_ => _serviceMock.Object)
                                               .WithIpcHostConfiguration(hostBuilder =>
            {
                hostBuilder.AddNamedPipeEndpoint <ITestService>(options =>
                {
                    options.PipeName         = pipeName;
                    options.StreamTranslator = x => new XorStream(x);
                });
            })
                                               .CreateClient((name, services) =>
            {
                services.AddNamedPipeIpcClient <ITestService>(name, (_, options) =>
                {
                    options.PipeName         = pipeName;
                    options.StreamTranslator = x => new XorStream(x);
                });
            });

#if !DISABLE_DYNAMIC_CODE_GENERATION
            string actual = await client.InvokeAsync(x => x.StringType(input));

            Assert.Equal(expected, actual);
#endif

            var request = TestHelpers.CreateIpcRequest(typeof(ITestService), "StringType", false, new object[] { input });
            var actual2 = await client.InvokeAsync <string>(request);

            Assert.Equal(expected, actual2);
        }
示例#6
0
 public ErrorTest(IpcApplicationFactory <ITestService> factory)
 {
     _factory = factory
                .WithServiceImplementation(_ => _serviceMock.Object);
 }