Ejemplo n.º 1
0
        public void VersionOS_Delete_Post_Null_Data_Should_Return_Error()
        {
            // Arrange
            var controller = new VersionOSController();

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

            // Assert
            Assert.AreEqual("Error", result.ActionName);
        }
Ejemplo n.º 2
0
        public void VersionOS_Delete_Post_Invalid_Model_Should_Send_Back_For_Edit()
        {
            // Arrange
            var controller = new VersionOSController();
            var data       = new VersionOSModel();

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

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

            // Assert
            Assert.AreEqual(404, result.StatusCode);
        }
Ejemplo n.º 3
0
        public void VersionOS_Delete_Post_Empty_Id_Should_Send_Back_For_Edit()
        {
            // Arrange
            var            controller = new VersionOSController();
            VersionOSModel dataEmpty  = new VersionOSModel
            {
                // Make data.Id empty
                ID = ""
            };

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

            // Assert
            Assert.AreEqual("Error", result.ActionName);
        }
Ejemplo n.º 4
0
        public void VersionOS_Delete_Post_Valid_Should_Delete()
        {
            // Arrange
            var controller = new VersionOSController();

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

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

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

            // Assert
            Assert.IsNull(dataExist);
        }
Ejemplo n.º 5
0
        public void VersionOS_Delete_Post_Default_Should_Return_Index_Page()
        {
            // Arrange
            var controller = new VersionOSController();

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

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

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

            // Assert
            Assert.AreEqual(404, result.StatusCode);
        }