Exemplo n.º 1
0
        public void TestEvalwithEmptyCallObject()
        {
            var code = new StringBuilder();

            code.AppendLine("if (_call.LineOfBusiness.Equals(\"PAU\")) {");
            code.AppendLine("\t\t_call.Claim.ClaimNumber = \"123456789\"; }");
            code.AppendLine("else {");
            code.AppendLine("\t\t_call.Claim.SetValue(\"ERRORSTRING\",\"LOB_CD NOT PAU\"); }");

            var eval = new Eval {
                Expression = code.ToString()
            };
            //eval.Parameter = call.ToXml();

            var results = eval.Execute();

            NUnit.Framework.Assert.IsEmpty(eval.LastError, eval.LastError);
            NUnit.Framework.Assert.IsNotEmpty(results, "Nothing returned!");

            var resultCall = new CallObject();

            resultCall.LoadFromXml(results);
            NUnit.Framework.Assert.IsNotEmpty(resultCall.GetValue("LASTERROR"), "Expected error was not returned!");
            Console.WriteLine(resultCall.GetValue("LASTERROR"));
        }
Exemplo n.º 2
0
        public void TestDatesLogic()
        {
            var myCall      = new CallObject();
            var strTestCall = LoadFileText(@"C:\Documents and Settings\gwynnj\My Documents\call.xml");

            Assert.IsTrue(strTestCall.Length > 0);
            myCall.LoadFromXml(strTestCall);

            var asiNode = myCall["ASI"] as Composite;

            if (asiNode == null)
            {
                return;
            }
            var reg = new Regex("_DT$");

            foreach (CompositeLeaf node in asiNode.GetEnumerator <CompositeLeaf>())
            {
                if (!reg.IsMatch(node.Name) || node.Value.Length <= 0)
                {
                    continue;
                }
                var newDate   = string.Format("{0}{1}{2}", node.Value.Substring(4, 4), node.Value.Substring(0, 2), node.Value.Substring(2, 2));
                var parseDate = string.Format("{0}/{1}/{2}", node.Value.Substring(0, 2), node.Value.Substring(2, 2), node.Value.Substring(4, 4));
                Console.WriteLine("Found Match: {0} Value: {1}", node.Name, node.Value);
                DateTime date;
                if (!DateTime.TryParse(parseDate, out date))
                {
                    continue;
                }
                node.Value = newDate;
                Console.WriteLine("Found Match: {0} Value: {1}", node.Name, node.Value);
            }
        }
Exemplo n.º 3
0
        public void TestSedgwickRuleProcessor()
        {
            const string asiDisabilityAttribute = "ASI:CTA_EMPLOYEE_BEGIN_DISABILITY_DT";

            using (var call = new CallWrapper())
            {
                call.LoadFromDSN("7679", GeneralUtility.GetDsnFromInstance(DbBaseClass.SEDBA));
                var myCall = new CallObject();
                myCall.LoadFromXml(call.GetXML());
                var originalDate = myCall.GetValue(asiDisabilityAttribute);
                //NUnit.Framework.Assert.IsTrue(originalDate.Length == 8, "Bad date format!");
                var records = RuleRecordSet.GetRuleSetByClientAndEvent("18", "CLOSE", "SEDBA");
                NUnit.Framework.Assert.IsTrue(records.Count >= 1, "Problems!");
                foreach (var record in records)
                {
                    var results = Eval.EvaluateCallObject(myCall.ToXml(), record.RuleText);
                    NUnit.Framework.Assert.IsNotEmpty(results, "Nothing returned!");

                    var resultCall = new CallObject();
                    resultCall.LoadFromXml(results);
                    NUnit.Framework.Assert.IsNotEmpty(resultCall.GetValue(asiDisabilityAttribute), "Expected result was not returned!");
                    NUnit.Framework.Assert.IsFalse(originalDate.Equals((resultCall.GetValue(asiDisabilityAttribute))),
                                                   "dates are unchanged!");
                    Console.WriteLine("Original: {0} Transformed: {1}", originalDate, resultCall.GetValue(asiDisabilityAttribute));
                }
            }
        }
Exemplo n.º 4
0
        public void TestNameValues()
        {
            const string accountId = "ACCOUNT_ID";
            const string policyId  = "POLICY_ID";

            _base.SetValue(accountId, "12345");
            _base.SetValue(policyId, "678910");

            var copyCall = new CallObject();

            copyCall.LoadFromXml(_base.ToXml());
            Assert.IsNotEmpty(copyCall.GetValue(accountId));
            Assert.IsNotEmpty(copyCall.GetValue(policyId));
            copyCall.Remove(policyId);
            Assert.IsEmpty(copyCall.GetValue(policyId));

            // subtract method
            var items = _base.ToNameValueCollection();

            foreach (var key in items.AllKeys)
            {
                if (string.IsNullOrEmpty(copyCall.GetValue(key)))
                {
                    _base.Remove(key);
                }
            }
            Assert.IsEmpty(_base.GetValue(policyId));
            Console.WriteLine(_base);
        }
Exemplo n.º 5
0
        public void TestCopy()
        {
            const string vehicle = "CLAIM:INSURED:VEHICLE";
            const string vin     = "CLAIM:INSURED:VEHICLE:VIN";
            var          call    = new CallObject();

            call.LoadFromXml(_base.GetXmlTree(vin));
            Assert.IsNotEmpty(call.GetValue(vin), "Nothing returned!");
            Console.WriteLine(call.GetValue(vin));

            call.LoadFromXml(_base.GetXmlTree(vehicle));
            var results = call.ToXml();

            Assert.IsNotEmpty(results, "Nothing returned!");
            Console.WriteLine(results);
        }
Exemplo n.º 6
0
        public void TestCopyNode()
        {
            var call = new CallObject();

            call.LoadFromXml(_base.ToXml());
            var vehicle = call.GetNode("CLAIM:INSURED:VEHICLE");

            Assert.IsNotNull(vehicle);
            Console.WriteLine(vehicle.ToString());
            var items = vehicle.ToNameValueDictionary();

            foreach (var item in items.Keys)
            {
                Console.WriteLine("{0}={1}", item, items[item]);
            }
        }
Exemplo n.º 7
0
        public void TestStaticEvalwithEmptyCallObject()
        {
            var code = new StringBuilder();

            code.AppendLine("if (_call.LineOfBusiness.Equals(\"PAU\")) {");
            code.AppendLine("\t\t_call.Claim.ClaimNumber = \"123456789\"; }");
            code.AppendLine("else {");
            code.AppendLine("\t\t_call.Claim.SetValue(\"ERRORSTRING\",\"LOB_CD NOT PAU\"); }");

            var results = Eval.EvaluateCallObject(string.Empty, code.ToString());

            NUnit.Framework.Assert.IsNotEmpty(results, "Nothing returned!");

            var resultCall = new CallObject();

            resultCall.LoadFromXml(results);
            NUnit.Framework.Assert.IsNotEmpty(resultCall.GetValue("LASTERROR"), "Expected error was not returned!");
            Console.WriteLine(resultCall.GetValue("LASTERROR"));
        }
Exemplo n.º 8
0
        public void TestAddress()
        {
            var call        = new CallObject();
            var strTestCall = LoadFileText(@"C:\Documents and Settings\john.gwynn\My Documents\call.xml");

            Assert.IsTrue(strTestCall.Length > 0);
            call.LoadFromXml(strTestCall);

            Assert.IsNotEmpty(call.Claim.Insured.Address.Fips, "Insured Fips is missing!");

            Assert.IsNotEmpty(call.Claim.LossLocation.Address.Address1, "Loss location Address1 is missing!");
            Assert.IsNotEmpty(call.Claim.LossLocation.Address.City, "Loss location City is missing!");
            Assert.IsNotEmpty(call.Claim.LossLocation.Address.State, "Loss location State is missing!");

            call.Claim.Remove("LOSS_LOCATION");

            Assert.IsEmpty(call.Claim.LossLocation.Address.Address1, "Loss location Address1 is not empty!");
            Assert.IsEmpty(call.Claim.LossLocation.Address.City, "Loss location City s not empty!");
            Assert.IsEmpty(call.Claim.LossLocation.Address.State, "Loss location State s not empty!");

            call.Claim.LossLocation.Address.Address1 = "529 Main Street";
            call.Claim.LossLocation.Address.City     = "Charlestown";
            call.Claim.LossLocation.Address.State    = "MA";
            call.Claim.LossLocation.Address.Zip      = "02129";

            Assert.IsNotEmpty(call.GetValue("CLAIM:LOSS_LOCATION:ADDRESS_LINE1"), "Loss location Address1 is missing!");
            Assert.IsNotEmpty(call.GetValue("CLAIM:LOSS_LOCATION:ADDRESS_CITY"), "Loss location City is missing!");
            Assert.IsNotEmpty(call.GetValue("CLAIM:LOSS_LOCATION:ADDRESS_STATE"), "Loss location State is missing!");
            Assert.IsNotEmpty(call.GetValue("CLAIM:LOSS_LOCATION:ADDRESS_ZIP"), "Loss location Zip is missing!");

            Console.WriteLine("{0}\n{1}, {2} {3}",
                              call.Claim.LossLocation.Address.Address1,
                              call.Claim.LossLocation.Address.City,
                              call.Claim.LossLocation.Address.State,
                              call.Claim.LossLocation.Address.Zip);
        }