Пример #1
0
Файл: Rpc.cs Проект: Sholtee/rpc
        public async Task Context_ShouldBeAccessible()
        {
            var mockModule = new Mock <IModule>(MockBehavior.Strict);

            mockModule.Setup(i => i.Dummy());

            IRequestContext context = null;

            Server.Register(injector =>
            {
                context = injector.Get <IRequestContext>();

                return(mockModule.Object);
            });
            Server.Start(Host);

            ClientFactory.SessionId = "cica";

            IModule proxy = await ClientFactory.CreateClient <IModule>();

            proxy.Dummy();

            Assert.That(context, Is.Not.Null);
            Assert.That(context.SessionId, Is.EqualTo("cica"));
            Assert.That(context.Module, Is.EqualTo(nameof(IModule)));
            Assert.That(context.Method, Is.EqualTo(nameof(IModule.Dummy)));
        }
Пример #2
0
Файл: Rpc.cs Проект: Sholtee/rpc
        public async Task Logger_ShouldBeAccessible()
        {
            var mockModule = new Mock <IModule>(MockBehavior.Strict);

            mockModule.Setup(i => i.Dummy());

            ILogger logger = null;

            Server.Register(injector =>
            {
                logger = injector.Get <ILogger>();

                return(mockModule.Object);
            });
            Server.Start(Host);

            IModule proxy = await ClientFactory.CreateClient <IModule>();

            proxy.Dummy();

            Assert.That(logger, Is.Not.Null);
        }