Ejemplo n.º 1
0
        public void GetFizzBuzz_Should_Return_Exception_If_Input_Is_Greater_Than_Thousand()
        {
            // Arrange
            var fizbuzz = new MyFizzBuzz(() => notWednesday);

            // Act
            // Assert
            Assert.Throws <ArgumentException>(() => fizbuzz.GetFizzBuzz(1001));
        }
Ejemplo n.º 2
0
        public void GetFizzBuzz_Should_Return_Exception_If_Input_Is_Less_Than_One()
        {
            // Arrange
            var fizbuzz = new MyFizzBuzz(() => notWednesday);

            // Act
            // Assert
            Assert.Throws <ArgumentException>(() => fizbuzz.GetFizzBuzz(0));
        }
Ejemplo n.º 3
0
        public ActionResult FizzBuzz(int value, int?page)
        {
            int pageSize   = 20;
            int pageNumber = (page ?? 1);

            var model = new FizzBuzzViewModel();

            model.UserPosition = value;
            var fizzBuzz = new MyFizzBuzz(() => DateTime.UtcNow);

            model.FizzBuzzNumbers = fizzBuzz.GetFizzBuzz(model.UserPosition).ToPagedList(pageNumber, pageSize);

            return(View(model));
        }
Ejemplo n.º 4
0
        public void GetFizzBuzz_Should_Return_FizzBuzz_For_15th_Position_If_Input_Is_15_Or_Greater()
        {
            // Arrange
            var fizbuzz  = new MyFizzBuzz();
            var position = 15;
            var expected = "FizzBuzz";

            // Act
            var actualFizzBuzzList = fizbuzz.GetFizzBuzz(position);
            var actual             = actualFizzBuzzList.ElementAt(position - 1); // As lists are 0 index based we need to access the 14th item to get the correct position

            // Assert
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 5
0
        public void GetFizzBuzz_Should_Return_List_With_One_Two_Fizz_Four_Buzz_If_Input_Is_Five()
        {
            // Arrange
            var fizbuzz  = new MyFizzBuzz();
            var expected = new List <string> {
                "1", "2", "Fizz", "4", "Buzz"
            };

            // Act
            var actual = fizbuzz.GetFizzBuzz(5);

            // Assert
            CollectionAssert.AreEqual(expected, actual);
        }
Ejemplo n.º 6
0
        public void GetFizzBuzz_Should_Return_List_With_One_If_Input_Is_One()
        {
            // Arrange
            var fizbuzz  = new MyFizzBuzz();
            var expected = new List <string> {
                "1"
            };

            // Act
            var actual = fizbuzz.GetFizzBuzz(1);

            // Assert
            CollectionAssert.AreEqual(expected, actual);
        }
Ejemplo n.º 7
0
        public void GetFizzBuzz_Should_Return_List_With_One_Two_Wizz_If_Input_Is_Three_And_Is_Wednesday()
        {
            // Arrange
            var fizbuzz  = new MyFizzBuzz(() => wednesday);
            var expected = new List <string> {
                "1", "2", "Wizz"
            };

            // Act
            var actual = fizbuzz.GetFizzBuzz(3);

            // Assert
            CollectionAssert.AreEqual(expected, actual);
        }
Ejemplo n.º 8
0
        public ActionResult Index(FizzBuzzViewModel model, int?page)
        {
            int pageSize   = 20;
            int pageNumber = (page ?? 1);

            if (ModelState.IsValid)
            {
                var fizzBuzz = new MyFizzBuzz(() => DateTime.UtcNow);
                model.FizzBuzzNumbers = fizzBuzz.GetFizzBuzz(model.UserPosition).ToPagedList(pageNumber, pageSize);

                return(RedirectToAction("FizzBuzz", new { value = model.UserPosition, page = 1 }));
            }
            else
            {
                return(View(model));
            }
        }