Пример #1
0
        public void With_NServiceKitFunq()
        {
            serviceController.Register(typeof(BasicRequest), typeof(BasicService));
            var request = new BasicRequest();

            Console.WriteLine("With_TypedArguments(): {0}", Measure(() => serviceController.Execute(request), Times));
        }
Пример #2
0
        public void NativeFunq_Perf()
        {
            RegisterServices(serviceController, GetNativeFunqTypeFactory());

            StoreAndGetCustomers(serviceController);

            var request = new GetCustomer {
                CustomerId = 2
            };

            Console.WriteLine("NativeFunq_Perf(): {0}", Measure(() => serviceController.Execute(request), Times));
        }
Пример #3
0
        private void ServiceControllerExecute(string serviceName)
        {
            ServiceQuery queryTask = new ServiceQuery();

            queryTask.BuildEngine = new MockBuild();
            queryTask.ServiceName = serviceName;
            Assert.IsTrue(queryTask.Execute(), "Execute query failed");

            ServiceController task = new ServiceController();

            task.BuildEngine = new MockBuild();
            task.ServiceName = serviceName;

            if (ServiceQuery.UNKNOWN_STATUS.Equals(queryTask.Status))
            {
                Assert.Ignore("Couldn't find the '{0}' service on '{1}'",
                              queryTask.ServiceName, queryTask.MachineName);
            }
            else if (ServiceControllerStatus.Stopped.ToString().Equals(queryTask.Status))
            {
                task.Action = "Start";
            }
            else if (ServiceControllerStatus.Running.ToString().Equals(queryTask.Status))
            {
                task.Action = "Restart";
            }
            else
            {
                Assert.Ignore("'{0}' service on '{1}' is '{2}'",
                              queryTask.ServiceName, queryTask.MachineName, queryTask.Status);
            }

            Assert.IsTrue(task.Execute(), "Execute Failed");
            Assert.IsNotNull(task.Status, "Status Null");
        }
        public TResponse Get <TResponse>(string relativeOrAbsoluteUrl)
        {
            httpReq.HttpMethod = HttpMethods.Get;

            var requestTypeName = typeof(TResponse).Namespace + "." + relativeOrAbsoluteUrl;
            var requestType     = typeof(TResponse).Assembly.GetType(requestTypeName);

            if (requestType == null)
            {
                throw new ArgumentException("Type not found: " + requestTypeName);
            }

            var request = requestType.CreateInstance();

            if (ApplyRequestFilters <TResponse>(request))
            {
                return(default(TResponse));
            }

            httpReq.HttpMethod = HttpMethods.Get;
            var response = ServiceController.Execute(request, httpReq);

            if (ApplyResponseFilters <TResponse>(response))
            {
                return((TResponse)response);
            }

            return((TResponse)response);
        }
 public virtual object ExecuteService(object requestDto, IRequest request)
 {
     using (Profiler.Current.Step("Execute Service"))
     {
         return(ServiceController.Execute(requestDto, request));
     }
 }
Пример #6
0
        public void Can_execute_BasicService()
        {
            serviceController.RegisterService(typeof(BasicService));
            var result = serviceController.Execute(new EmptyRequest()) as EmptyRequestResponse;

            Assert.That(result, Is.Not.Null);
        }
Пример #7
0
        public void Can_execute_BasicService()
        {
            serviceController.Register(() => new BasicService());
            var result = serviceController.Execute(new BasicRequest()) as BasicRequestResponse;

            Assert.That(result, Is.Not.Null);
        }
Пример #8
0
        public void With_TypedArguments()
        {
            var serviceController = new ServiceController();

            serviceController.Register(() => new BasicService());
            var request = new BasicRequest();

            Console.WriteLine("With_TypedArguments(): {0}", Measure(() => serviceController.Execute(request), Times));
        }
Пример #9
0
        public void Can_execute_BasicService()
        {
            var serviceController = new ServiceController();

            serviceController.Register(() => new BasicService());
            var result = serviceController.Execute(new BasicRequest()) as BasicRequestResponse;

            Assert.That(result, Is.Not.Null);
        }
Пример #10
0
        public void With_Expressions()
        {
            var requestType = typeof(BasicRequest);
            var serviceController = new ServiceController();

            serviceController.Register(requestType, typeof(BasicService));
            var request = new BasicRequest();

            Console.WriteLine("With_Expressions(): {0}", Measure(() => serviceController.Execute(request), Times));
        }
Пример #11
0
        public void Can_execute_RestTestService()
        {
            var serviceController = new ServiceController();

            serviceController.Register(() => new RestTestService());
            var result = serviceController.Execute(new RestTest()) as RestTestResponse;

            Assert.That(result, Is.Not.Null);
            Assert.That(result.MethodName, Is.EqualTo("Execute"));
        }
Пример #12
0
        public void With_Expressions()
        {
            var requestType       = typeof(BasicRequest);
            var serviceController = new ServiceController();

            serviceController.Register(requestType, typeof(BasicService));
            var request = new BasicRequest();

            Console.WriteLine("With_Expressions(): {0}", Measure(() => serviceController.Execute(request), Times));
        }
Пример #13
0
        public void Can_execute_RestTestService()
        {
            var serviceController = new ServiceController();

            serviceController.Register(() => new RestTestService());
            var result = serviceController.Execute(new RestTest()) as RestTestResponse;

            Assert.That(result, Is.Not.Null);
            Assert.That(result.MethodName, Is.EqualTo("Execute"));
        }
Пример #14
0
        public void NativeFunq_Perf()
        {
            var serviceController = new ServiceController();

            RegisterServices(serviceController, GetNativeFunqTypeFactory());

            StoreAndGetCustomers(serviceController);

            var request = new GetCustomer { CustomerId = 2 };
            Console.WriteLine("NativeFunq_Perf(): {0}", Measure(() => serviceController.Execute(request), Times));
        }
Пример #15
0
        public void Can_RestTestService_GET()
        {
            var serviceController = new ServiceController();

            serviceController.Register(() => new RestTestService());
            var result = serviceController.Execute(new RestTest(),
                                                   new HttpRequestContext(null, EndpointAttributes.HttpGet)) as RestTestResponse;

            Assert.That(result, Is.Not.Null);
            Assert.That(result.MethodName, Is.EqualTo("Get"));
        }
Пример #16
0
        public void Can_execute_BasicService_from_dynamic_Type()
        {
            var requestType = typeof(BasicRequest);

            var serviceController = new ServiceController();
            serviceController.Register(requestType, typeof(BasicService));

            object request = Activator.CreateInstance(requestType);

            var result = serviceController.Execute(request) as BasicRequestResponse;

            Assert.That(result, Is.Not.Null);
        }
Пример #17
0
        private static void StoreAndGetCustomers(ServiceController serviceController)
        {
            var storeCustomers = new StoreCustomers
            {
                Customers =
                {
                    new Customer {
                        Id = 1, FirstName = "First", LastName = "Customer"
                    },
                    new Customer {
                        Id = 2, FirstName = "Second", LastName = "Customer"
                    },
                }
            };

            serviceController.Execute(storeCustomers);

            storeCustomers = new StoreCustomers
            {
                Customers =
                {
                    new Customer {
                        Id = 3, FirstName = "Third", LastName = "Customer"
                    },
                }
            };
            serviceController.Execute(storeCustomers);

            var response = serviceController.Execute(new GetCustomer {
                CustomerId = 2
            });

            Assert.That(response as GetCustomerResponse, Is.Not.Null);

            var customer = ((GetCustomerResponse)response).Customer;

            Assert.That(customer.FirstName, Is.EqualTo("Second"));
        }
Пример #18
0
        public void Can_execute_BasicService_from_dynamic_Type()
        {
            var requestType = typeof(BasicRequest);

            var serviceController = new ServiceController();

            serviceController.Register(requestType, typeof(BasicService));

            object request = Activator.CreateInstance(requestType);

            var result = serviceController.Execute(request) as BasicRequestResponse;

            Assert.That(result, Is.Not.Null);
        }
Пример #19
0
        public void Service_Execute_Zorgtoeslag_From_Url()
        {
            ServiceController controller = new ServiceController(InitMoqLogger(), new YamlScriptController(), InitMoqRoutingController());
            var executeRequest           = new ExecuteRequest()
            {
                Config     = YamlTestFileLoader.Load(@"Rijksoverheid/Zorgtoeslag.yaml"),
                Parameters = new ParametersCollection()
                {
                    new ClientParameter("alleenstaande", "ja", TypeInference.InferenceResult.TypeEnum.Boolean, "Dummy")
                }
            };

            var payload = JsonConvert.SerializeObject(executeRequest);
            var result  = controller.Execute(executeRequest);

            Assert.True(result.Questions.Parameters.Count == 1);
            Assert.True(result.Questions.Parameters[0].Name == "woonland");
        }
        public TResponse Send <TResponse>(object request)
        {
            httpReq.HttpMethod = HttpMethods.Post;
            httpReq.Dto        = request;

            if (ApplyRequestFilters <TResponse>(request))
            {
                return(default(TResponse));
            }

            this.PopulateRequestMetadata(request);

            httpReq.HttpMethod = HttpMethods.Post;
            var response = ServiceController.Execute(request, httpReq);

            if (ApplyResponseFilters <TResponse>(response))
            {
                return((TResponse)response);
            }

            return((TResponse)response);
        }
Пример #21
0
 public virtual object ExecuteService(object requestDto, RequestAttributes requestAttributes)
 {
     return(ServiceController.Execute(requestDto, new BasicRequest(requestDto, requestAttributes)));
 }
Пример #22
0
 public virtual object ExecuteService(object requestDto, IRequest req)
 {
     return(ServiceController.Execute(requestDto, req));
 }
Пример #23
0
 public void SendOneWay(object requestDto)
 {
     ServiceManager.Execute(requestDto);
 }
 public void SendOneWay(string relativeOrAbsoluteUri, object requestDto)
 {
     ServiceController.Execute(requestDto);
 }
 public void SendOneWay(object requestDto)
 {
     ServiceController.Execute(requestDto);
 }
Пример #26
0
        public void With_TypedArguments()
        {
            var serviceController = new ServiceController();

            serviceController.Register(() => new BasicService());
            var request = new BasicRequest();

            Console.WriteLine("With_TypedArguments(): {0}", Measure(() => serviceController.Execute(request), Times));
        }
Пример #27
0
        private static void StoreAndGetCustomers(ServiceController serviceController)
        {
            var storeCustomers = new StoreCustomers {
                Customers = {
                    new Customer { Id = 1, FirstName = "First", LastName = "Customer" },
                    new Customer { Id = 2, FirstName = "Second", LastName = "Customer" },
                }
            };
            serviceController.Execute(storeCustomers);

            storeCustomers = new StoreCustomers {
                Customers = {
                    new Customer {Id = 3, FirstName = "Third", LastName = "Customer"},
                }
            };
            serviceController.Execute(storeCustomers);

            var response = serviceController.Execute(new GetCustomer { CustomerId = 2 });

            Assert.That(response as GetCustomerResponse, Is.Not.Null);

            var customer = ((GetCustomerResponse)response).Customer;
            Assert.That(customer.FirstName, Is.EqualTo("Second"));
        }
Пример #28
0
        public void Can_RestTestService_DELETE()
        {
            var serviceController = new ServiceController();

            serviceController.Register(() => new RestTestService());
            var result = serviceController.Execute(new RestTest(),
                new HttpRequestContext((object)null, EndpointAttributes.HttpDelete)) as RestTestResponse;

            Assert.That(result, Is.Not.Null);
            Assert.That(result.MethodName, Is.EqualTo("Delete"));
        }