Example #1
0
        public void Visa_card_number_invalid()
        {
            //Arrange
            CardViewModel fakeModel = new CardViewModel()
            {
                Number = "4123123412341234",
                Month  = 12,
                Year   = 2018
            };

            _controller.ModelState.AddModelError("Card", "Invalid");

            //Act
            var actionResult = _controller.Card(fakeModel);

            var objectResult = actionResult as ObjectResult;
            var modelState   = objectResult.Value as dynamic;

            //Assert
            Assert.IsType <BadRequestObjectResult>(actionResult);
            Assert.NotNull(objectResult?.Value);
            Assert.True(modelState?.ContainsKey("Card"));
        }