예제 #1
0
        public void TestOver30000ReturnsBarclayCard()
        {
            // Arrange
            ApplyController controller = new ApplyController();

            var model = new ApplyViewModel()
            {
                DOB       = new DateTime(1980, 1, 1),
                FirstName = "Over30kTest",
                LastName  = "Over30kTest",
                Income    = 30001m
            };

            SeedDB(context);

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

            result.RouteValues.TryGetValue("action", out object routeNameObj);
            result.RouteValues.TryGetValue("cardApplicationID", out object cardApplicationIDObj);

            var cardApplicationID = Int16.Parse(cardApplicationIDObj.ToString());
            var cardApplication   = context.CardApplications.First(c => c.CardApplicationID == cardApplicationID);

            //Assert
            Assert.AreEqual("Results", routeNameObj.ToString());
            Assert.AreEqual(1, cardApplication.Cards.Count);
            Assert.AreEqual("BarclayCard", cardApplication.Cards.First().Name);
        }
예제 #2
0
        public void TestUnder18ReturnsNoCard()
        {
            // Arrange
            ApplyController controller = new ApplyController();

            var model = new ApplyViewModel()
            {
                DOB       = DateTime.Now,
                FirstName = "Uder18Test",
                LastName  = "Uder18Test",
                Income    = 20000m
            };

            SeedDB(context);

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

            result.RouteValues.TryGetValue("action", out object routeNameObj);
            result.RouteValues.TryGetValue("cardApplicationID", out object cardApplicationIDObj);

            var cardApplicationID = Int16.Parse(cardApplicationIDObj.ToString());
            var cardApplication   = context.CardApplications.First(c => c.CardApplicationID == cardApplicationID);

            //Assert
            Assert.AreEqual("Results", routeNameObj.ToString());
            Assert.AreEqual(0, cardApplication.Cards.Count);
        }
        public void ReturnViewForIndex()
        {
            var MockRepository = new Mock <ICreditCardApplicationRepository>();
            var sut            = new ApplyController(MockRepository.Object);

            IActionResult result = _sut.Index();

            Assert.IsType <ViewResult>(result);
        }
예제 #4
0
        public void TestCanReturnIndexView()
        {
            // Arrange
            ApplyController controller = new ApplyController();


            // Act
            ViewResult result = controller.Index() as ViewResult;

            // Assert
            Assert.AreEqual("Index", result.ViewName);
        }
 public ApplyControllerShould()
 {
     _mockData = new Mock <ICreditCardData>();
     _sut      = new ApplyController(_mockData.Object);
 }
 public ApplyControllerShould()
 {
     _mockRepository = new Mock <ICreditCardApplicationRepository>();
     _sut            = new ApplyController(_mockRepository.Object);
 }