Exemplo n.º 1
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.º 2
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.º 3
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.º 4
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.º 5
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.º 6
0
        public void TestConditionalVisitor()
        {
            var predicate = new ConditionalVisitor(p => p.IsLeaf && p.Name.IndexOf("NAME") > -1);

            _base.Accept(predicate);

            Assert.IsTrue(predicate.Results.Count > 0);
            foreach (var s in predicate.Results)
            {
                Console.WriteLine("{0}={1}", s, _base.GetValue(s));
            }

            var expressionVisitor = new NameExpressionVisitor("ADDRESS");

            _base.Accept(expressionVisitor);

            Assert.IsTrue(expressionVisitor.Results.Count > 0);
            foreach (var s in expressionVisitor.Results)
            {
                Console.WriteLine("{0}={1}", s, _base.GetValue(s));
            }
        }
Exemplo n.º 7
0
        public void TestJson()
        {
            _base.SetValue("CLAIM:VEHICLE[0]:MAKE", "PLYMOUTH");
            _base.SetValue("CLAIM:VEHICLE[0]:MODEL", "VALIANT");
            _base.SetValue("CLAIM:VEHICLE[1]:MAKE", "DODGE");
            _base.SetValue("CLAIM:VEHICLE[1]:MODEL", "RAM");
            _base.SetValue("CLAIM:VEHICLE[2]:MAKE", "TOYOTA");
            _base.SetValue("CLAIM:VEHICLE[2]:MODEL", "CAMRY");
            _base.Instance      = "TEST";
            _base.CallStartTime = "12:00 PM";
            _base.CallStartDate = "12/12/2008";
            string script = _base.ToJson();

            Console.WriteLine(script);

            var test = new CallObject();

            test.LoadFromJson(script);
            Assert.IsTrue(test.Name == "CALL", "Not working: " + test.Name);

            Assert.IsTrue(test.Instance == "TEST", "Unexpected result INSTANCE!");
            Assert.IsTrue(test.CallStartTime == "12:00 PM", "Unexpected result CALL_START_TIME!");
            Assert.IsTrue(test.CallStartDate == "12/12/2008", "Unexpected result CALL_START_DATE!");
            Assert.IsTrue(test.GetValue("CLAIM:VEHICLE[0]:MODEL") == "VALIANT", "Unexpected result CLAIM:VEHICLE[0]:MODEL!");
            Assert.IsTrue(test.GetValue("CLAIM:VEHICLE[1]:MAKE") == "DODGE", "Unexpected result CLAIM:VEHICLE[1]:MAKE!");
            Assert.IsTrue(test.GetValue("CLAIM:INSURED:VEHICLE:MODEL") == "MATRIX", "Unexpected result CLAIM:INSURED:VEHICLE:MODEL!");
            Assert.IsTrue(test.GetValue("CLAIM:VEHICLE[2]:MODEL") == "CAMRY", "Unexpected result CLAIM:VEHICLE[2]:MODEL!");

            Console.WriteLine(test.ToXml());

            var callObject = Composite.CreateFromJson(script) as CallObject;

            Assert.IsNotNull(callObject, "callObject was null!");
            Assert.IsTrue(callObject.GetType() == typeof(CallObject), "type mismatch");

            Console.WriteLine(callObject.Claim.GetType().ToString());
        }
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);
        }
Exemplo n.º 9
0
        public void TestNodeCount()
        {
            var call = new CallObject {
                CallId = "12"
            };

            Assert.IsNotEmpty(call.GetValue("CALL_ID"));

            call.SetValue("CLAIM:VEHICLE[0]:VIN", "123456789");
            call.SetValue("CLAIM:VEHICLE[1]:VIN", "123456789");
            call.SetValue("CLAIM:VEHICLE[2]:VIN", "123456789");
            call.SetValue("CLAIM:VEHICLE[3]:VIN", "123456789");

            Assert.IsTrue(call.GetNodeCount("CLAIM:VEHICLE") == 4);
        }