Exemple #1
0
        public void IndexGet_WhenSessionIsNull_ShouldReturnView()
        {
            ViewResult returnView = _controller.Display() as ViewResult;

            Assert.IsNotNull(returnView);
            Assert.AreEqual(returnView.ViewName, "Display");
        }
        public void Display_ShouldDisplayView_WithInvalidModelState()
        {
            var model = new FizzBuzzModel()
            {
            };

            this.fizzBuzzController.ViewData.ModelState.AddModelError("Limit", Constants.EnterNumber1To1000);
            var result = fizzBuzzController.Display(model) as ViewResult;

            Assert.AreEqual(result.ViewName, Constants.ControllerActionName);
        }
        public void Post_DisplayTest(int value, string[] expectedResult)
        {
            this.mockFizzBuzzService.Setup(x => x.GetFizzBuzzData(It.IsAny <int>())).Returns(expectedResult);
            var fizzBuzzController = new FizzBuzzController(this.mockFizzBuzzService.Object);
            var output             = fizzBuzzController.Display(new FizzBuzzModel()
            {
                Number = value
            }) as ViewResult;
            var outputList = (FizzBuzzModel)output.ViewData.Model;

            Assert.AreEqual(expectedResult.Length, outputList.Number);
        }