public void GetMortgageDetailsById() { //Arrange Mock <IMortgageService> mortgageService = new Mock <IMortgageService>(); mortgageService.Setup(ur => ur.GetAllMortgages()).Returns(this.model); //Action Api.Controllers.MortgageController controller = new Api.Controllers.MortgageController(mortgageService.Object); Dto.Mortgage result = controller.Get(1); //Assert mortgageService.Verify(ur => ur.GetAllMortgages(), Times.Once); Dto.Mortgage data = (Dto.Mortgage)(result); Assert.IsNotNull(data); }
public void Setup() { this.model = new List <Dto.Mortgage>(); DateTime StartDate = DateTime.Now; StartDate = StartDate.AddDays(-10); model.Add(new Dto.Mortgage { Name = "Fixed Home Loan (Interest Only)", EffectiveStartDate = DateTime.Parse(StartDate.ToString()), EffectiveEndDate = DateTime.Parse(DateTime.Today.ToString()), CancellationFee = Convert.ToDecimal(259.99), EstablishmentFee = Convert.ToDecimal(259.99), InterestRepayment = (Dto.InterestRepayment)Enum.Parse(typeof(Dto.InterestRepayment), "InterestOnly"), MortgageId = 1, MortgageType = (Dto.MortgageType)Enum.Parse(typeof(Dto.MortgageType), "Variable") }); this.models = new Dto.Mortgage(); models.Name = "Fixed Home Loan (Interest Only)"; models.EffectiveStartDate = DateTime.Parse(StartDate.ToString()); models.EffectiveEndDate = DateTime.Parse(DateTime.Today.ToString()); models.CancellationFee = Convert.ToDecimal(259.99); models.EstablishmentFee = Convert.ToDecimal(259.99); models.InterestRepayment = (Dto.InterestRepayment)Enum.Parse(typeof(Dto.InterestRepayment), "InterestOnly"); models.MortgageId = 1; models.MortgageType = (Dto.MortgageType)Enum.Parse(typeof(Dto.MortgageType), "Variable"); details = new Dto.MortgageDetails(); details.LoanAmount = 100000; details.LoanDurationY = 15; details.InterestRateY = 6; expdetails = new Dto.MortgageDetails(); expdetails.LoanAmount = 100000; expdetails.LoanDurationY = 15; expdetails.InterestRateY = 6; expdetails.MonthlyPayment = 843.90; expdetails.TotalRepayment = 151902; expdetails.TotalInterestPaid = 51902; invaliddetails = new Dto.MortgageDetails(); invaliddetails.LoanDurationY = 15; invaliddetails.InterestRateY = 6; }