private bool IsResponseCorrect(InRuleResponse response, InRuleResponse expectedResponse)
        {
            List <Payment> payments         = DeserializeFromXml <List <Payment> >(response.RuleResult.Replace("LoanPayments", "ArrayOfPayment"));
            List <Payment> expectedPayments = DeserializeFromXml <List <Payment> >(expectedResponse.RuleResult.Replace("LoanPayments", "ArrayOfPayment"));

            foreach (Payment payment in payments)
            {
                bool loanNumberFound = false;
                foreach (Payment expectedPayment in expectedPayments)
                {
                    if (expectedPayment.LoanNumber == payment.LoanNumber)
                    {
                        loanNumberFound = true;
                        if ((expectedPayment.InterestPayment != payment.InterestPayment) ||
                            (expectedPayment.PrincipalPayment != payment.PrincipalPayment))
                        {
                            return(false);
                        }
                    }
                }
                if (!loanNumberFound)
                {
                    return(false);
                }
            }
            return(true);
        }
        private InRuleResponse GetResponseFromFile(string fileName)
        {
            XmlSerializer  reader   = new XmlSerializer(typeof(InRuleResponse));
            StreamReader   file     = new StreamReader(Settings.Default.TestFilesPath + fileName);
            InRuleResponse response = new InRuleResponse();

            response = (InRuleResponse)reader.Deserialize(file);
            return(response);
        }
 public void TestUndirectedPaymentAllocation_Jane6a()
 {
     using (InRuleServiceClient serviceClient = new InRuleServiceClient())
     {
         InRuleResponse response         = serviceClient.PaymentAllocationRules(GetRequestFromFile("InRuleRequestJane6a.xml"));
         InRuleResponse expectedResponse = GetResponseFromFile("InRuleResponseJane6a.xml");
         Assert.IsTrue(response.RuleInfo.Status == "Success");
         Assert.IsTrue(IsResponseCorrect(response, expectedResponse));
     }
 }
        public void TestDirectedPaymentAllocation()
        {
            using (InRuleServiceClient serviceClient = new InRuleServiceClient())
            {
                XmlSerializer reader  = new XmlSerializer(typeof(InRuleRequest));
                StreamReader  file    = new StreamReader(Settings.Default.TestFilesPath + "InRuleRequestDirected.xml");
                InRuleRequest request = new InRuleRequest();
                request = (InRuleRequest)reader.Deserialize(file);

                InRuleResponse response = serviceClient.PaymentAllocationRules(request);
            }
        }
 public void TestUndirectedPaymentAllocation_MissingFederal()
 {
     using (InRuleServiceClient serviceClient = new InRuleServiceClient())
     {
         InRuleResponse response = serviceClient.PaymentAllocationRules(GetRequestFromFile("InRuleRequest_missing_federal.xml"));
         //Failure if response validation is enabled on the server
         Assert.IsTrue(response.RuleInfo.Status == "Failure");
         //Success if response validation is not enabled on the server
         //Assert.IsTrue(response.RuleInfo.Status == "Failure");
         Assert.IsTrue(response.RuleInfo.ErrorDetails.Count > 0);
     }
 }