public void edituserdata_ok()
        {
            var mock = new Mock<ControllerContext>();
            mock.SetupGet(u => u.HttpContext.Request.IsAuthenticated).Returns(true);
            mock.SetupGet(u => u.HttpContext.User.Identity.Name).Returns("");
            var t = new ChangeUserDataModel()
            {
                Email = "*****@*****.**",
                Firstname = "Hans",
                Lastname = "Hansen",
                Streetadress = "Osloveien 2",
                ZipCode = "1274",
                PhoneNr = "22225555"
            };

            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.EditUserData("ad");
            var k = (ChangeUserDataModel)viewResult.Model;

            Assert.AreEqual(t.Email, k.Email);
            Assert.AreEqual(t.Firstname, k.Firstname);
            Assert.AreEqual(t.Lastname, k.Lastname);
            Assert.AreEqual(t.Streetadress, k.Streetadress);
            Assert.AreEqual(t.ZipCode, k.ZipCode);
            Assert.AreEqual(t.PhoneNr, k.PhoneNr);
        }
        public void edituserdata_feil()
        {
            var mock = new Mock<ControllerContext>();
            mock.SetupGet(u => u.HttpContext.Request.IsAuthenticated).Returns(true);
            mock.SetupGet(u => u.HttpContext.User.Identity.Name).Returns("");
            var t = new ChangeUserDataModel()
            {
                Email = "0",

            };

            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.EditUserData("");
            var k = (ChangeUserDataModel)viewResult.Model;
            Assert.AreEqual(t.Email, k.Email);
        }
        public void edituserdata_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("");
            var t = new ChangeUserDataModel()
            {
                Email = "*****@*****.**",
                Firstname = "Hans",
                Lastname = "Hansen",
                Streetadress = "Osloveien 2",
                ZipCode = "1274",
                PhoneNr = "22225555"
            };

            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.EditUserData(t);
            Assert.AreEqual("visAlleKunder", 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 edituserdata_post_feil()
        {
            var mock = new Mock<ControllerContext>();
            mock.SetupGet(u => u.HttpContext.Request.IsAuthenticated).Returns(true);
            mock.SetupGet(u => u.HttpContext.User.Identity.Name).Returns("");
            var t = new ChangeUserDataModel();

            //act
            //assert

            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 viewResult = (ViewResult)controller.EditUserData(t);
            Assert.IsTrue(viewResult.ViewData.ModelState.Count == 1);
            Assert.IsTrue(viewResult.ViewName == "");
        }