public void TestInValidMortgages()
        {
            //Arrange
            mockMortRepo.Setup(s => s.GetAllMortgages()).Returns((List <Mortgage>)null);

            //Act
            MortgageController controller = new MortgageController(mockMortRepo.Object);
            IHttpActionResult  response   = controller.Get();
            var contentResult             = response as OkNegotiatedContentResult <List <Mortgage> >;

            //Assert
            Assert.IsNull(contentResult);
        }
        public void Verify_GetAllMortgagesTest_Api()
        {
            // Arrange
            var controller = new MortgageController();

            controller.Request       = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();

            // Act
            IEnumerable <Mortgage> mortgages = controller.Get();

            // Assert
            Assert.IsNotNull(mortgages);
            Assert.IsTrue(mortgages.Count() > 0);
        }
        public void TestGetAllMortgages()
        {
            //Arrange
            mockMortRepo.Setup(s => s.GetAllMortgages()).Returns(mortgageList);

            //Act
            MortgageController controller = new MortgageController(mockMortRepo.Object);
            IHttpActionResult  response   = controller.Get();
            var             contentResult = response as OkNegotiatedContentResult <List <Mortgage> >;
            List <Mortgage> mList         = contentResult.Content;

            //Assert
            Assert.IsNotNull(mList);
            Assert.AreEqual(mList.Count, mortgageList.Count);
        }
Beispiel #4
0
        public void Positive_GetMortgages()
        {
            var mortgageService = new Mock <IMortgageService>();
            var items           = new List <Dto.Mortgage>
            {
                new Dto.Mortgage {
                    MortgageId = 1, MortgageType = Dto.MortgageType.Fixed, Name = "Mortgage1"
                },
                new Dto.Mortgage {
                    MortgageId = 2, MortgageType = Dto.MortgageType.Variable, Name = "Mortgage2"
                },
            };

            mortgageService.Setup(x => x.GetAllMortgages()).Returns(() => items);

            var controller = new MortgageController(mortgageService.Object);
            var results    = controller.Get();

            Assert.AreEqual(items.Count, results.Count(), "Mortgages count mismatch");
        }
        public void Verify_GetMortgageTest_Api()
        {
            // Arrange
            var controller = new MortgageController();

            controller.Request       = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();

            // Act
            Mortgage mortgage = controller.Get(3);

            // Assert
            Assert.IsNotNull(mortgage);
            Assert.IsTrue(mortgage.MortgageId == 3);
            Assert.IsTrue(mortgage.Name.Length > 0);
            Assert.IsTrue(mortgage.InterestRate > 0);
            Assert.IsTrue(mortgage.EstablishmentFee > 0);
            Assert.IsTrue(mortgage.EffectiveStartDate > DateTime.MinValue);
            Assert.IsTrue(mortgage.EffectiveEndDate < DateTime.MaxValue);
            Assert.IsTrue(mortgage.EffectiveEndDate > mortgage.EffectiveStartDate);
            Assert.IsTrue(mortgage.MortgageType == MortgageType.Fixed || mortgage.MortgageType == MortgageType.Variable);
            Assert.IsTrue(mortgage.InterestRepayment == InterestRepayment.InterestOnly || mortgage.InterestRepayment == InterestRepayment.PrincipalAndInterest);
        }
Beispiel #6
0
        public void GetMortgagesTest()
        {
            var result = mortgageController.Get();

            Assert.IsNotNull(result);
        }