示例#1
0
        private decimal CalculateAmmountApproved(LoanRequestRequest request)
        {
            decimal response = 0;

            if (request.Id == 3)
            {
                response = 4000;
            }
            else if (request.Id == 7)
            {
                response = 7000;
            }
            else if (request.Id == 9)
            {
                response = 5000;
            }
            else if (request.Id == 11)
            {
                response = 50000;
            }
            else if (request.Id == 13)
            {
                response = 15000;
            }

            return(response);
        }
示例#2
0
        private string ValidateBorrowingCapacity(LoanRequestRequest request)
        {
            string response = string.Empty;

            if (request.Id == 3)
            {
                if (request.AmmountRequested > 5000)
                {
                    response = "The ammount requested is higher than the borrowing capacity";
                }
            }
            else if (request.Id == 7)
            {
                if (request.AmmountRequested > 9000)
                {
                    response = "The ammount requested is higher than the borrowing capacity";
                }
            }
            else if (request.Id == 11)
            {
                if (request.AmmountRequested > 50000)
                {
                    response = "The ammount requested is higher than the borrowing capacity";
                }
            }

            return(response);
        }
示例#3
0
        public LoanRequestResponse ValidateLoanRequest(LoanRequestRequest request)
        {
            LoanRequestResponse response = new LoanRequestResponse();

            response.AmmountRequested = request.AmmountRequested;

            response.ErrorMessage = this.ValidateClientInformation(request);
            if (string.IsNullOrEmpty(response.ErrorMessage))
            {
                response.ErrorMessage = this.ValidateRiskCenter(request);
                if (string.IsNullOrEmpty(response.ErrorMessage))
                {
                    response.ErrorMessage = this.ValidateBorrowingCapacity(request);
                    if (string.IsNullOrEmpty(response.ErrorMessage))
                    {
                        response.AmmountApproved = this.CalculateAmmountApproved(request);
                    }
                }
                else
                {
                    response.ControlRiskStateReported = true;
                }
            }

            response.Approved = response.AmmountApproved > 0;

            return(response);
        }
示例#4
0
        private string ValidateRiskCenter(LoanRequestRequest request)
        {
            string response = string.Empty;

            if (request.Id == 1 || request.Id == 5)
            {
                response = "The client is reported in the risk center";
            }

            return(response);
        }
示例#5
0
        private string ValidateClientInformation(LoanRequestRequest request)
        {
            string response = string.Empty;

            if (request.Id > 13)
            {
                response = "the current Id client does not exist";
            }
            else if (request.Id % 2 == 0)
            {
                response = "Client is not valid";
            }

            return(response);
        }
示例#6
0
        public void RunTest(List <int> idTestCases)
        {
            foreach (var idTestCase in idTestCases)
            {
                TestCase testCase = testDataAccess.GetTestCase(idTestCase);
                bool     success  = false;

                if (testCase != null && testCase.IdTestCase > 0)
                {
                    LoanRequestRequest  request  = (LoanRequestRequest)XmlHelper.XmlDeserializeFromString(testCase.Input, typeof(LoanRequestRequest));
                    LoanRequestResponse response = loanClient.LoanRequest(request);

                    success = ValidateTestCase(idTestCase, response);
                }
                else
                {
                    //throw new Exception(string.Format("There is no a test case with the parameter idTestCase = {0}", testCase));
                    success = false;
                }
            }
        }
 public LoanRequestResponse LoanRequest(LoanRequestRequest request)
 {
     BusinessComponent.Loan loanBusiness = new BusinessComponent.Loan();
     return(loanBusiness.ValidateLoanRequest(request));
 }
示例#8
0
        public Test()
        {
            LoanRequestRequest e = new LoanRequestRequest()
            {
                AmmountRequested = 324234,
                Direccion        = new Direccion {
                    Carrera  = "sdfsdf",
                    Latitude = new Latitude {
                        Longitud = 23123
                    }
                },
                Id   = 12,
                Type = LoanType.Car
            };

            var x = CrossCutting.Utils.XmlHelper.SerializeObject(e);

            //var a = e.GetType();
            //Activator.CreateInstance(a.AssemblyQualifiedName, a.q)

            //CrossCutting.Utils.XmlHelper.SerializeObject<>
            //using (var client = new WebClient())
            //{
            //    Automation.DataAccess.Test testDataAccess = new Automation.DataAccess.Test();
            //    TestCase testCase = testDataAccess.GetTestCase(6);

            //    XmlDocument xml = new XmlDocument();
            //    xml.LoadXml(testCase.Input);
            //    //xml.FirstChild.Value.GetType();


            //    // read the raw SOAP request message from a file
            //    //var data = File.ReadAllText(testCase.Input);
            //    // the Content-Type needs to be set to XML
            //    client.Headers.Add("Content-Type", "text/xml;charset=utf-8");
            //    // The SOAPAction header indicates which method you would like to invoke
            //    // and could be seen in the WSDL: <soap:operation soapAction="..." /> element
            //    client.Headers.Add("SOAPAction", "http://tempuri.org/ILoan/LoanRequest");
            //    var response = client.UploadString("http://localhost/Sofka.Automation.Dummy.Wcf/Loan.svc", testCase.Input);
            //    Console.WriteLine(response);
            //}

            Provider.XsdGenerator asas = new XsdGenerator();

            //Automation.DataAccess.Test testDataAccess = new Automation.DataAccess.Test();
            //TestCase testCase = testDataAccess.GetTestCase(6);

            //client = new Provider.TestConnector
            //{
            //    Request = testCase.Input,
            //    Url = "http://localhost/Sofka.Automation.Dummy.Wcf/Loan.svc",
            //    WSServiceType = Provider.TestConnector.ServiceType.WCF,
            //    WCFContractName = "ILoan",
            //    WebMethod = "LoanRequest"
            //};


            //client.BeginInvokeService(InvokeCompleted);

            //testDataAccess = new DataAccess.Test();
            //loanClient = new LoanClient();
        }