public void FakeVmExecuteTest() { var st = new FakeSkyTap(); st.AddSet(TestVmRESTData.vms); var request = new RestRequest(); var reply = st.Execute<Vm>(request); Assert.IsNotNull(reply); Assert.AreSame(typeof(Vm), reply.GetType()); }
public void FakeVmExecuteListTest() { var st = new FakeSkyTap(); st.AddSet(TestVmRESTData.vms); var request = new RestRequest(); var reply = st.ExecuteList<Vm>(request); Assert.IsNotNull(reply); Assert.AreEqual(typeof(List<Vm>), reply.GetType()); Assert.AreEqual(10, reply.Count); Assert.AreEqual(typeof(Vm), (reply[0]).GetType()); }
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 CourseControllerIndexTest() { // Arrange var db = new FakeDatabase(); var st = new FakeSkyTap(); CoursesController controller = new CoursesController(db, st); // Act ViewResult result = controller.Index() as ViewResult; // Assert Assert.IsNotNull(result); }
public void MachineAjaxList() { var db = new FakeDatabase(); var st = new FakeSkyTap(); db.AddSet(TestCourseMachineTempData.CourseMachineTemps); var controller = new CoursesController(db, st); controller.ControllerContext = new FakeControllerContext(); DTParameters param = new DTParameters() { Start = 2, Length = 5, Search = new DTSearch(), Order = new DTOrder[1] { new DTOrder() { Column = 1, Dir = DTOrderDir.ASC } }, Course = 1, SessionId = "12345" }; JsonResult result = controller.MachineAjax(param) as JsonResult; Assert.IsNotNull(result); Assert.AreEqual(5, ((List<CourseMachineTemp>)((DTResult<CourseMachineTemp>)result.Data).data).Count); Assert.AreEqual("Test3", ((List<CourseMachineTemp>)((DTResult<CourseMachineTemp>)result.Data).data)[0].VMName); }
public void CourseEditNewStartTest() { var db = new FakeDatabase(); var st = new FakeSkyTap(); db.AddSet(TestCourseData.Courses); db.AddSet(TestCourseMachineTempData.CourseMachineTemps); st.AddSet(TestTemplateRESTData.templates); var controller = new CoursesController(db, st); controller.ControllerContext = new FakeControllerContext(); ViewResult result = controller.Edit(0) as ViewResult; Assert.IsNotNull(result); Assert.AreEqual(11, ((List<Template>)((SelectList)result.ViewBag.Template).Items).Count); Assert.AreEqual(typeof(Course), result.Model.GetType()); Assert.AreEqual("New", ((Course)result.Model).Name); }
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 CourseEditNewWriteTest() { var db = new FakeDatabase(); var st = new FakeSkyTap(); db.AddSet(TestCourseData.Courses); db.AddSet(TestCourseMachineData.CourseMachines); db.AddSet(TestCourseMachineTempData.CourseMachineTemps); st.AddSet(TestTemplateRESTData.templates); var controller = new CoursesController(db, st); controller.ControllerContext = new FakeControllerContext(); Course testCourse = new Course() { CourseId = 0, Name = "TestNew", Days = 5, Hours = 8, Template = "11111111" }; var result = controller.Edit(testCourse, Guid.NewGuid().ToString()); Assert.IsNotNull(result); Assert.AreEqual(typeof(RedirectToRouteResult), result.GetType()); Assert.AreEqual(1, db.Added.Count); Assert.AreEqual("TestNew", ((Course)db.Added[0]).Name); Assert.AreEqual(3, db.saved); }
public void CourseDeleteStartTest() { var db = new FakeDatabase(); var st = new FakeSkyTap(); db.AddSet(TestCourseData.Courses); db.AddSet(TestCourseMachineData.CourseMachines); var controller = new CoursesController(db, st); controller.ControllerContext = new FakeControllerContext(); var result = controller.Delete(1); Assert.IsNotNull(result); }
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); }