public void endreReise_FEIL() { //Arrange var SessionMock = new TestControllerBuilder(); var controller = new ClearSkiesController(new AirlineLogikk(new AirlineDALStub())); SessionMock.InitializeController(controller); controller.Session["LoggetInn"] = true; DateTime dato = new DateTime(2017, 10, 20); DateTime tid1 = new DateTime(2017, 10, 20, 12, 00, 0); DateTime tid2 = new DateTime(2017, 10, 20, 14, 00, 0); Model.ReiseReg reise = new Model.ReiseReg() { Fra = "Oslo", Destinasjon = "Bergen", Avreise = dato, AvreiseTid = tid1, Ankomst = dato, AnkomstTid = tid2, Kapasitet = 150, Pris = 299 }; //Act var result = (ViewResult)controller.endreReise(2, reise); //Assert Assert.AreEqual(result.ViewName, ""); Assert.IsNotNull(result.ViewBag.Feil); Assert.AreEqual(true, result.ViewBag.Feil); }
public void endreReise_OK() { //Arrange var SessionMock = new TestControllerBuilder(); var controller = new ClearSkiesController(new AirlineLogikk(new AirlineDALStub())); SessionMock.InitializeController(controller); controller.Session["LoggetInn"] = true; DateTime dato = new DateTime(2017, 10, 20); DateTime tid1 = new DateTime(2017, 10, 20, 12, 00, 0); DateTime tid2 = new DateTime(2017, 10, 20, 14, 00, 0); Model.ReiseReg reise = new Model.ReiseReg() { Fra = "Oslo", Destinasjon = "Bergen", Avreise = dato, AvreiseTid = tid1, Ankomst = dato, AnkomstTid = tid2, Kapasitet = 150, Pris = 299 }; //Act var result = (RedirectToRouteResult)controller.endreReise(1, reise); //Assert result.AssertActionRedirect().ToAction("AdministrerReiser"); }
public void EndreReise_IKKE_LOGGET_INN() { //Arrange var SessionMock = new TestControllerBuilder(); var controller = new ClearSkiesController(); SessionMock.InitializeController(controller); controller.Session["LoggetInn"] = false; //Act var actionResult = (RedirectToRouteResult)controller.endreReise(1); //Assert Assert.AreEqual("Login", actionResult.RouteValues.Values.First()); }
public void hentEnReise_FANT_FAIL() { //Arrange var SessionMock = new TestControllerBuilder(); var controller = new ClearSkiesController(new AirlineLogikk(new AirlineDALStub())); SessionMock.InitializeController(controller); controller.Session["LoggetInn"] = true; Model.ReiseReg funnetReise = new Model.ReiseReg() { Ankomst = new DateTime(2017, 12, 20), AnkomstTid = new DateTime(2017, 12, 20, 14, 0, 0), Avreise = new DateTime(2017, 12, 20), AvreiseTid = new DateTime(2017, 12, 20, 14, 0, 0), Destinasjon = "New York", Fra = "Oslo", Kapasitet = 150, Pris = 500 }; //Act var result = (ViewResult)controller.endreReise(6); var hentetReise = result.Model as Model.ReiseReg; //Assert Assert.AreEqual("", result.ViewName); Assert.AreEqual(funnetReise.Ankomst, hentetReise.Ankomst); Assert.AreEqual(funnetReise.AnkomstTid, hentetReise.AnkomstTid); Assert.AreEqual(funnetReise.Avreise, hentetReise.Avreise); Assert.AreEqual(funnetReise.AvreiseTid, hentetReise.AvreiseTid); Assert.AreNotEqual(funnetReise.Destinasjon, hentetReise.Destinasjon); Assert.AreNotEqual(funnetReise.Fra, hentetReise.Fra); Assert.AreNotEqual(funnetReise.Pris, hentetReise.Pris); Assert.AreEqual(funnetReise.Kapasitet, hentetReise.Kapasitet); }