Пример #1
0
        public void getTermsTest()
        {
            //Arrange
            int i = 1;

            //Act
            MortgageController m = new MortgageController();

            double result = m.getTerms(i);

            //Assert
            Assert.AreEqual(12, result);
        }
        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);
        }
Пример #3
0
        public void getPercentageTest()
        {
            //Arrange
            double i = 12;

            //Act
            MortgageController m = new MortgageController();

            double result = m.getPercentage(i);

            //Assert
            Assert.AreEqual(0.01, result);
        }
Пример #4
0
        //[Ignore]
        public void Formula()
        {
            //Arrange
            double i = 1;
            int    j = 2;

            //Act
            MortgageController m = new MortgageController();

            double result = m.Formula(i, j);

            //Assert
            Assert.AreEqual(4, result);
        }
        public void TestGetMortgageByID_Invalid()
        {
            var mortId = 500;

            mockMortRepo.Setup(x => x.GetMortgageById(mortId)).Returns((Mortgage)null);

            var controller = new MortgageController(mockMortRepo.Object);

            IHttpActionResult response = controller.GetById(mortId);

            var contentResult = response as NotFoundResult;

            Assert.IsNotNull(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);
        }
Пример #8
0
        //[Ignore]
        public void calculateMortgage()
        {
            //Arrange
            double i = 100000;
            double j = 12;
            int    k = 1;

            //Act
            MortgageController m = new MortgageController();

            double intr = m.getPercentage(j);
            int    term = m.getTerms(k);

            double result = m.calculateMortgage(i, intr, term);

            //Assert
            Assert.AreEqual(8884.88, Math.Round(result, 2));
        }
        public void TestGetMortgageByID_Valid()
        {
            //Arrange
            var mortId = 1;

            mockMortRepo.Setup(x => x.GetMortgageById(mortId)).Returns(new Mortgage()
            {
                MortgageId = 1
            });
            //ACT
            var controller             = new MortgageController(mockMortRepo.Object);
            IHttpActionResult response = controller.GetById(mortId);
            var contentResult          = response as OkNegotiatedContentResult <Mortgage>;

            //Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(mortId, contentResult.Content.MortgageId);
        }
Пример #10
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);
        }
Пример #12
0
 public void setup()
 {
     _unityContainer    = new UnityContainer();
     mortgageController = _unityContainer.Resolve <MortgageController>();
 }