public void registreradmin_Post_Ok()
        {
            var mock = new Mock<ControllerContext>();
            mock.SetupGet(u => u.HttpContext.Request.IsAuthenticated).Returns(true);
            mock.SetupGet(u => u.HttpContext.User.Identity.Name).Returns("123");
            var ansatte = new RegisterAnsattModel()
            {
                AnsattNr = "s1",
                Epost = "*****@*****.**",
                Firstname = "Arne",
                Lastname = "Hansen",
                Stilling = "Leder"
            };

            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.registrerAdmin(ansatte, "leder");
            Assert.AreEqual("Index", 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 registrer_post_modelfeil()
        {
            var mock = new Mock<ControllerContext>();
            var controller = new AdminController(new Mock<IAuth>().Object, new AdminLogikk(new ansattRepositoryStub()),
                new ProdukterLogikk(new ProduktRepositoryStub()), new KundeLogikk(new KundeRepositoryStub()));
            controller.ControllerContext = mock.Object;
            controller.ViewData.ModelState.AddModelError("", "Feil");
            var resultat = (ViewResult)controller.registrerAdmin(null,"Leder");

            //act
            //assert
            Assert.IsTrue(resultat.ViewData.ModelState.Count == 1);
            Assert.IsTrue(resultat.ViewName == "");
        }
        public void registreradmin_notOK()
        {
            var mock = new Mock<ControllerContext>();
            mock.SetupGet(u => u.HttpContext.Request.IsAuthenticated).Returns(true);
            mock.SetupGet(u => u.HttpContext.User.Identity.Name).Returns("123");
            var ansatte = new Admin()
            {
                AnsattId = "s1",
                Epost = "*****@*****.**",
                Firstname = "Arne",
                Lastname = "Hansen",
                Stilling = "Leder"
            };

            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 = (ViewResult)controller.registrerAdmin();
            var k = (RegisterAnsattModel)viewResult.Model;
            Assert.AreEqual("s1000", k.AnsattNr);
        }