public void AjaxSeatList()
 {
     var db = new FakeDatabase();
     var st = new FakeSkyTap();
     db.AddSet(TestSeatTempData.SeatTemps);
     var controller = new ClassroomsController(db, st);
     controller.ControllerContext = new FakeControllerContext();
     DTParameters param = new DTParameters() {SessionId= "12345", Start = 2, Length = 3, Search = new DTSearch(), Order = new DTOrder[1] { new DTOrder() { Column = 1, Dir = DTOrderDir.ASC } } };
     JsonResult result = controller.AjaxSeat(param) as JsonResult;
     Assert.IsNotNull(result);
     Assert.AreEqual(3, ((List<SeatTemp>)((DTResult<SeatTemp>)result.Data).data).Count);
 }
 public void EditStartNew()
 {
     var db = new FakeDatabase();
     db.AddSet(TestUserData.Users);
     db.AddSet(TestSeatData.Seats);
     db.AddSet(TestSeatTempData.SeatTemps);
     db.AddSet(TestDataCenterData.DataCenters);
     db.AddSet(TestCourseData.Courses);
     var st = new FakeSkyTap();
     var controller = new ClassroomsController(db, st);
     controller.ControllerContext = new FakeControllerContext();
     ViewResult result = controller.Edit(0) as ViewResult;
     Assert.IsNotNull(result);
     Assert.AreEqual(0, ((Classroom)result.Model).ClassroomId);
 }
 public void EditWriteBackNew()
 {
     var db = new FakeDatabase();
     db.AddSet(TestClassroomData.Classrooms);
     db.AddSet(TestUserData.Users);
     db.AddSet(TestSeatData.Seats);
     db.AddSet(TestSeatTempData.SeatTemps);
     db.AddSet(TestDataCenterData.DataCenters);
     db.AddSet(TestCourseData.Courses);
     var st = new FakeSkyTap();
     var controller = new ClassroomsController(db, st);
     controller.ControllerContext = new FakeControllerContext();
     Classroom NewRoom = new Classroom() { ClassroomId = 0, CourseId = 1, DataCenterId = 1, Project = "ABCDE", Start = System.DateTime.Now, UserId = 1 };
     ActionResult result = controller.Edit(NewRoom, "12345");
     Assert.IsNotNull(result);
 }
        public void RemoveSeatTestInvalidRequest()
        {
            var db = new FakeDatabase();
            var st = new FakeSkyTap();
            db.AddSet(TestSeatTempData.SeatTemps);
            var controller = new ClassroomsController(db, st);
            var httpRequest = new Mock<HttpRequestBase>();
            var stream = new MemoryStream(Encoding.Default.GetBytes("{'WrongParameter':50}"));
            httpRequest.Setup(r => r.InputStream).Returns(stream);

            var httpContext = new Mock<HttpContextBase>();
            httpContext.Setup(c => c.Request).Returns(httpRequest.Object);

            var routeData = new RouteData();
            controller.ControllerContext = // set mocked context
                 new ControllerContext(httpContext.Object, routeData, controller);
            var result = controller.RemoveSeat();
            dynamic jsonObject = result.Data;
            Assert.AreEqual("Done", jsonObject["Status"]);
            Assert.AreEqual(0, db.Removed.Count);
        }
        public void AddSeatTestInvalidClassroom()
        {
            var db = new FakeDatabase();
            var st = new FakeSkyTap();
            db.AddSet(TestSeatTempData.SeatTemps);
            db.AddSet(TestUserData.Users);
            var controller = new ClassroomsController(db, st);
            var httpRequest = new Mock<HttpRequestBase>();
            var stream = new MemoryStream(Encoding.Default.GetBytes("{'NewSeats':'[email protected]\[email protected]','Session':'12345','Classroom':'Invalid'}"));
            httpRequest.Setup(r => r.InputStream).Returns(stream);

            var httpContext = new Mock<HttpContextBase>();
            httpContext.Setup(c => c.Request).Returns(httpRequest.Object);

            var routeData = new RouteData();
            controller.ControllerContext = // set mocked context
                 new ControllerContext(httpContext.Object, routeData, controller);
            var result = controller.AddSeats();
            dynamic jsonObject = result.Data;
            Assert.AreEqual("Done", jsonObject["Status"]);
            Assert.AreEqual(0, db.Added.Count);
        }