Beispiel #1
0
        public void TestTypeRegistration()
        {
            using (new AssertionScope())
                using (var listener = new JsonRpcServer(new MockService()))
                {
                    listener.Register(typeof(RpcTargetMock));

                    var registry = listener.GetRegisteredMethods();

                    registry.Should().Contain("Canary");
                }
        }
Beispiel #2
0
        public void TestTypeRegistrationExplicit()
        {
            using (new AssertionScope())
                using (var listener = new JsonRpcServer(new MockService()))
                {
                    listener.Register(typeof(RpcTargetMock), "Canary");
                    listener.Register(typeof(RpcTargetMock), "Echo", "Pizza");

                    var registry = listener.GetRegisteredMethods();

                    registry.Should().Contain("Canary");
                    registry.Should().Contain("Pizza");

                    // ReSharper disable once AccessToDisposedClosure
                    Action testAction = () => listener.Register(typeof(RpcTargetMock), "thisIsNotAValidMethod");

                    testAction.Should().Throw <RpcRegistrationException>();
                }
        }