Exemplo n.º 1
0
        public void AddToFavourite()
        {
            var controllerContext = new Mock <ControllerContext>();
            var principal         = new Mock <IPrincipal>();

            principal.Setup(p => p.IsInRole("Administrator")).Returns(true);
            principal.SetupGet(x => x.Identity.Name).Returns("rr");
            controllerContext.SetupGet(x => x.HttpContext.User).Returns(principal.Object);
            controller.ControllerContext = controllerContext.Object;

            RedirectToRouteResult result = controller.AddToFavourite(1) as RedirectToRouteResult;

            Assert.IsTrue(result != null);
        }