Exemplo n.º 1
0
        public async Task Exception_ThrowWithoutDetails(string pipeName, string details)
        {
            _serviceMock.Setup(x => x.ThrowException())
            .Throws(new Exception(details));

            IIpcClient <ITestService> client = _factory
                                               .WithIpcHostConfiguration(hostBuilder =>
            {
                hostBuilder.AddNamedPipeEndpoint <ITestService>(options =>
                {
                    options.PipeName = pipeName;
                    options.IncludeFailureDetailsInResponse = false;
                });
            })
                                               .CreateClient((name, services) =>
            {
                services.AddNamedPipeIpcClient <ITestService>(name, (_, options) =>
                {
                    options.PipeName = pipeName;
                });
            });

            IpcFaultException actual = await Assert.ThrowsAsync <IpcFaultException>(async() =>
            {
                await client.InvokeAsync(x => x.ThrowException());
            });

            Assert.Null(actual.InnerException);
        }
        public async Task Exception_ThrowWithoutDetails(string pipeName, string details)
        {
            _serviceMock.Setup(x => x.ThrowException())
            .Throws(new Exception(details));

            IIpcClient <ITestService> client = _factory
                                               .WithIpcHostConfiguration(hostBuilder =>
            {
                hostBuilder.AddNamedPipeEndpoint <ITestService>(options =>
                {
                    options.PipeName = pipeName;
                    options.IncludeFailureDetailsInResponse = false;
                });
            })
                                               .CreateClient((name, services) =>
            {
                services.AddNamedPipeIpcClient <ITestService>(name, (_, options) =>
                {
                    options.PipeName = pipeName;
                });
            });

#if !DISABLE_DYNAMIC_CODE_GENERATION
            IpcFaultException actual = await Assert.ThrowsAsync <IpcFaultException>(async() =>
            {
                await client.InvokeAsync(x => x.ThrowException());
            });

            Assert.Null(actual.InnerException);
#endif

            IpcFaultException actual2 = await Assert.ThrowsAsync <IpcFaultException>(async() =>
            {
                var request = TestHelpers.CreateIpcRequest("ThrowException");
                await client.InvokeAsync(request);
            });

            Assert.Null(actual2.InnerException);
        }