static void Main(string[] args) { var conn = new Connection(); conn.Connect("EdDb"); //var ClassesController = new ClassesController(conn); //INSERT CREATE ..... var sql = new Class(); sql.connect("Class"); var success = ClassesController.Create(new Class()); var newclass = new Class { Id = 0, Code = "11200", Subject = "Underwater Basket Weaving", Section = 901, InstructorId = null }; var success = classesController.Create(newclass); newclass.Id = 2; }
public void CreateShouldSaveAndDisplayCorrectView() { //ARRANGE var model = new ClassViewModel { Name = "Class One", School = new School { Id = Guid.NewGuid() } }; var logic = new Mock <IClassLogic>(); logic .Setup(x => x.Create(It.IsAny <ClassEntity>())) .Verifiable("Should create class"); var controller = new ClassesController(logic.Object, null); //ACT var result = controller.Create(model) as RedirectToRouteResult; //ASSERT logic.Verify(); Assert.NotNull(result); Assert.AreEqual("Index", result.RouteValues["Action"]); }
public void CreateShouldValidateModel() { //ARRANGE var model = new ClassViewModel { Name = "Class One" }; var logic = new Mock <ISchoolLogic>(); logic .Setup(x => x.GetAll()) .Returns(new List <School>()) .Verifiable("Should re get the schools to display."); var controller = new ClassesController(null, logic.Object); //ACT var result = controller.Create(model) as ViewResult; //ASSERT logic.Verify(); Assert.NotNull(result); Assert.That(result.ViewName, Is.EqualTo("Create")); Assert.That(result.ViewData.ModelState.Count, Is.EqualTo(1)); }
public void CreateShouldDisplayTheCorrectView() { //ARRANGE var model = new List <School>(); var logic = new Mock <ISchoolLogic>(); logic .Setup(x => x.GetAll()) .Returns(model) .Verifiable("should get schools to display"); var controller = new ClassesController(null, logic.Object); //ACT var result = controller.Create() as ViewResult; //ASSERT logic.Verify(); Assert.NotNull(result); Assert.That(result.ViewName, Is.EqualTo("Create")); }