コード例 #1
0
        public void op_Translate_Post_WhenModelStateIsNotValid()
        {
            // Arrange
            const string expectedview = "Translate";
            PaulController controller = new PaulController();
            controller.ModelState.AddModelError("From", "Error found");

            // Act
            var result = (ViewResult)controller.Translate(new TranslateViewModel());

            // Assert
            Assert.IsInstanceOfType(result, typeof(ViewResult));
            Assert.AreEqual(expectedview, result.ViewName);
            Assert.AreEqual(1, result.ViewData.ModelState.Keys.Count);
        }
コード例 #2
0
        public void op_Translate_Post_WhenModelStateIsValid()
        {
            // Arrange
            const string englishword = "Monday";
            const string expected = "Lundi";
            const string expectedview = "Translate";
            PaulController controller = new PaulController();
            var result = (ViewResult)controller.Translate(new TranslateViewModel() { From = englishword });
            var model = (TranslateViewModel)result.Model;

            // Act
            var actual = model.To;

            // Assert
            Assert.IsInstanceOfType(result, typeof (ViewResult));
            Assert.AreEqual(expectedview, result.ViewName);
            Assert.AreEqual(expected, actual);
        }