コード例 #1
0
        public void RunScript_SetFieldValue_OptionObject2015_ReturnsErrorCode0()
        {
            // Arrange
            FieldObject fieldObject = new FieldObject()
            {
                FieldNumber = "123",
                FieldValue  = "TESTING"
            };
            RowObject rowObject = new RowObject()
            {
                Fields = new List <FieldObject>()
                {
                    fieldObject
                },
                RowId = "1||1"
            };
            FormObject formObject = new FormObject()
            {
                CurrentRow = rowObject,
                FormId     = "1"
            };
            OptionObject2015 optionObject = new OptionObject2015()
            {
                Forms = new List <FormObject>()
                {
                    formObject
                }
            };
            string parameter = "?";

            // Act
            OptionObject2015 returnOptionObject = SetFieldValue.RunScript(optionObject, parameter);

            // Assert
            Assert.AreEqual(0, returnOptionObject.ErrorCode);
        }
コード例 #2
0
        public void RunScript_SetFieldValue_OptionObject2_FormCountEquals1()
        {
            // Arrange
            FieldObject fieldObject = new FieldObject()
            {
                FieldNumber = "123",
                FieldValue  = "TESTING"
            };
            RowObject rowObject = new RowObject()
            {
                Fields = new List <FieldObject>()
                {
                    fieldObject
                },
                RowId = "1||1"
            };
            FormObject formObject = new FormObject()
            {
                CurrentRow = rowObject,
                FormId     = "1"
            };
            OptionObject2 optionObject = new OptionObject2()
            {
                Forms = new List <FormObject>()
                {
                    formObject
                }
            };
            string parameter = "?";

            // Act
            OptionObject2 returnOptionObject = SetFieldValue.RunScript(optionObject, parameter);

            // Assert
            Assert.AreEqual(1, returnOptionObject.Forms.Count);
        }
コード例 #3
0
        public OptionObject RunScript(OptionObject optionObject, string parameter)
        {
            OptionObject returnOptionObject = new OptionObject();
            string       scriptName         = parameter != null?parameter.Split(',')[0] : "";

            logger.Debug("Script '" + scriptName + "' requested.");

            switch (scriptName)
            {
            case "GetErrorCode0":
                returnOptionObject = GetErrorCode0.RunScript(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetErrorCode1":
                returnOptionObject = GetErrorCode1.RunScript(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetErrorCode2":
                returnOptionObject = GetErrorCode2.RunScript(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetErrorCode3":
                returnOptionObject = GetErrorCode3.RunScript(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetErrorCode4":
                returnOptionObject = GetErrorCode4.RunScript(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetErrorCode5":
                returnOptionObject = GetErrorCode5.RunScript(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetErrorCode6":
                returnOptionObject = GetErrorCode6.RunScript(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetFieldValue":
                returnOptionObject = GetFieldValue.RunScript(optionObject, parameter);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "SetFieldValue":
                returnOptionObject = SetFieldValue.RunScript(optionObject, parameter);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            default:
                logger.Warn("ScriptName '" + scriptName + "' does not match an existing script.");
                returnOptionObject = DefaultScript.RunScript(optionObject, scriptName);
                break;
            }

            return(returnOptionObject);
        }