Beispiel #1
0
        public void ResultLog_Update_Default_Should_Pass()
        {
            // Arrange
            var myController = new ResultLogController();

            // Act
            var result = myController.Update("abc");

            // Assert
            Assert.IsNotNull(result);
        }
Beispiel #2
0
        public void ResultLog_Index_Default_Should_Pass()
        {
            // Arrange
            var myController = new ResultLogController();

            // Act
            var result = myController.Index();

            // Assert
            Assert.IsNotNull(result);
        }
Beispiel #3
0
        public void ResultLog_Delete_InValid_Data_Bogus_Should_Fail()
        {
            // Arrange
            var myController = new ResultLogController();

            // Act
            var result = myController.Delete("bogus");

            // Assert
            Assert.IsNotNull(result);
        }
        public void ResultLog_Delete_Get_Null_Id_Should_Return_Error()
        {
            // Arrange
            var controller = new ResultLogController();

            // Act
            var result = controller.Delete((string)null) as NotFoundResult;

            // Assert
            Assert.AreEqual(404, result.StatusCode);
        }
        public void ResultLog_Delete_Post_Null_Data_Should_Return_Error()
        {
            // Arrange
            var controller = new ResultLogController();

            // Act
            var result = controller.DeleteConfirmed(null) as RedirectToActionResult;

            // Assert
            Assert.AreEqual("Error", result.ActionName);
        }
        public void ResultLog_Update_Get_Valid_Data_Should_Pass()
        {
            // Arrange
            var myController = new ResultLogController();
            var myData       = BiliWeb.Backend.ResultLogBackend.Instance.Index().FirstOrDefault();

            // Act
            var result = myController.Update(myData.ID) as ViewResult;

            // Assert
            Assert.IsNotNull(result.Model);
        }
        public void ResultLog_Create_Get_Default_Should_Pass()
        {
            // Arrange
            var myController = new ResultLogController();

            // Act
            var result = myController.Create();

            // Reset

            // Assert
            Assert.IsNotNull(result);
        }
        public void ResultLog_Read_Get_InValid_Data_Null_Should_Fail()
        {
            // Arrange
            var myController = new ResultLogController();

            // Act
            var result = (NotFoundResult)myController.Read(null);

            // Reset

            // Assert
            Assert.AreEqual(404, result.StatusCode);
        }
        public void ResultLog_Update_Get_InValid_ID_Bogus_Should_Fail()
        {
            // Arrange
            var myController = new ResultLogController();

            // Act
            var result = myController.Update("abc");

            // Reset

            // Assert
            Assert.IsNotNull(result);
        }
        public void ResultLog_Read_Get_Data_Null_Should_Fail()
        {
            // Arrange
            var myController = new ResultLogController();

            // Act
            var result = myController.Read(null);

            // Reset

            // Assert
            Assert.IsNotNull(result);
        }
        public void ResultLog_Update_Post_Default_Should_Pass()
        {
            // Arrange
            var myController = new ResultLogController();
            var myData       = new ResultLogModel();

            // Act
            var result = myController.Update(myData);

            // Reset

            // Assert
            Assert.IsNotNull(result);
        }
        public void ResultLog_Create_Post_Invalid_Model_Should_Send_Back_For_Edit()
        {
            // Arrange
            var controller = new ResultLogController();
            var data       = new ResultLogModel();

            // Make ModelState Invalid
            controller.ModelState.AddModelError("test", "test");

            // Act
            var result = controller.Create(data) as RedirectToActionResult;

            // Assert
            Assert.AreEqual("Error", result.ActionName);
        }
        public void ResultLog_Delete_Post_Invalid_Model_Should_Send_Back_For_Edit()
        {
            // Arrange
            var controller = new ResultLogController();
            var data       = new ResultLogModel();

            // Make ModelState Invalid
            controller.ModelState.AddModelError("test", "test");

            // Act
            var result = controller.DeleteConfirmed(data.ID) as NotFoundResult;

            // Assert
            Assert.AreEqual(404, result.StatusCode);
        }
        public void ResultLog_Delete_Invalid_Null_Data_Should_Return_Error()
        {
            // Arrange
            var    controller = new ResultLogController();
            string id         = "bogus";

            // Act
            var result = controller.Delete(id) as NotFoundResult;

            // Reset
            BiliWeb.Backend.DataSourceBackend.Instance.Reset();

            // Assert
            Assert.AreEqual(404, result.StatusCode);
        }
        public void ResultLog_Delete_Get_Default_Should_Return_Data()
        {
            // Arrange
            var controller = new ResultLogController();

            // Get default student
            var data = BiliWeb.Backend.DataSourceBackend.Instance.ResultLogBackend.Index().FirstOrDefault();

            // Act
            var result = controller.Delete(data.ID, true) as ViewResult;

            // Reset

            // Assert
            Assert.IsNotNull(result.ViewData);
        }
        public void ResultLog_Delete_Post_Empty_Id_Should_Send_Back_For_Edit()
        {
            // Arrange
            var            controller = new ResultLogController();
            ResultLogModel dataEmpty  = new ResultLogModel
            {
                // Make data.Id empty
                ID = ""
            };

            // Act
            var result = controller.DeleteConfirmed(dataEmpty.ID) as RedirectToActionResult;

            // Assert
            Assert.AreEqual("Error", result.ActionName);
        }
        public void ResultLog_Delete_Get_Default_Should_Pass()
        {
            // Arrange
            var controller = new ResultLogController();

            string id = BiliWeb.Backend.DataSourceBackend.Instance.ResultLogBackend.Index().FirstOrDefault().ID;

            // Act
            ViewResult result = controller.Delete(id) as ViewResult;

            // Reset
            BiliWeb.Backend.DataSourceBackend.Instance.Reset();

            // Assert
            Assert.IsNotNull(result);
        }
        public void ResultLog_Delete_Post_Valid_Should_Delete()
        {
            // Arrange
            var controller = new ResultLogController();

            // Get default student
            var data = BiliWeb.Backend.DataSourceBackend.Instance.ResultLogBackend.Index().FirstOrDefault();

            // Act
            var result    = controller.DeleteConfirmed(data.ID) as ViewResult;
            var dataExist = BiliWeb.Backend.DataSourceBackend.Instance.ResultLogBackend.Read(data.ID);

            // Reset
            BiliWeb.Backend.DataSourceBackend.Instance.Reset();

            // Assert
            Assert.IsNull(dataExist);
        }
        public void ResultLog_Delete_Post_Default_Should_Return_Index_Page()
        {
            // Arrange
            var controller = new ResultLogController();

            // Get default student
            var            defaultData = BiliWeb.Backend.DataSourceBackend.Instance.ResultLogBackend.Index().FirstOrDefault();
            ResultLogModel data        = new ResultLogModel(defaultData);

            // Act
            var result = controller.DeleteConfirmed(data.ID) as NotFoundResult;

            // Reset
            BiliWeb.Backend.DataSourceBackend.Instance.Reset();

            // Assert
            Assert.AreEqual(404, result.StatusCode);
        }
        public void ResultLog_Update_Post_Valid_Data_Should_Pass()
        {
            // Arrange
            var myController = new ResultLogController();
            var myData       = BiliWeb.Backend.ResultLogBackend.Instance.Index().FirstOrDefault();
            var resultData   = new ResultLogModel(myData)
            {
                ClinicID = "New",
                ID       = myData.ID
            };

            // Act
            var result = myController.Update(resultData) as RedirectToActionResult;

            //Reset
            BiliWeb.Backend.DataSourceBackend.Instance.Reset();

            // Assert
            Assert.AreEqual("Index", result.ActionName);
        }