Пример #1
0
        public ActionResult Index(FibViewModel model)
        {
            if (ModelState.IsValid)
            {
                model.FibNumber = Benet.NthNumber(model.SequenceNumber);
            }
            else
            {
                model.FibNumber = 0;
            }

            return(View(model));
        }
Пример #2
0
        public void GivenSequence7ThenExpect13()
        {
            // Arrange
            var inputModel = new FibViewModel {
                SequenceNumber = 7
            };

            // Act
            var result      = _controller.Index(inputModel) as ViewResult;
            var outputModel = (FibViewModel)result.Model;

            // Assert
            Assert.AreEqual(13, outputModel.FibNumber);
        }
Пример #3
0
        public void GivenInvalidValueThenVerifyResultIs0()
        {
            // Arrange
            var inputModel = new FibViewModel {
                SequenceNumber = 1
            };

            _controller.ViewData.ModelState.AddModelError("Test", "Invalid value");

            // Act
            var result      = _controller.Index(inputModel) as ViewResult;
            var outputModel = (FibViewModel)result.Model;

            // Assert
            Assert.AreEqual(0, outputModel.FibNumber);
        }