public void AdministrerBestillinger_IKKE_LOGGET_INN() { //Arrange var SessionMock = new TestControllerBuilder(); var controller = new ClearSkiesController(); SessionMock.InitializeController(controller); controller.Session["LoggetInn"] = false; //Act var actionResult = (RedirectToRouteResult)controller.AdministrerBestillinger("", "", "", 0); //Assert Assert.AreEqual("Login", actionResult.RouteValues.Values.First()); }
public void hentAlleBestillinger_OK() { //Arrange var SessionMock = new TestControllerBuilder(); var controller = new ClearSkiesController(new AirlineLogikk(new AirlineDALStub())); SessionMock.InitializeController(controller); controller.Session["LoggetInn"] = true; Model.BestillingView best = new Model.BestillingView() { AntallBilletter = 2, Eier = "Donal Duck", HandelId = 1, TotalPris = 598 }; //Act var result = (ViewResult)controller.AdministrerBestillinger("", "", "", 0); var listResult = (PagedList.IPagedList <Model.BestillingView>)result.Model; List <Model.BestillingView> konvertert = new List <Model.BestillingView>(); //Assert Assert.AreEqual("", result.ViewName); foreach (var k in listResult) { Model.BestillingView bestKonv = new Model.BestillingView() { AntallBilletter = k.AntallBilletter, Eier = k.Eier, HandelId = k.HandelId, TotalPris = k.TotalPris }; konvertert.Add(bestKonv); } foreach (var k in konvertert) { Assert.AreEqual(best.HandelId, k.HandelId); Assert.AreEqual(best.Eier, k.Eier); Assert.AreEqual(best.AntallBilletter, k.AntallBilletter); Assert.AreEqual(best.TotalPris, k.TotalPris); } }