public void EditAction_Fails_With_Wrong_Owner()
        {
            // Arrange
            var repo       = new FakeDinnerRepository(FakeDinnerData.CreateTestDinners());
            var controller = CreateDinnersControllerAs("fred");
            var form       = FakeDinnerData.CreateDinnerFormCollection();

            controller.ValueProvider = form.ToValueProvider();

            // Act
            ViewResult result = (ViewResult)controller.Edit(1, form);

            // Assert
            Assert.AreEqual("InvalidOwner", result.ViewName);
        }
        public void EditAction_Saves_Changes_To_Dinner_1()
        {
            // Arrange
            var repo       = new FakeDinnerRepository(FakeDinnerData.CreateTestDinners());
            var controller = CreateDinnersControllerAs("someuser");
            var form       = FakeDinnerData.CreateDinnerFormCollection();

            form["Description"]      = "New, Updated Description";
            controller.ValueProvider = form.ToValueProvider();

            // Act
            ActionResult result       = (ActionResult)controller.Edit(1, form);
            ViewResult   detailResult = (ViewResult)controller.Details(1);
            var          dinner       = detailResult.ViewData.Model as Dinner;

            // Assert
            Assert.AreEqual(5, controller.ModelState.Count);
            Assert.AreEqual("New, Updated Description", dinner.Description);
        }
        public void DinnersController_Edit_Post_Should_Fail_Given_Bad_US_Phone_Number()
        {
            // Arrange
            var controller = CreateDinnersControllerAs("someuser");
            var form       = FakeDinnerData.CreateDinnerFormCollection();

            form["ContactPhone"]     = "foo"; //BAD
            controller.ValueProvider = form.ToValueProvider();

            // Act
            //var result = controller.Edit(1, form);

            // Assert
            ////Assert.IsInstanceOfType(result, typeof(ViewResult));
            //var viewResult = (ViewResult)result;
            //Assert.IsFalse(viewResult.ViewData.ModelState.IsValid);
            //Assert.AreEqual(1, viewResult.ViewData.ModelState.Sum(p => p.Value.Errors.Count), "Expected Errors");
            //ModelState m = viewResult.ViewData.ModelState["ContactPhone"];
            //Assert.IsTrue(m.Errors.Count == 1);
        }