Пример #1
0
        public void HistoryApp_Update_Default_Should_Pass()
        {
            // Arrange
            var myController = new HistoryAppController();

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

            // Assert
            Assert.IsNotNull(result);
        }
        public void HistoryApp_Update_Get_Valid_Data_Should_Pass()
        {
            // Arrange
            var myController = new HistoryAppController();
            var myData       = BiliWeb.Backend.HistoryAppBackend.Instance.Index().FirstOrDefault();

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

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

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

            // Reset

            // Assert
            Assert.IsNotNull(result);
        }
        public void HistoryApp_Update_Post_Default_Should_Pass()
        {
            // Arrange
            var myController = new HistoryAppController();
            var myData       = new HistoryAppModel();

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

            // Reset

            // Assert
            Assert.IsNotNull(result);
        }
        public void HistoryApp_Update_Post_Invalid_Model_Should_Send_Back_For_Edit()
        {
            // Arrange
            var controller = new HistoryAppController();
            var data       = new HistoryAppModel();

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

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

            // Assert
            Assert.AreEqual(404, result.StatusCode);
        }
        public void HistoryApp_Update_Post_Valid_Data_Should_Pass()
        {
            // Arrange
            var myController = new HistoryAppController();
            var myData       = BiliWeb.Backend.HistoryAppBackend.Instance.Index().FirstOrDefault();
            var resultData   = new HistoryAppModel(myData)
            {
                PhoneID = "NewPhone",
                ID      = myData.ID
            };

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

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

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