Example #1
0
        private static void Main(string[] args)
        {

            //new design
            //simple
            var service = new ProxyService();
            service.BeforeCall += (p) =>
            {
                Console.WriteLine("Before Call");
            };
            service.AfterCall += (p) =>
            {
                Console.WriteLine("After Call");
                if (p.ProxiedMethod.Name.IndexOf("Name") != -1)
                    p.ReturnValue = 100;
            };
            var item = service.Create<TestWrapper>();
            item.GetAll(1, "213");
            item.Name = 5;
            item.Name1 = null;
            Console.WriteLine(item.Name);

            //service.AfterCall = () => { Console.WriteLine("After Call2"); };
            //var item2 = service.Create<TestWrapper2>();
            //item2.Test("213");
        }
 public void CrossDomainSampleTestWithSerializableClass()
 {
     try
     {
         ProxyService service = new ProxyService();
         var wrapper = service.Create<TestWrapper0>();
         wrapper.Test();
         Assert.Fail("should throw exception");
     }
     catch (Exception e)
     {
     }
 }
Example #3
0
        public async void Create()
        {
            var mock  = new ServiceMockFacade <IProxyRepository>();
            var model = new ApiProxyRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <Proxy>())).Returns(Task.FromResult(new Proxy()));
            var service = new ProxyService(mock.LoggerMock.Object,
                                           mock.RepositoryMock.Object,
                                           mock.ModelValidatorMockFactory.ProxyModelValidatorMock.Object,
                                           mock.BOLMapperMockFactory.BOLProxyMapperMock,
                                           mock.DALMapperMockFactory.DALProxyMapperMock);

            CreateResponse <ApiProxyResponseModel> response = await service.Create(model);

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.ProxyModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiProxyRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <Proxy>()));
        }
 public void Can_Proxy_Normal_Class()
 {
     ProxyService service = new ProxyService();
     service.BeforeCall += (p) =>
     {
         if (p.Method.Name == "TestParams")
         {
             Assert.AreEqual(p.Arguments[0].GetType(), typeof(int[]));
         }
     };
     service.AfterCall += (p) =>
     {
     };
     var ac = service.Create<Normal>();
     var r = ac.WithDuplexName(true, 1, "abc");
     ac.Do(5);
     ac.Do("abc");
     ac.Do(5, "abc");
     ac.Do(new object[] { });
     ac.TestParams(1, 2, 3);
     ac.Name = "Name";
 }
 public void Can_Proxy_Function_Class()
 {
     ProxyService service = new ProxyService();
     service.BeforeCall += (p) =>
     {
         Assert.AreEqual(2, p.Arguments.Length);
         Assert.AreEqual("aaa", p.Arguments[0]);
         Assert.AreEqual(100, p.Arguments[1]);
         p.Arguments[0] = p.Arguments[0] + "_BeforeCall_";
         p.Arguments[1] = (int)p.Arguments[1] + 100;
     };
     service.AfterCall += (p) =>
     {
         Assert.AreEqual("aaa_BeforeCall_200", p.ReturnValue);
         p.ReturnValue = p.ReturnValue + "_AfterCall";
     };
     var ac = service.Create<InheritClass>();
     var r = ac.Do("aaa", 100);
     Assert.AreEqual("aaa_BeforeCall_200_AfterCall", r);
     r = ac.DoNotProxy("aaa", 100);
     Assert.AreEqual("aaa100", r);
 }
 public override Task <Proxy> Create(Proxy request, ServerCallContext context)
 {
     return(Task.FromResult((Proxy)proxyService.Create((ProxyVM)request)));
 }
 public IActionResult Create(ProxyVM proxyInput)
 {
     return(Ok(proxyService.Create(proxyInput)));
 }
        public void CrossDomainSampleTestWithMarshalByRefObject()
        {

            ProxyService service = new ProxyService();
            var wrapper = service.Create<TestWrapper2>();
            wrapper.Test();
        }
        public void CrossDomainSampleTestWithSerializableClass2()
        {

            ProxyService service = new ProxyService();
            var wrapper = service.Create<TestWrapper1>();
            wrapper.Test();
        }