public void Slett_ikke_funnet_Post() { // Arrange var SessionMock = new TestControllerBuilder(); var controller = new RuteController(new RuteBLL(new RuteStub())); SessionMock.InitializeController(controller); controller.Session["LoggetInn"] = true; var innRute = new Rute() { RuteId = "OSLKRS000", ReiseFra = reiseFra, ReiseTil = reiseTil, Dato = "10.10.2017", Tid = "10:00", ReiseTid = "10min", Flymaskin = flymaskin, Pris = 999 }; // Act var actionResult = (ViewResult)controller.SlettRute("", innRute); // Assert Assert.AreEqual(actionResult.ViewName, "~/Views/Error/Error.cshtml"); }
public void Slettet_funnet_Post_session_ikke_OK() { // Arrange var SessionMock = new TestControllerBuilder(); var controller = new RuteController(new RuteBLL(new RuteStub())); SessionMock.InitializeController(controller); controller.Session["LoggetInn"] = false; var innRute = new Rute() { RuteId = "OSLKRS000", ReiseFra = reiseFra, ReiseTil = reiseTil, Dato = "10.10.2017", Tid = "10:00", ReiseTid = "10min", Flymaskin = flymaskin, Pris = 999 }; // Act var actionResult = (RedirectToRouteResult)controller.SlettRute("OSLKRS000", innRute); // Assert Assert.AreEqual(actionResult.RouteName, ""); Assert.AreEqual(actionResult.RouteValues.Values.First(), "IngenTilgang"); }
public async Task SlettRuteNotFound() { mockRepo.Setup(k => k.SlettRute(It.IsAny <int>())).ReturnsAsync(false); var ruteController = new RuteController(mockRepo.Object, mockLog.Object); mockSession[_loggetInn] = _loggetInn; mockHttpContext.Setup(s => s.Session).Returns(mockSession); ruteController.ControllerContext.HttpContext = mockHttpContext.Object; var resultat = await ruteController.SlettRute(It.IsAny <int>()) as NotFoundObjectResult; Assert.Equal((int)HttpStatusCode.NotFound, resultat.StatusCode); Assert.Equal("Kunne ikke slette ruten", resultat.Value); }
public void SlettRute_session_ikke_OK() { // Arrange var SessionMock = new TestControllerBuilder(); var controller = new RuteController(new RuteBLL(new RuteStub())); SessionMock.InitializeController(controller); controller.Session["LoggetInn"] = false; // Act var result = (RedirectToRouteResult)controller.SlettRute(""); // Assert Assert.AreEqual(result.RouteName, ""); Assert.AreEqual(result.RouteValues.Values.First(), "IngenTilgang"); }
public void SlettRute() { // Arrange var SessionMock = new TestControllerBuilder(); var controller = new RuteController(new RuteBLL(new RuteStub())); SessionMock.InitializeController(controller); controller.Session["LoggetInn"] = true; // Act var actionResult = (ViewResult)controller.SlettRute(""); var resultat = (Rute)actionResult.Model; // Assert Assert.AreEqual(actionResult.ViewName, ""); }