Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Global.DefaultSerializer            = new JsonSerializer();
            Global.DefaultWatcher.IsDebugEnable = false;

            PrintHelp();



            ISomeService          realService = new DummyImplementation();
            IRpcServerCoordinator server      = RpcFactory.CreateServer(realService, serverId: "UnitTest");

            server.Start();


            string outValue;
            var    client = RpcFactory.CreateClient <ISomeService>();

            client.TryParse(out outValue);



            Console.WriteLine();
            Console.WriteLine();
            Global.DefaultWatcher.InfoFormat("Method TryParse was executed remotely, out value is {0}", outValue);
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();

            Global.DefaultWatcher.InfoFormat("... change the method to something else to continue to test");
            Console.ReadKey();
        }
Exemplo n.º 2
0
        public void Can_provide_request_queue_name()
        {
            // Action
            var server = RpcFactory.CreateServer(Substitute.For <ISomeService>(), "RequestQueue") as BurrowRpcServerCoordinator <ISomeService>;

            // Assert
            Assert.IsNotNull(server);
        }
Exemplo n.º 3
0
        public void Can_accept_null_params()
        {
            // Action
            var server = RpcFactory.CreateServer(Substitute.For <ISomeService>()) as BurrowRpcServerCoordinator <ISomeService>;

            // Assert
            Assert.IsNotNull(server);
        }
Exemplo n.º 4
0
        public void Should_use_DefaulRpcRouteFinder_and_create_durable_queue_even_if_not_provide_serverId()
        {
            // Arrange
            var model = Substitute.For <IModel>();

            InternalDependencies.RpcQueueHelper
            .When(x => x.CreateQueues(Arg.Any <string>(), Arg.Any <Action <IModel> >()))
            .Do(callInfo => callInfo.Arg <Action <IModel> >()(model));


            // Action
            var server = RpcFactory.CreateServer(Substitute.For <ISomeService>(), "RequestQueue") as BurrowRpcServerCoordinator <ISomeService>;

            Assert.IsNotNull(server);
            server.Start();

            // Assert
            model.Received(1).QueueDeclare("RequestQueue", true, false, false, Arg.Any <IDictionary <string, object> >());
        }
Exemplo n.º 5
0
        public void Should_use_DefaulRpcRouteFinder_and_declare_durable_request_queue()
        {
            // Arrange
            var model = Substitute.For <IModel>();

            InternalDependencies.RpcQueueHelper
            .When(x => x.CreateQueues(Arg.Any <string>(), Arg.Any <Action <IModel> >()))
            .Do(callInfo => callInfo.Arg <Action <IModel> >()(model));


            // Action
            var server = RpcFactory.CreateServer(Substitute.For <ISomeService>(), "RequestQueue", serverId: "ServerId") as BurrowRpcServerCoordinator <ISomeService>;

            Assert.IsNotNull(server);
            server.Start();

            // Assert
            model.Received().QueueDeclare("RequestQueue", true, false, false, Arg.Any <IDictionary <string, object> >());
            model.DidNotReceiveWithAnyArgs().ExchangeDeclare("", "", false, false, null);
            tunnel.Received(1).SubscribeAsync("ServerId", Arg.Any <Action <RpcRequest> >());
        }
Exemplo n.º 6
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            // Serialize Test
            string json = JsonConvert.SerializeObject(User.Super());
            object o    = JsonConvert.DeserializeObject(json, typeof(List <User>));

            Console.WriteLine("Deserialized type: {0}", o.GetType());

            bool logMessages = true;
            var  server      = RpcFactory.CreateServer <ICalculator>(new Calculator(), "tcp://127.0.0.1:13777", logMessages);

            server.Start();


            var calculator = RpcFactory.CreateClient <ICalculator>(">tcp://127.0.0.1:13777");            //, logClientMessage);
            var result     = calculator.Add(1, 2);

            Console.WriteLine("Result is: {0}", result);


            var programmers = calculator.Programmers();

            Console.WriteLine("Programmer Count: {0}", programmers.Count);


            var goodProgrammers = calculator.GoodProgrammers(programmers);

            Console.WriteLine("Good Programmer Count: {0}", goodProgrammers.Count);



            calculator.SetProgrammers(programmers);

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
            server.Stop();
            Console.WriteLine("Shutting Down..");
        }
Exemplo n.º 7
0
        public void Should_use_DefaulRpcRouteFinder_if_not_provide_serverId()
        {
            // Arrange
            var model = Substitute.For <IModel>();

            InternalDependencies.RpcQueueHelper = Substitute.For <IRpcQueueHelper>();
            InternalDependencies.RpcQueueHelper
            .When(x => x.CreateQueues(Arg.Any <string>(), Arg.Any <Action <IModel> >()))
            .Do(callInfo => callInfo.Arg <Action <IModel> >()(model));

            // Action

            var server = RpcFactory.CreateServer(Substitute.For <ISomeService>()) as BurrowRpcServerCoordinator <ISomeService>;

            Assert.IsNotNull(server);
            server.Start();

            // Assert
            model.Received(1).QueueDeclare("Burrow.Queue.Rpc.ISomeService.Requests", true, false, false, Arg.Any <IDictionary <string, object> >());
            model.DidNotReceive().ExchangeDeclare(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <bool>(), Arg.Any <bool>(), Arg.Any <IDictionary <string, object> >());
            tunnel.Received(1).SubscribeAsync(typeof(ISomeService).Name, Arg.Any <Action <RpcRequest> >());
        }