Пример #1
0
        public void Setup()
        {
            if (businessAPIController == null)
            {
                // var controllerContext = new Mock<ControllerContext>();
                // var principal = new Moq.Mock<IPrincipal>();
                //// principal.Setup(p => p.IsInRole("Administrator")).Returns(true);
                // principal.SetupGet(x => x.Identity.Name).Returns("*****@*****.**");
                // controllerContext.SetupGet(x => x.HttpContext.User).Returns(principal.Object);

                var request = new Mock <HttpRequestBase>();
                // request.SetupGet(r => r.Form).Returns(formData);
                var context = new Mock <HttpContextBase>();
                context.SetupGet(c => c.Request).Returns(request.Object);


                businessAPIController = new BusinessAPIController();
                //HttpControllerContext context = new HttpControllerContext(new RequestContext(mockContext, new RouteData()), businessAPIController);
                //businessAPIController.ControllerContext = controllerContext.Object; ;
                businessAPIController.ControllerContext = new ControllerContext(context.Object, new RouteData(), businessAPIController);

                HelperMethods.SetupPostControllerForTest(businessAPIController, "BusinessAPI");
            }

            AutoMapperConfig.Configure();

            if (RouteTable.Routes.Count == 0)
            {
                RouteConfig.RegisterRoutes(RouteTable.Routes);
            }
        }
Пример #2
0
        public void Setup()
        {
            if (businessAPIController == null)
            {
                businessAPIController = new BusinessAPIController();
                HelperMethods.SetupPostControllerForTest(businessAPIController, "BusinessAPI");
            }

            AutoMapperConfig.Configure();

            if (RouteTable.Routes.Count == 0)
            {
                RouteConfig.RegisterRoutes(RouteTable.Routes);
            }
        }