public void index_ikkeloggetinn()
        {
            var mock = new Mock<ControllerContext>();

            mock.SetupGet(u => u.HttpContext.Request.IsAuthenticated).Returns(false);
            mock.SetupGet(u => u.HttpContext.User.Identity.Name).Returns("");
            var controller = new AdminController(new Mock<IAuth>().Object, new AdminLogikk(new ansattRepositoryStub()),
                new ProdukterLogikk(new ProduktRepositoryStub()), new KundeLogikk(new KundeRepositoryStub()));
            controller.ControllerContext = mock.Object;
            var viewResult = (RedirectToRouteResult)controller.Index();

            Assert.AreEqual("logginn", viewResult.RouteValues["Action"]); //<---view som blir vist hvis er requested-->)
            Assert.AreEqual("Admin", viewResult.RouteValues["Controller"]); //<---view som blir vist hvis er requested-->)
        }
        public void index_ok()
        {
            var mock = new Mock<ControllerContext>();
               // var identity = new Mock<IIdentity>();
            mock.SetupGet(u => u.HttpContext.Request.IsAuthenticated).Returns(true);
            mock.SetupGet(u => u.HttpContext.User.Identity.Name).Returns("bruker");
            // identity.SetupGet(u => u.Name).Returns("s1000");
            var controller = new AdminController(new Mock<IAuth>().Object, new AdminLogikk(new ansattRepositoryStub()),
                new ProdukterLogikk(new ProduktRepositoryStub()), new KundeLogikk(new KundeRepositoryStub()));
            controller.ControllerContext = mock.Object;
               // var context = new Mock<HttpContextBase>();
            //context.SetupGet(x => x.Request).Returns(request.Object);

               // controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);
            //test
            ViewResult viewResult = (ViewResult)controller.Index();
            Assert.IsTrue(viewResult.ViewName == "");//<---view som blir vist hvis er requested-->)
        }
        public void index_bruker_null()
        {
            var mock = new Mock<ControllerContext>();
            mock.SetupGet(u => u.HttpContext.Request.IsAuthenticated).Returns(true);
            mock.SetupGet(u => u.HttpContext.User.Identity.Name).Returns("");
            var controller = new AdminController(new Mock<IAuth>().Object, new AdminLogikk(new ansattRepositoryStub()),
                new ProdukterLogikk(new ProduktRepositoryStub()), new KundeLogikk(new KundeRepositoryStub()));
            controller.ControllerContext = mock.Object;
            // var context = new Mock<HttpContextBase>();
            //context.SetupGet(x => x.Request).Returns(request.Object);

            // controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);
            //test
            var viewResult = (RedirectToRouteResult)controller.Index();

            Assert.AreEqual("logginn", viewResult.RouteValues["Action"]); //<---view som blir vist hvis er requested-->)
            Assert.AreEqual("Admin", viewResult.RouteValues["Controller"]); //<---view som blir vist hvis er requested-->)
        }