public void OptionObject_GetFieldValue_AreEqual()
        {
            var expected = "Value";
            var actual   = configuredOptionObject.GetFieldValue("123");

            Assert.AreEqual(expected, actual);
        }
示例#2
0
        public void GetFieldValueOptionObjectNullReturnsError()
        {
            OptionObject optionObject = null;
            string       expected1    = "TEST";
            string       expected2    = "TESTED";

            Assert.AreEqual(expected1, optionObject.GetFieldValue("124"));
            Assert.AreNotEqual(expected2, optionObject.GetFieldValue("124"));
            Assert.AreEqual(expected1, optionObject.GetFieldValue("1", "1||1", "124"));
            Assert.AreEqual(expected2, optionObject.GetFieldValue("1", "1||2", "124"));
        }
        public void OptionObject_GetFieldValue_AreNotEqual()
        {
            OptionObject optionObject = new OptionObject();
            var          expected     = "Value";
            var          actual       = optionObject.GetFieldValue("123");

            Assert.AreNotEqual(expected, actual);
        }
示例#4
0
        public void GetFieldValueOptionObjectMissingFieldReturnsError()
        {
            FieldObject fieldObject1 = new FieldObject("123", "TEST");
            RowObject   rowObject1   = new RowObject("1||1");
            FieldObject fieldObject2 = new FieldObject("123", "TESTED");
            RowObject   rowObject2   = new RowObject("1||2");

            rowObject1.Fields.Add(fieldObject1);
            rowObject2.Fields.Add(fieldObject2);
            FormObject formObject = new FormObject("1", rowObject1);

            formObject.OtherRows.Add(rowObject2);
            OptionObject optionObject = new OptionObject();

            optionObject.Forms.Add(formObject);
            string expected1 = "TEST";
            string expected2 = "TESTED";

            Assert.AreEqual(expected1, optionObject.GetFieldValue("124"));
            Assert.AreNotEqual(expected2, optionObject.GetFieldValue("124"));
            Assert.AreEqual(expected1, optionObject.GetFieldValue("1", "1||1", "124"));
            Assert.AreEqual(expected2, optionObject.GetFieldValue("1", "1||2", "124"));
        }
示例#5
0
        public void GetFieldValueOptionObjectReturnsString()
        {
            FieldObject fieldObject1 = new FieldObject("123", "TEST");
            RowObject   rowObject1   = new RowObject("1||1");
            FieldObject fieldObject2 = new FieldObject("123", "TESTED");
            RowObject   rowObject2   = new RowObject("1||2");

            rowObject1.Fields.Add(fieldObject1);
            rowObject2.Fields.Add(fieldObject2);
            FormObject formObject = new FormObject("1", rowObject1);

            formObject.OtherRows.Add(rowObject2);
            OptionObject optionObject = new OptionObject();

            optionObject.Forms.Add(formObject);
            string expected1 = "TEST";
            string expected2 = "TESTED";

            Assert.AreEqual(expected1.GetType(), optionObject.GetFieldValue("123").GetType());
            Assert.AreEqual(expected2.GetType(), optionObject.GetFieldValue("123").GetType());
            Assert.AreEqual(expected1.GetType(), optionObject.GetFieldValue("1", "1||1", "123").GetType());
            Assert.AreEqual(expected2.GetType(), optionObject.GetFieldValue("1", "1||2", "123").GetType());
        }
        public static OptionObject RunScript(OptionObject optionObject, string parameter)
        {
            string[] parameters    = parameter.Split(',');
            string   fieldNumber   = parameters.Length >= 2 ? parameters[1] : "";
            string   returnMessage = "The FieldValue is ";

            if (optionObject.IsFieldPresent(fieldNumber))
            {
                returnMessage += optionObject.GetFieldValue(fieldNumber);
            }

            returnMessage += ". Since no FieldObjects were modified, no Forms should be returned.";

            return(optionObject.ToReturnOptionObject(ErrorCode.Informational, returnMessage));
        }
 public static OptionObject RunScript(OptionObject optionObject, string parameter)
 {
     if (optionObject.IsFieldPresent("123"))
     {
         string fieldValue = optionObject.GetFieldValue("123");
         if (string.IsNullOrEmpty(fieldValue))
         {
             fieldValue = "I have set the FieldValue.";
         }
         else
         {
             fieldValue += " (I have appended the FieldValue.)";
         }
         optionObject.SetFieldValue("123", fieldValue);
     }
     return(optionObject.ToReturnOptionObject(ErrorCode.Success, "If FieldNumber 123 is found in OptionObject, then it should be the only FieldObject returned. Otherwise, no Forms should be returned."));
 }