예제 #1
0
        /// <summary>
        /// Inject alternative container and strategy for resolving Service Types
        /// </summary>
        public ServiceManager(Container container, ServiceController serviceController)
        {
            if (serviceController == null)
                throw new ArgumentNullException("serviceController");

            this.Container = container ?? new Container();
            this.Metadata = serviceController.Metadata; //always share the same metadata
            this.ServiceController = serviceController;

            typeFactory = new ContainerResolveCache(this.Container);
        }
예제 #2
0
        public void SetUp()
		{
            appHost = new BasicAppHost().Init();
            serviceController = appHost.ServiceController;
		}
예제 #3
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"));
		}
예제 #4
0
		public void OnBeforeEachTest()
		{
			serviceController = new ServiceController(null);
		}
예제 #5
0
		private static void RegisterServices(ServiceController serviceController, ITypeFactory typeFactory)
		{
			serviceController.RegisterServiceExecutor(typeof(StoreCustomers), typeof(StoreCustomersService), typeFactory);
			serviceController.RegisterServiceExecutor(typeof(GetCustomer), typeof(GetCustomerService), typeFactory);
		}
        public void Does_throw_on_invalid_Route_Definitions()
        {
            AppHostConfig.SkipRouteValidation = false;

            var controller = new ServiceController(() => new[] { typeof(MyService) });

            Assert.Throws<ArgumentException>(
                () => controller.RegisterRestPaths(typeof(NoSlashPrefix)));

            Assert.Throws<ArgumentException>(
                () => controller.RegisterRestPaths(typeof(UsesQueryString)));

            AppHostConfig.SkipRouteValidation = true;
        }