// GET: Sequence
 public ActionResult Index(SequenceGeneratorModel model)
 {
     if (ModelState.IsValid && model.EndValue.HasValue)
     {
         model.Results = _generator.Select(c => new SequenceModel()
         {
             Title = SequenceGeneratorDetails.ResourceManager.GetString(String.Format("{0}_Header", c.SequenceName)),
             Description = SequenceGeneratorDetails.ResourceManager.GetString(String.Format("{0}_Description", c.SequenceName)),
             Values = c.Generate(model.StartValue, model.EndValue.GetValueOrDefault(0))
         });
     }
     return View("Index", model);
 }
        public void Index_Does_Nothing_If_The_MaxValue_Is_Not_Known()
        {
            // Arrange
            var controller = new SequenceController(null);
            var model = new SequenceGeneratorModel()
            {
                EndValue = null
            };

            // Act
            var result = controller.Index(model);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(model.Results == null);
            Assert.IsInstanceOfType(result, typeof(ViewResult));
            var viewResult = result as ViewResult;
            Assert.AreEqual("Index", viewResult.ViewName);
        }
        public void Index_Returns_A_Model_With_Results()
        {
            // Arrange
            var controller = new SequenceController(new[] { new AllNumberSequence() });
            var model = new SequenceGeneratorModel()
            {
                EndValue = 5
            };

            // Act
            var result = controller.Index(model);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(model.Results != null);
            Assert.IsInstanceOfType(result, typeof(ViewResult));
            var viewResult = result as ViewResult;
            Assert.IsTrue(viewResult.ViewData.ModelState.IsValid);
            Assert.AreEqual("Index", viewResult.ViewName);
        }