public async Task Should_Allow_Nested_Registration_During_Creation_Using_Description(Side side)
        {
            var(client, server) = await Initialize(
                options => {
                if (side == Side.Client)
                {
                    options.Services.AddSingleton(JsonRpcHandlerDescription.Infer(typeof(NestedClientHandler)));
                }
            },
                options => {
                if (side == Side.Server)
                {
                    options.Services.AddSingleton(JsonRpcHandlerDescription.Infer(typeof(NestedServerHandler)));
                }
            }
                );

            if (side == Side.Client)
            {
                client.GetRequiredService <IHandlersManager>().Descriptors
                .Where(z => z.Handler.GetType().Assembly == typeof(RecursiveResolutionTests).Assembly)
                .Should()
                .HaveCount(2);
            }

            if (side == Side.Server)
            {
                server.GetRequiredService <IHandlersManager>().Descriptors
                .Where(z => z.Handler.GetType().Assembly == typeof(RecursiveResolutionTests).Assembly)
                .Should()
                .HaveCount(2);
            }
        }
        public async Task Server_Cannot_Be_Injected_Into_Handler_During_Creation_Using_Description(Side side)
        {
            Func <Task> a = () => Initialize(
                options =>
            {
                if (side == Side.Client)
                {
                    options.Services
                    .AddSingleton(JsonRpcHandlerDescription.Infer(typeof(InterfaceHandler <ILanguageClient>)))
                    .AddSingleton(JsonRpcHandlerDescription.Infer(typeof(ClassHandler <LanguageClient>)));
                }
            },
                options =>
            {
                if (side == Side.Server)
                {
                    options.Services
                    .AddSingleton(JsonRpcHandlerDescription.Infer(typeof(InterfaceHandler <ILanguageServer>)))
                    .AddSingleton(JsonRpcHandlerDescription.Infer(typeof(ClassHandler <LanguageServer>)));
                }
            }
                );
            var result = await a.Should().ThrowAsync <ContainerException>();

            result.And.ErrorName.Should().Be("UnableToResolveFromRegisteredServices");
        }
 public async Task Server_Facade_Can_Be_Injected_Into_Handler_During_Creation_Using_Description()
 {
     Func <Task> a = () => Initialize(
         options => { },
         options => options.Services
         .AddSingleton(JsonRpcHandlerDescription.Infer(typeof(ClassHandler <IJsonRpcServerFacade>)))
         );
     await a.Should().NotThrowAsync();
 }
        public void Server_Cannot_Be_Injected_Into_Handler_During_Creation_Using_Description()
        {
            Func <Task> a = () => Initialize(
                options => { },
                options => options.Services
                .AddSingleton(JsonRpcHandlerDescription.Infer(typeof(InterfaceHandler <IJsonRpcServer>)))
                .AddSingleton(JsonRpcHandlerDescription.Infer(typeof(ClassHandler <JsonRpcServer>)))
                );
            var result = a.Should().Throw <ContainerException>();

            result.And.ErrorName.Should().Be("UnableToResolveFromRegisteredServices");
        }
 public async Task Server_Facade_Can_Be_Injected_Into_Handler_During_Creation_Using_Description(Side side)
 {
     Func <Task> a = () => Initialize(
         options => {
         if (side == Side.Client)
         {
             options.Services
             .AddSingleton(JsonRpcHandlerDescription.Infer(typeof(InterfaceHandler <ILanguageClientFacade>)));
         }
     },
         options => {
         if (side == Side.Server)
         {
             options.Services
             .AddSingleton(JsonRpcHandlerDescription.Infer(typeof(InterfaceHandler <ILanguageServerFacade>)));
         }
     }
         );
     await a.Should().NotThrowAsync();
 }