Beispiel #1
0
        public void ProductGetRouteTest()
        {
            // Setup
            var         productRepositoryMock = new ProductRepositoryMock();
            RouteHelper testHelper            = RouteHelper.Create();

            testHelper.Resolver.RegisterInstance <IProductRepository>(productRepositoryMock);

            // Action
            var products = testHelper.Get("api/product");

            // Assertion
            Assert.IsTrue(productRepositoryMock.RetrieveProductsCalled);
        }
Beispiel #2
0
        public static RouteHelper Create()
        {
            if (_instance == null)
            {
                _instance = new RouteHelper();

                _instance.Config   = new HttpConfiguration();
                _instance.Resolver = new UnityContainer();
                _instance.Config.DependencyResolver = new UnityDependencyResolver(_instance.Resolver);
                WebRouting.WebApiConfig.Register(_instance.Config);

                var server = new HttpServer(_instance.Config);

                _instance._client             = new HttpClient(server);
                _instance._client.BaseAddress = new Uri("http://routetest/api");
            }

            return(_instance);
        }