public void DeleteGetView() { var controller = new ItemCategoriesController(new CategoryBLL(new CategoryServiceStub())); var actionResult = (ViewResult)controller.Delete(1); Assert.AreEqual(actionResult.ViewName, ""); Assert.IsNotNull(actionResult.Model); }
public void CreateModelInvalid() { var controller = new ItemCategoriesController(new CategoryBLL(new CategoryServiceStub())); var forventet = new ItemCategory(); controller.ViewData.ModelState.AddModelError("CategoryName", ""); var actionResult = (ViewResult)controller.Create(forventet); Assert.AreEqual(actionResult.ViewName, ""); }
public void CreateModelOK() { var controller = new ItemCategoriesController(new CategoryBLL(new CategoryServiceStub())); var forventet = new ItemCategory { CategoryId = 1, CategoryName = "TestCategory" }; var actionResult = (RedirectToRouteResult)controller.Create(forventet); Assert.AreEqual(actionResult.RouteName, ""); Assert.IsTrue(actionResult.RouteValues.Values.Count == 1); Assert.AreEqual(actionResult.RouteValues.Values.First(), "Index"); }
public void DeleteNotValidId() { var SessionMock = new TestControllerBuilder(); var controller = new ItemCategoriesController(new CategoryBLL(new CategoryServiceStub())); SessionMock.InitializeController(controller); var actionResult = (RedirectToRouteResult)controller.DeleteConfirmed(99); Assert.AreEqual(actionResult.RouteName, ""); }
public void DeleteGetViewBadId() { var controller = new ItemCategoriesController(new CategoryBLL(new CategoryServiceStub())); var actionResult = (HttpStatusCodeResult)controller.Delete(99); Assert.AreEqual(actionResult.StatusCode, 404); }
public void CreateGetView() { var controller = new ItemCategoriesController(new CategoryBLL(new CategoryServiceStub())); var actionResult = (ViewResult)controller.Create(); Assert.AreEqual(actionResult.ViewName, ""); }
public void ItemCategoryList() { var controller = new ItemCategoriesController(new CategoryBLL(new CategoryServiceStub())); List<ItemCategory> forventetListe = new List<ItemCategory>(); var ItemCat = new ItemCategory { CategoryId = 1, CategoryName = "TestCategory" }; forventetListe.Add(ItemCat); forventetListe.Add(ItemCat); forventetListe.Add(ItemCat); var actionResultat = (ViewResult)controller.Index(); var resultat = (List<ItemCategory>)actionResultat.Model; Assert.AreEqual(actionResultat.ViewName, ""); for(var i = 0; i < resultat.Count; i++) { Assert.AreEqual(forventetListe[i].CategoryId, resultat[i].CategoryId); Assert.AreEqual(forventetListe[i].CategoryName, resultat[i].CategoryName); } }
public void ConstructorTest() { var controller = new ItemCategoriesController(); Assert.IsNotNull(controller); Assert.IsInstanceOfType(controller, typeof(Controller)); }
public void GetCategoryNameValidId() { var controller = new ItemCategoriesController(new CategoryBLL(new CategoryServiceStub())); var actionResult = controller.GetCategoryName(1); Assert.AreEqual(actionResult, "TestCategory"); }
public void getCategoryNameList() { var controller = new ItemCategoriesController(new CategoryBLL(new CategoryServiceStub())); List<ItemCategory> forventetListe = new List<ItemCategory>(); var ItemCat = new ItemCategory { CategoryId = 1, CategoryName = "TestCategory" }; forventetListe.Add(ItemCat); forventetListe.Add(ItemCat); forventetListe.Add(ItemCat); var actionResult = controller.getCategoryNameList(); dynamic data = actionResult.Data; for(var i = 0; i < forventetListe.Count; i++) { Assert.AreEqual(forventetListe[i].CategoryId, data[i].CategoryId); Assert.AreEqual(forventetListe[i].CategoryName, data[i].CategoryName); } }
public void EditGetViewPassing() { var controller = new ItemCategoriesController(new CategoryBLL(new CategoryServiceStub())); //Act var actionResult = (ViewResult)controller.Edit(1); //Assert Assert.AreEqual(actionResult.ViewName, ""); }
public void EditGetViewIdNull() { var controller = new ItemCategoriesController(new CategoryBLL(new CategoryServiceStub())); var actionResult = (HttpNotFoundResult)controller.Edit(99); Assert.AreEqual(actionResult.StatusCode, 404); }
public void DeletePassingId() { var controller = new ItemCategoriesController(new CategoryBLL(new CategoryServiceStub())); var actionResult = (RedirectToRouteResult)controller.DeleteConfirmed(1); Assert.AreEqual(actionResult.RouteValues.Values.First(), "Index"); }