Exemple #1
0
 public FinancialAssessmentController(IFinancialAssessmentDataProvider financialAssessmentDataProvider)
 {
     this.financialAssessmentDataProvider = financialAssessmentDataProvider;
 }
Exemple #2
0
        /// <summary>
        /// Financials the assessment_ success.
        /// </summary>
        private void FinancialAssessment_Success()
        {
            Mock <IFinancialAssessmentDataProvider> mock = new Mock <IFinancialAssessmentDataProvider>();

            financialAssessmentDataProvider = mock.Object;

            var financialAssessmentDetails = new List <FinancialAssessmentDetailsModel>();

            financialAssessmentDetail = new FinancialAssessmentDetailsModel()
            {
                FinancialAssessmentDetailsID = 1,
                FinancialAssessmentID        = 1,
                CategoryTypeID     = 1,
                Amount             = 100,
                FinanceFrequencyID = 17,
                CategoryID         = 1
            };
            financialAssessmentDetails.Add(financialAssessmentDetail);
            var financialAssessmentModels = new List <FinancialAssessmentModel>();

            financialAssessmentModel = new FinancialAssessmentModel()
            {
                ContactID                  = 1,
                FinancialAssessmentID      = 1,
                AssessmentDate             = DateTime.Now,
                TotalIncome                = 300000,
                TotalExpenses              = 30000,
                AdjustedGrossIncome        = 5000,
                TotalExtraOrdinaryExpenses = 100,
                TotalOther                 = 100,
                ExpirationDate             = DateTime.Now,
                ExpirationReasonID         = 0,
                FamilySize                 = 2,
                FinancialAssessmentDetails = financialAssessmentDetails
            };

            financialAssessmentModels.Add(financialAssessmentModel);
            var financialAssessment = new Response <FinancialAssessmentModel>()
            {
                DataItems   = financialAssessmentModels,
                RowAffected = 1
            };

            var financialAssessmentDetailsResult = new Response <FinancialAssessmentDetailsModel>()
            {
                DataItems   = financialAssessmentDetails,
                RowAffected = 1
            };

            //Get FinancialAssessment
            Response <FinancialAssessmentModel> financialAssessmentResponse = new Response <FinancialAssessmentModel>();

            financialAssessmentResponse.DataItems = financialAssessmentModels.Where(contact => contact.ContactID == contactId && contact.FinancialAssessmentID == financialAssessmentID).ToList();

            mock.Setup(r => r.GetFinancialAssessment(It.IsAny <long>(), It.IsAny <long>()))
            .Returns(financialAssessmentResponse);

            //Add FinancialAssessment
            mock.Setup(r => r.AddFinancialAssessment(It.IsAny <FinancialAssessmentModel>()))
            .Callback((FinancialAssessmentModel financialAssessmentsModel) => financialAssessmentModels.Add(financialAssessmentsModel))
            .Returns(financialAssessment);

            //Update FinancialAssessment
            mock.Setup(r => r.UpdateFinancialAssessment(It.IsAny <FinancialAssessmentModel>()))
            .Callback((FinancialAssessmentModel financialAssessmentsModel) => financialAssessmentModels.Add(financialAssessmentsModel))
            .Returns(financialAssessment);


            //Add FinancialAssessment Details
            mock.Setup(r => r.AddFinancialAssessmentDetails(It.IsAny <FinancialAssessmentDetailsModel>()))
            .Callback((FinancialAssessmentDetailsModel financialAssessmentsDetailsModel) => financialAssessmentDetails.Add(financialAssessmentsDetailsModel))
            .Returns(financialAssessmentDetailsResult);

            //Update FinancialAssessment Details
            mock.Setup(r => r.UpdateFinancialAssessmentDetails(It.IsAny <FinancialAssessmentDetailsModel>()))
            .Callback((FinancialAssessmentDetailsModel financialAssessmentsDetailsModel) => financialAssessmentDetails.Add(financialAssessmentsDetailsModel))
            .Returns(financialAssessmentDetailsResult);


            //Delete FinancialAssessment
            Response <bool> deleteResponse = new Response <bool>();
            List <bool>     lstStatus      = new List <bool>();

            lstStatus.Add(true);

            deleteResponse.RowAffected = 1;
            deleteResponse.ResultCode  = 0;
            deleteResponse.DataItems   = lstStatus;
            mock.Setup(r => r.DeleteFinancialAssessmentDetail(It.IsAny <long>(), DateTime.UtcNow))
            .Callback((long id) => financialAssessmentModels.Remove(financialAssessmentModels.Find(x => x.FinancialAssessmentDetails[0].FinancialAssessmentDetailsID == id)))
            .Returns(deleteResponse);
        }