public void CreateInvalidModel() { var controller = new UserController(new UserBLL(new UserServiceStub())); var User = new User(); controller.ModelState.AddModelError("FirstName", ""); var actionResult = (ViewResult)controller.Create(User); Assert.AreEqual(actionResult.ViewName, ""); }
public void CreateValidModel() { var controller = new UserController(new UserBLL(new UserServiceStub())); var User = new User { UserID = 1, FirstName = "Espen", LastName = "Zaal", Address = "Osloveien 123", PostCode = "1234", PostAddress = "Oslo", Email = "*****@*****.**", Orders = new List<Order>(), Password = "******", RoleId = 1, RoleStringId = "C", Telephone = "22334455" }; var actionResult = (RedirectToRouteResult)controller.Create(User); Assert.AreEqual(actionResult.RouteName, ""); Assert.IsTrue(actionResult.RouteValues.Values.Count == 1); Assert.AreEqual(actionResult.RouteValues.Values.First(), "Index"); }
public void DeleteGetValid() { var controller = new UserController(new UserBLL(new UserServiceStub())); var actionResult = (ViewResult)controller.Delete(1); Assert.AreEqual(actionResult.ViewName, ""); }
public void DeleteGetNoId() { var controller = new UserController(new UserBLL(new UserServiceStub())); var actionResult = (HttpStatusCodeResult)controller.Delete(null); Assert.AreEqual(actionResult.StatusCode, 400); }
public void DeleteGetInvalidId() { var controller = new UserController(new UserBLL(new UserServiceStub())); var actionResult = (HttpNotFoundResult)controller.Delete(99); Assert.AreEqual(actionResult.StatusCode, 404); }
public void ConstructorTest() { var controller = new UserController(); Assert.IsNotNull(controller); Assert.IsInstanceOfType(controller, typeof(Controller)); }
public void CreateGetView() { var controller = new UserController(new UserBLL(new UserServiceStub())); var actionResult = (ViewResult)controller.Create(); Assert.AreEqual(actionResult.ViewName, ""); }
public void GetUserList() { var controller = new UserController(new UserBLL(new UserServiceStub())); var User = new User { UserID = 1, FirstName = "Espen", LastName = "Zaal", Address = "Osloveien 123", PostCode = "1234", PostAddress = "Oslo", Email = "*****@*****.**", Orders = new List<Order>(), Password = "******", RoleId = 1, RoleStringId = "C", Telephone = "22334455" }; List<User> forventet = new List<User>(); forventet.Add(User); forventet.Add(User); forventet.Add(User); var actionResult = (ViewResult)controller.Index(); var result = (List<User>)actionResult.Model; Assert.AreEqual(actionResult.ViewName, ""); for(var i = 0; i < forventet.Count; i++) { Assert.AreEqual(forventet[i].UserID, result[i].UserID); Assert.AreEqual(forventet[i].FirstName, result[i].FirstName); Assert.AreEqual(forventet[i].LastName, result[i].LastName); Assert.AreEqual(forventet[i].Address, result[i].Address); Assert.AreEqual(forventet[i].PostCode, result[i].PostCode); Assert.AreEqual(forventet[i].PostAddress, result[i].PostAddress); Assert.AreEqual(forventet[i].Email, result[i].Email); Assert.AreEqual(forventet[i].Password, result[i].Password); Assert.AreEqual(forventet[i].RoleId, result[i].RoleId); Assert.AreEqual(forventet[i].RoleStringId, result[i].RoleStringId); Assert.AreEqual(forventet[i].Telephone, result[i].Telephone); } }
public void GetUserDetailsValidId() { var controller = new UserController(new UserBLL(new UserServiceStub())); var actionResult = (ViewResult)controller.Details(1); Assert.AreEqual(actionResult.ViewName, ""); }
public void GetUserDetailsIdIsNull() { var controller = new UserController(new UserBLL(new UserServiceStub())); var actionResult = (HttpStatusCodeResult)controller.Details(null); Assert.AreEqual(actionResult.StatusCode, 400); }
public void DeleteValidId() { var controller = new UserController(new UserBLL(new UserServiceStub())); var actionResult = (RedirectToRouteResult)controller.DeleteConfirmed(1); Assert.AreEqual(actionResult.RouteName, ""); Assert.AreEqual(actionResult.RouteValues.Values.First(), "Index"); Assert.IsTrue(actionResult.RouteValues.Values.Count == 1); }
public void DeleteInvalidId() { var SessionMock = new TestControllerBuilder(); var controller = new UserController(new UserBLL(new UserServiceStub())); SessionMock.InitializeController(controller); var actionResult = (ViewResult)controller.DeleteConfirmed(99); Assert.AreEqual(actionResult.ViewName, ""); }