public void Returns_Null_For_Missing_Method()
            {
                // Given
                var builder = new MethodCacheBuilder(new[] { new JsonRpcServiceFake() });

                // When
                var result = builder.Build().Get("missing.method");

                // Then
                Assert.Null(result);
            }
            public void Returns_Empty_Cache_When_Given_No_Services()
            {
                // Given
                var builder = new MethodCacheBuilder(Enumerable.Empty<IJsonRpcService>());

                // When
                var result = builder.Build();

                // Then
                Assert.Equal(0, result.GetAll().Count());
            }
            public void Returns_Cache_With_Services_When_Services_Is_Not_Empty()
            {
                // Given
                var builder = new MethodCacheBuilder(new[] { new JsonRpcServiceFake() });

                // When
                var result = builder.Build();

                // Then
                Assert.NotNull(result.Get("test"));
            }
            public void Throws_MethodNameAlreadyRegistered_For_Duplicate_Method_Names()
            {
                // Given
                var builder = new MethodCacheBuilder(new[] { new JsonRpcServiceFake(), new JsonRpcServiceFake() });

                // When
                var exception = Record.Exception(() => builder.Build());

                // Then
                Assert.IsType<MethodNameAlreadyRegisteredException>(exception);
                Assert.Equal("test", ((MethodNameAlreadyRegisteredException) exception).MethodName);
            }
示例#5
0
        private static RequestHandler CreateRequestHandler(params IJsonRpcService[] services)
        {
            var cacheBuilder = new MethodCacheBuilder(services);
            var nameResolver = new ByNameResolver(new JsonSerializer());
            var positionResolver = new ByPositionResolver(new JsonSerializer());
            var nullResolver = new NullResolver();

            return new RequestHandler(cacheBuilder,
                new IParameterResolver[] { nameResolver, positionResolver, nullResolver });
        }