예제 #1
0
        public void IndexGetWithValuesReturnsView()
        {
            var controller = new HomeController();
            var result = controller.Index(1, 100) as ViewResult;

            AssertValidFizzBuzzViewResult(result);
        }
예제 #2
0
        public void IndexGetHasEmptyResults()
        {
            var controller = new HomeController();

            var result = controller.Index(12, 42) as ViewResult;
            var viewModel = result.Model as FizzBuzzModel;

            Assert.That(viewModel.Results, Is.Not.Null);
            Assert.That(viewModel.Results.Count, Is.EqualTo(0));
        }
예제 #3
0
        public void IndexGetEchoesNonDefaultFirstAndLast()
        {
            var controller = new HomeController();

            var result = controller.Index(12, 47) as ViewResult;
            var viewModel = result.Model as FizzBuzzModel;

            Assert.That(viewModel.First, Is.EqualTo(12));
            Assert.That(viewModel.Last, Is.EqualTo(47));
        }
예제 #4
0
        public void IndexPostEchoesFirstAndLast()
        {
            var postData = new FizzBuzzPostModel
                {
                    First = 1,
                    Last = 15
                };
            var controller = new HomeController();

            var result = controller.Index(postData) as ViewResult;
            var viewModel = result.Model as FizzBuzzModel;

            Assert.That(viewModel.First, Is.EqualTo(1));
            Assert.That(viewModel.Last, Is.EqualTo(15));
        }
예제 #5
0
        public void IndexPostReturnsStrings(int index, string expected)
        {
            var postData = new FizzBuzzPostModel
            {
                First = 1,
                Last = 15
            };
            var controller = new HomeController();

            var result = controller.Index(postData) as ViewResult;
            var viewModel = result.Model as FizzBuzzModel;

            Assert.That(viewModel.Results.Count, Is.EqualTo(15));
            Assert.That(viewModel.Results[index - 1], Is.EqualTo(expected));
        }
예제 #6
0
        public void IndexPostReturnsViewWithOneToFifteen()
        {
            var postData = new FizzBuzzPostModel
            {
                First = 1,
                Last = 15
            };
            var controller = new HomeController();

            var result = controller.Index(postData) as ViewResult;

            AssertValidFizzBuzzViewResult(result);
        }
예제 #7
0
        public void IndexPostReturnsViewWithDefaultPostData()
        {
            var controller = new HomeController();
            var result = controller.Index(new FizzBuzzPostModel()) as ViewResult;

            AssertValidFizzBuzzViewResult(result);
        }