Ejemplo n.º 1
0
        public void CreateControllerContext_ContextShouldBeValid()
        {
            var controller    = new TestController();
            var controllerCtx = _ctx.CreateControllerContext(controller);

            Assert.IsNotNull(controllerCtx);
            Assert.AreSame(_ctx, controllerCtx.HttpContext);
            Assert.AreSame(controller, controllerCtx.Controller);
        }
        public void SetUp()
        {
            _user = new UserInfo {
                Permissions = new string[0]
            };
            _mockAuth = new Mock <IAuthentication>();
            _mockAuth.Setup(m => m.GetUser(It.IsAny <string>())).Returns(_user);
            var userManager = new UserManager(_mockAuth.Object);
            var resolver    = new NinjectDependencyResolver();

            resolver.Kernel.Bind <UserManager>().ToConstant(userManager);
            DependencyResolver.SetResolver(resolver);

            _mockCtx = new MockHttpContext();
            _mockCtx.SetUser("user");
            var controller    = new TestController();
            var controllerCtx = _mockCtx.CreateControllerContext(controller);
            var descriptor    = new Mock <ActionDescriptor>().Object;

            _execCtx = new ActionExecutingContext(controllerCtx, descriptor, new Dictionary <string, object>());
            _filter  = new PermissionAttribute("p1");
        }