Exemple #1
0
        public void GetFavourites()
        {
            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;

            ViewResult result = controller.GetFavourites() as ViewResult;

            Assert.AreNotEqual(null, result.ViewBag.Recipes);
        }