Exemple #1
0
        public void AddLike()
        {
            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("*****@*****.**");
            controllerContext.SetupGet(x => x.HttpContext.User).Returns(principal.Object);
            controller.ControllerContext = controllerContext.Object;

            LikeModel like = new LikeModel
            {
                RecipeId = 1
            };

            ViewResult result = controller.Like(like) as ViewResult;
            var        added  = db.FindLike("1", 1);

            Assert.AreNotEqual(null, added);
        }