Exemple #1
0
        public void SetFailedFatallyStatus()
        {
            _engine       = new AutomationEngineInstance(null);
            _setQueueItem = new SetQueueItemStatusCommand();

            string name = "FailedQueueItem";

            AddQueueItem(name);
            var queueItemDict = WorkQueueItem();

            var client         = AuthMethods.GetAuthToken();
            var transactionKey = queueItemDict["LockTransactionKey"].ToString();
            var queueItem      = QueueItemMethods.GetQueueItemByLockTransactionKey(client, transactionKey);

            VariableMethods.CreateTestVariable(null, _engine, "vQueueItem", typeof(Dictionary <,>));
            _setQueueItem.v_QueueItem = "{vQueueItem}";
            queueItemDict.StoreInUserVariable(_engine, _setQueueItem.v_QueueItem, typeof(Dictionary <,>));
            _setQueueItem.v_QueueItemStatusType = "Failed - Fatal";

            _setQueueItem.RunCommand(_engine);

            queueItem = QueueItemMethods.GetQueueItemById(client, queueItem.Id);

            Assert.Equal("Failed", queueItem.State);
        }
        public void CreatesDataTable()
        {
            _createDataTableCommand = new CreateDataTableCommand();
            _engine = new AutomationEngineInstance(null);

            OBData.DataTable columnNameDataTable = new OBData.DataTable
            {
                TableName = "ColumnNamesDataTable" + DateTime.Now.ToString("MMddyy.hhmmss")
            };
            VariableMethods.CreateTestVariable("Col1", _engine, "Col1", typeof(string));
            VariableMethods.CreateTestVariable(null, _engine, "outputTable", typeof(OBData.DataTable));
            columnNameDataTable.Columns.Add("{Col1}");

            _createDataTableCommand.v_ColumnNameDataTable    = columnNameDataTable;
            _createDataTableCommand.v_OutputUserVariableName = "{outputTable}";

            _createDataTableCommand.RunCommand(_engine);

            OBData.DataTable expectedDt = new OBData.DataTable();
            foreach (DataRow rwColumnName in columnNameDataTable.Rows)
            {
                expectedDt.Columns.Add(rwColumnName.Field <string>("Column Name").ConvertUserVariableToString(_engine));
            }

            OBData.DataTable resultDataTable = (OBData.DataTable)_createDataTableCommand.v_OutputUserVariableName.ConvertUserVariableToObject(_engine, typeof(OBData.DataTable));

            for (int row = 0; row < expectedDt.Rows.Count; row++)
            {
                for (int col = 0; col < expectedDt.Columns.Count; col++)
                {
                    Assert.Equal(expectedDt.Rows[row][expectedDt.Columns[col]], resultDataTable.Rows[row][resultDataTable.Columns[col]]);
                }
            }
        }
        public async void SplitsTextWithMultipleDelimiters()
        {
            _splitText = new SplitTextCommand();
            _engine    = new AutomationEngineInstance(null);

            string        inputText       = "test text:with!multiple;delimiters";
            List <string> splitCharacters = new List <string>();

            splitCharacters.Add(" ");
            splitCharacters.Add(":");
            splitCharacters.Add("!");
            splitCharacters.Add(";");
            VariableMethods.CreateTestVariable(inputText, _engine, "input", typeof(string));
            VariableMethods.CreateTestVariable(splitCharacters, _engine, "splitChar", typeof(List <>));
            VariableMethods.CreateTestVariable(null, _engine, "output", typeof(List <>));

            _splitText.v_InputText              = "{input}";
            _splitText.v_SplitCharacter         = "{splitChar}";
            _splitText.v_OutputUserVariableName = "{output}";

            _splitText.RunCommand(_engine);

            List <string> splitText = (List <string>)await "{output}".EvaluateCode(_engine);

            Assert.Equal("test", splitText[0]);
            Assert.Equal("text", splitText[1]);
            Assert.Equal("with", splitText[2]);
            Assert.Equal("multiple", splitText[3]);
            Assert.Equal("delimiters", splitText[4]);
        }
Exemple #4
0
        public void CompressesFilesWithPassword()
        {
            _engine        = new AutomationEngineInstance(null);
            _compressFiles = new CompressFilesCommand();

            string projectDirectory = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;
            string inputPath        = Path.Combine(projectDirectory, @"Resources\toCompressWithPassword");

            VariableMethods.CreateTestVariable(inputPath, _engine, "inputPath", typeof(string));

            string outputPath = Environment.CurrentDirectory;

            VariableMethods.CreateTestVariable(outputPath, _engine, "outputPath", typeof(string));

            string password = "******";

            VariableMethods.CreateTestVariable(password.ConvertStringToSecureString(), _engine, "testPassword", typeof(SecureString));
            VariableMethods.CreateTestVariable(null, _engine, "output", typeof(string));

            _compressFiles.v_DirectoryPathOrigin    = "{inputPath}";
            _compressFiles.v_Password               = "******";
            _compressFiles.v_PathDestination        = "{outputPath}";
            _compressFiles.v_OutputUserVariableName = "{output}";

            _compressFiles.RunCommand(_engine);

            Assert.True(IO.File.Exists(Path.Combine(Environment.CurrentDirectory, @"toCompressWithPassword.zip")));

            IO.File.Delete(Path.Combine(outputPath, @"toCompressWithPassword.zip"));
        }
Exemple #5
0
        public async System.Threading.Tasks.Task HandlesNonExistentQueue()
        {
            _engine        = new AutomationEngineInstance(null);
            _addQueueItem  = new AddQueueItemCommand();
            _workQueueItem = new WorkQueueItemCommand();

            var textValue = "{ \"text\": \"testText\" }";

            VariableMethods.CreateTestVariable(null, _engine, "output", typeof(Dictionary <,>));
            VariableMethods.CreateTestVariable(textValue, _engine, "textValue", typeof(string));

            _addQueueItem.v_QueueName          = "UnitTestQueue";
            _addQueueItem.v_QueueItemName      = "WorkQueueItemJsonTest";
            _addQueueItem.v_QueueItemType      = "Json";
            _addQueueItem.v_JsonType           = "Test Type";
            _addQueueItem.v_QueueItemTextValue = "{textValue}";
            _addQueueItem.v_Priority           = "10";

            _addQueueItem.RunCommand(_engine);

            _workQueueItem.v_QueueName = "NoQueue";
            _workQueueItem.v_OutputUserVariableName = "{output}";
            _workQueueItem.v_SaveAttachments        = "No";
            _workQueueItem.v_AttachmentDirectory    = "";

            await Assert.ThrowsAsync <DataException>(() => _workQueueItem.RunCommand(_engine));
        }
Exemple #6
0
        public async Task HandlesNonExistentTransactionKey()
        {
            _engine       = new AutomationEngineInstance(null);
            _setQueueItem = new SetQueueItemStatusCommand();

            var queueItemDict = new Dictionary <string, object>()
            {
                { "LockTransactionKey", null },
                { "Name", "ExtendQueueItemTest" },
                { "Source", null },
                { "Event", null },
                { "Type", "Text" },
                { "JsonType", "Test Type" },
                { "DataJson", "Test Text" },
                { "Priority", 10 },
                { "LockedUntilUTC", DateTime.UtcNow.AddHours(1) }
            };

            VariableMethods.CreateTestVariable(null, _engine, "vQueueItem", typeof(Dictionary <,>));
            _setQueueItem.v_QueueItem           = "{vQueueItem}";
            _setQueueItem.v_QueueItemStatusType = "Successful";
            queueItemDict.SetVariableValue(_engine, _setQueueItem.v_QueueItem);

            await Assert.ThrowsAsync <NullReferenceException>(() => _setQueueItem.RunCommand(_engine));
        }
        public void ExecuteScript(JobExecutionParams executionParams)
        {
            var engineContext = GetEngineContext(executionParams);
            var engine        = new AutomationEngineInstance(engineContext);

            engine.ExecuteScriptSync();
        }
Exemple #8
0
        public void ForwardsOutlookEmail()
        {
            _engine              = new AutomationEngineInstance(null);
            _getOutlookEmails    = new GetOutlookEmailsCommand();
            _forwardOutlookEmail = new ForwardOutlookEmailCommand();
            _deleteOutlookEmail  = new DeleteOutlookEmailCommand();

            VariableMethods.CreateTestVariable(null, _engine, "emails", typeof(List <>));

            _getOutlookEmails.v_SourceFolder  = "TestInput";
            _getOutlookEmails.v_Filter        = "[Subject] = 'toForward'";
            _getOutlookEmails.v_GetUnreadOnly = "No";
            _getOutlookEmails.v_MarkAsRead    = "No";
            _getOutlookEmails.v_SaveMessagesAndAttachments = "No";
            _getOutlookEmails.v_MessageDirectory           = "";
            _getOutlookEmails.v_AttachmentDirectory        = "";
            _getOutlookEmails.v_OutputUserVariableName     = "{emails}";

            _getOutlookEmails.RunCommand(_engine);

            var      emails = (List <MailItem>) "{emails}".ConvertUserVariableToObject(_engine, typeof(List <>));
            MailItem email  = emails[0];

            VariableMethods.CreateTestVariable(email, _engine, "email", typeof(MailItem));
            string forwardAddress = "*****@*****.**";

            VariableMethods.CreateTestVariable(forwardAddress, _engine, "forwardEmail", typeof(string));

            _forwardOutlookEmail.v_MailItem   = "{email}";
            _forwardOutlookEmail.v_Recipients = "{forwardEmail}";

            _forwardOutlookEmail.RunCommand(_engine);

            int attempts = 0;

            do
            {
                System.Threading.Thread.Sleep(5000);

                _getOutlookEmails.v_SourceFolder  = "Inbox";
                _getOutlookEmails.v_Filter        = "[Subject] = 'toForward'";
                _getOutlookEmails.v_GetUnreadOnly = "No";
                _getOutlookEmails.v_MarkAsRead    = "No";
                _getOutlookEmails.v_SaveMessagesAndAttachments = "No";
                _getOutlookEmails.v_MessageDirectory           = "";
                _getOutlookEmails.v_AttachmentDirectory        = "";
                _getOutlookEmails.v_OutputUserVariableName     = "{emails}";

                _getOutlookEmails.RunCommand(_engine);

                emails = (List <MailItem>) "{emails}".ConvertUserVariableToObject(_engine, typeof(List <>));
                attempts++;
            } while (emails.Count < 1 & attempts < 5);
            email = emails[0];

            Assert.Equal("*****@*****.**", email.Sender.Address);
            Assert.Equal("FW: toForward", email.Subject);

            resetEmail(_engine, email);
        }
        public void SendServerEmailWithNoAttachments()
        {
            _engine          = new AutomationEngineInstance(null);
            _sendServerEmail = new SendServerEmailCommand();

            string projectDirectory = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;
            string filePath         = Path.Combine(projectDirectory, @"Resources\");
            string subject          = "No Attachments";
            string email            = filePath + @"Download\" + $"{subject}.msg";

            _sendServerEmail.v_AccountName   = "NicolePersonalTest";
            _sendServerEmail.v_ToRecipients  = "*****@*****.**";
            _sendServerEmail.v_CCRecipients  = "";
            _sendServerEmail.v_BCCRecipients = "";
            _sendServerEmail.v_Subject       = subject;
            _sendServerEmail.v_Body          = "Test Body";
            _sendServerEmail.v_Attachments   = "";

            _sendServerEmail.RunCommand(_engine);

            var emailMessage = GetEmail(filePath, subject);

            Assert.True(File.Exists(email));

            DeleteEmail(emailMessage);
            File.Delete(email);
        }
        public async void GetsDataTableListItem()
        {
            _engine      = new AutomationEngineInstance(null);
            _getListItem = new GetListItemCommand();

            List <OBDataTable> list  = new List <OBDataTable>();
            OBDataTable        item1 = new OBDataTable();

            item1.Columns.Add("d1col");
            OBDataTable item2 = new OBDataTable();

            item2.Columns.Add("d2col");
            list.Add(item1);
            list.Add(item2);
            VariableMethods.CreateTestVariable(list, _engine, "inputList", typeof(List <>));
            VariableMethods.CreateTestVariable(null, _engine, "output", typeof(OBDataTable));

            _getListItem.v_ListName  = "{inputList}";
            _getListItem.v_ItemIndex = "1";
            _getListItem.v_OutputUserVariableName = "{output}";

            _getListItem.RunCommand(_engine);

            Assert.Equal(item2, (OBDataTable)await "{output}".EvaluateCode(_engine));
        }
        public void RenamesFile()
        {
            _engine     = new AutomationEngineInstance(null);
            _renameFile = new RenameFileCommand();

            string projectDirectory = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;
            string inputPath        = Path.Combine(projectDirectory, @"Resources\toRename.txt");

            VariableMethods.CreateTestVariable(inputPath, _engine, "inputPath", typeof(string));

            string newName = "newname.txt";

            VariableMethods.CreateTestVariable(newName, _engine, "newName", typeof(string));

            _renameFile.v_SourceFilePath = "{inputPath}";
            _renameFile.v_NewName        = "{newName}";

            _renameFile.RunCommand(_engine);

            string newFile = Path.Combine(projectDirectory, @"Resources\" + newName);

            Assert.True(IO.File.Exists(newFile));

            resetTestFilename(newFile);
        }
Exemple #12
0
        public async void ExtractsAllBeforeText()
        {
            _engine         = new AutomationEngineInstance(null);
            _textExtraction = new TextExtractionCommand();

            string input = "This is an example sentence";

            OBData.DataTable extractParams = new OBData.DataTable();
            extractParams.Columns.Add("Parameter Name");
            extractParams.Columns.Add("Parameter Value");
            DataRow row1 = extractParams.NewRow();

            row1["Parameter Name"]  = "Trailing Text";
            row1["Parameter Value"] = "{trailingText}";
            extractParams.Rows.Add(row1);
            DataRow row2 = extractParams.NewRow();

            row2["Parameter Name"]  = "Skip Past Occurences";
            row2["Parameter Value"] = "0";
            extractParams.Rows.Add(row2);

            VariableMethods.CreateTestVariable(" an example sentence", _engine, "trailingText", typeof(string));
            VariableMethods.CreateTestVariable(input, _engine, "input", typeof(string));
            VariableMethods.CreateTestVariable(null, _engine, "output", typeof(string));

            _textExtraction.v_InputText              = "{input}";
            _textExtraction.v_TextExtractionType     = "Extract All Before Text";
            _textExtraction.v_TextExtractionTable    = extractParams;
            _textExtraction.v_OutputUserVariableName = "{output}";

            _textExtraction.RunCommand(_engine);

            Assert.Equal("This is", (string)await "{output}".EvaluateCode(_engine));
        }
        public void GetsOutlookEmailProperty(string prop, string propValue)
        {
            _engine                  = new AutomationEngineInstance(null);
            _getOutlookEmails        = new GetOutlookEmailsCommand();
            _getOutlookEmailProperty = new GetOutlookEmailPropertyCommand();

            VariableMethods.CreateTestVariable(null, _engine, "emails", typeof(List <>));

            _getOutlookEmails.v_SourceFolder  = "TestInput";
            _getOutlookEmails.v_Filter        = "[Subject] = 'subjectProp'";
            _getOutlookEmails.v_GetUnreadOnly = "No";
            _getOutlookEmails.v_MarkAsRead    = "No";
            _getOutlookEmails.v_SaveMessagesAndAttachments = "No";
            _getOutlookEmails.v_MessageDirectory           = "";
            _getOutlookEmails.v_AttachmentDirectory        = "";
            _getOutlookEmails.v_OutputUserVariableName     = "{emails}";

            _getOutlookEmails.RunCommand(_engine);

            var      emails = (List <MailItem>) "{emails}".ConvertUserVariableToObject(_engine, typeof(List <>));
            MailItem email  = emails[0];

            VariableMethods.CreateTestVariable(email, _engine, "email", typeof(MailItem));
            VariableMethods.CreateTestVariable(null, _engine, "property", typeof(string));

            _getOutlookEmailProperty.v_MailItem = "{email}";
            _getOutlookEmailProperty.v_Property = prop;
            _getOutlookEmailProperty.v_OutputUserVariableName = "{property}";

            _getOutlookEmailProperty.RunCommand(_engine);

            Assert.Equal(propValue, "{property}".ConvertUserVariableToString(_engine));
        }
Exemple #14
0
        private async void resetCopyEmail(AutomationEngineInstance _engine)
        {
            _deleteOutlookEmail = new DeleteOutlookEmailCommand();
            _getOutlookEmails   = new GetOutlookEmailsCommand();

            VariableMethods.CreateTestVariable(null, _engine, "emails", typeof(List <>));

            _getOutlookEmails.v_SourceFolder  = "MovedMail";
            _getOutlookEmails.v_Filter        = "[Subject] = 'toCopy'";
            _getOutlookEmails.v_GetUnreadOnly = "No";
            _getOutlookEmails.v_MarkAsRead    = "No";
            _getOutlookEmails.v_SaveMessagesAndAttachments = "No";
            _getOutlookEmails.v_MessageDirectory           = "";
            _getOutlookEmails.v_AttachmentDirectory        = "";
            _getOutlookEmails.v_OutputUserVariableName     = "{emails}";

            _getOutlookEmails.RunCommand(_engine);

            var      emails = (List <MailItem>)await "{emails}".EvaluateCode(_engine);
            MailItem email  = emails[0];

            VariableMethods.CreateTestVariable(email, _engine, "email", typeof(MailItem));

            _deleteOutlookEmail.v_MailItem       = "{email}";
            _deleteOutlookEmail.v_DeleteReadOnly = "No";

            _deleteOutlookEmail.RunCommand(_engine);
        }
Exemple #15
0
        public void removesDataRow(string search, string andOr, int expectedIndex, string expectedName)
        {
            _removeDataRow = new RemoveDataRowCommand();
            _engine        = new AutomationEngineInstance(null);

            OBData.DataTable inputTable = new OBData.DataTable();
            inputTable.Columns.Add("firstname");
            inputTable.Columns.Add("lastname");
            DataRow row1 = inputTable.NewRow();

            row1["firstname"] = "john";
            row1["lastname"]  = "smith";
            inputTable.Rows.Add(row1);
            DataRow row2 = inputTable.NewRow();

            row2["firstname"] = "jane";
            row2["lastname"]  = "smith";
            inputTable.Rows.Add(row2);
            DataRow row3 = inputTable.NewRow();

            row3["firstname"] = "jane";
            row3["lastname"]  = "doe";
            inputTable.Rows.Add(row3);

            VariableMethods.CreateTestVariable(inputTable, _engine, "inputTable", typeof(OBData.DataTable));

            _removeDataRow.v_DataTable  = "{inputTable}";
            _removeDataRow.v_SearchItem = search;
            _removeDataRow.v_AndOr      = andOr;

            _removeDataRow.RunCommand(_engine);

            OBData.DataTable outputTable = (OBData.DataTable)_removeDataRow.v_DataTable.ConvertUserVariableToObject(_engine, typeof(OBData.DataTable));
            Assert.True(outputTable.Rows[expectedIndex][0].Equals(expectedName));
        }
Exemple #16
0
        public async void AddsDataRow()
        {
            _addDataRow = new AddDataRowCommand();
            _engine     = new AutomationEngineInstance(null);

            OBData.DataTable inputTable = new OBData.DataTable();
            inputTable.Columns.Add("firstname");
            inputTable.Columns.Add("lastname");
            DataRow inputrow = inputTable.NewRow();

            inputrow["firstname"] = "john";
            inputrow["lastname"]  = "smith";
            VariableMethods.CreateTestVariable(inputTable, _engine, "inputTable", typeof(OBData.DataTable));
            _addDataRow.v_DataTable = "{inputTable}";
            OBData.DataRow newrow = _addDataRow.v_DataRowDataTable.NewRow();
            newrow["Column Name"] = "firstname";
            newrow["Data"]        = "john";
            OBData.DataRow newrow2 = _addDataRow.v_DataRowDataTable.NewRow();
            newrow2["Column Name"] = "lastname";
            newrow2["Data"]        = "smith";

            _addDataRow.v_DataRowDataTable.Rows.Add(newrow);
            _addDataRow.v_DataRowDataTable.Rows.Add(newrow2);

            _addDataRow.RunCommand(_engine);

            OBData.DataTable outputTable = (OBData.DataTable) await _addDataRow.v_DataTable.EvaluateCode(_engine);

            Assert.Equal(inputTable.Rows[0]["firstname"], outputTable.Rows[0]["firstname"]);
            Assert.Equal(inputTable.Rows[0]["lastname"], outputTable.Rows[0]["lastname"]);
        }
        public void AddsDictionaryItem()
        {
            _addDictionaryItem = new AddDictionaryItemCommand();
            _engine            = new AutomationEngineInstance(null);

            Dictionary <string, string> inputDict = new Dictionary <string, string>();

            VariableMethods.CreateTestVariable(inputDict, _engine, "inputDict", typeof(Dictionary <,>));

            OBData.DataTable inputTable = new OBData.DataTable();
            inputTable.Columns.Add("Keys");
            inputTable.Columns.Add("Values");
            DataRow row1 = inputTable.NewRow();

            row1["Keys"]   = "key1";
            row1["Values"] = "val1";
            inputTable.Rows.Add(row1);
            VariableMethods.CreateTestVariable(inputTable, _engine, "inputTable", typeof(OBData.DataTable));

            _addDictionaryItem.v_DictionaryName      = "{inputDict}";
            _addDictionaryItem.v_ColumnNameDataTable = (OBData.DataTable) "{inputTable}".ConvertUserVariableToObject(_engine, typeof(OBData.DataTable));

            _addDictionaryItem.RunCommand(_engine);

            Assert.Equal("val1", inputDict["key1"]);
        }
        public void UpdatesStringListItem()
        {
            _engine         = new AutomationEngineInstance(null);
            _updateListItem = new UpdateListItemCommand();

            List <string> inputList = new List <string>();

            inputList.Add("item1");
            inputList.Add("item2");
            string index = "0";
            string item  = "item3";

            VariableMethods.CreateTestVariable(inputList, _engine, "inputList", typeof(List <>));
            VariableMethods.CreateTestVariable(index, _engine, "index", typeof(string));
            VariableMethods.CreateTestVariable(item, _engine, "item", typeof(string));

            _updateListItem.v_ListName  = "{inputList}";
            _updateListItem.v_ListIndex = "{index}";
            _updateListItem.v_ListItem  = "{item}";

            _updateListItem.RunCommand(_engine);

            List <string> outputList = (List <string>) "{inputList}".ConvertUserVariableToObject(_engine, typeof(List <>));

            Assert.Equal("item3", outputList[0]);
        }
Exemple #19
0
        public async void SetFailedFatallyStatus()
        {
            _engine       = new AutomationEngineInstance(null);
            _setQueueItem = new SetQueueItemStatusCommand();

            string name = "FailedQueueItem";

            AddQueueItem(name);
            var queueItemDict = await WorkQueueItem();

            var transactionKey = queueItemDict["LockTransactionKey"].ToString();
            var userInfo       = ServerSessionVariableMethods.GetUserInfo(_engine);
            var queueItem      = QueueItemMethods.GetQueueItemByLockTransactionKey(userInfo, transactionKey.ToString());

            VariableMethods.CreateTestVariable(null, _engine, "vQueueItem", typeof(Dictionary <,>));
            _setQueueItem.v_QueueItem = "{vQueueItem}";
            queueItemDict.SetVariableValue(_engine, _setQueueItem.v_QueueItem);
            _setQueueItem.v_QueueItemStatusType = "Failed - Fatal";

            _setQueueItem.RunCommand(_engine);

            queueItem = QueueItemMethods.GetQueueItemById(userInfo, queueItem.Id);

            Assert.Equal("Failed", queueItem.State);
        }
        public void UpdatesDataTableListItem()
        {
            _engine         = new AutomationEngineInstance(null);
            _updateListItem = new UpdateListItemCommand();

            List <OBDataTable> inputList = new List <OBDataTable>();
            OBDataTable        item1     = new OBDataTable();

            item1.Columns.Add("d1col");
            OBDataTable item2 = new OBDataTable();

            item2.Columns.Add("d2col");
            inputList.Add(item1);
            inputList.Add(item2);
            string      index   = "0";
            OBDataTable newitem = new OBDataTable();

            newitem.Columns.Add("d3col");

            VariableMethods.CreateTestVariable(inputList, _engine, "inputList", typeof(List <>));
            VariableMethods.CreateTestVariable(index, _engine, "index", typeof(string));
            VariableMethods.CreateTestVariable(newitem, _engine, "newitem", typeof(OBDataTable));

            _updateListItem.v_ListName  = "{inputList}";
            _updateListItem.v_ListIndex = "{index}";
            _updateListItem.v_ListItem  = "{newitem}";

            _updateListItem.RunCommand(_engine);

            List <OBDataTable> outputList = (List <OBDataTable>) "{inputList}".ConvertUserVariableToObject(_engine, typeof(List <>));

            Assert.Equal(newitem, outputList[0]);
        }
        public void CreatesDictionary()
        {
            _createDictionary = new CreateDictionaryCommand();
            _engine           = new AutomationEngineInstance(null);
            OBData.DataTable inputDt = new OBData.DataTable();
            inputDt.Columns.Add("Keys");
            inputDt.Columns.Add("Values");
            DataRow row1 = inputDt.NewRow();

            row1["Keys"]   = "key1";
            row1["Values"] = "val1";
            inputDt.Rows.Add(row1);
            VariableMethods.CreateTestVariable(inputDt, _engine, "inputDt", typeof(OBData.DataTable));
            VariableMethods.CreateTestVariable(null, _engine, "output", typeof(Dictionary <,>));

            _createDictionary.v_ColumnNameDataTable    = (OBData.DataTable) "{inputDt}".ConvertUserVariableToObject(_engine, typeof(OBData.DataTable));
            _createDictionary.v_OutputUserVariableName = "{output}";

            _createDictionary.RunCommand(_engine);

            Dictionary <string, string> outDict = (Dictionary <string, string>) "{output}".ConvertUserVariableToObject(_engine, typeof(Dictionary <,>));

            Assert.True(outDict.ContainsKey("key1"));
            Assert.Equal("val1", outDict["key1"]);
        }
Exemple #22
0
        public async void UpdatesNumberAsset()
        {
            _engine      = new AutomationEngineInstance(null);
            _updateAsset = new UpdateAssetCommand();
            _getAsset    = new GetAssetCommand();

            string assetName = "testNumberAsset";
            string newAsset  = "70";

            VariableMethods.CreateTestVariable(assetName, _engine, "assetName", typeof(string));
            VariableMethods.CreateTestVariable(newAsset, _engine, "newAsset", typeof(string));
            VariableMethods.CreateTestVariable(null, _engine, "output", typeof(string));

            _updateAsset.v_AssetName     = "{assetName}";
            _updateAsset.v_AssetType     = "Number";
            _updateAsset.v_AssetFilePath = "";
            _updateAsset.v_AssetValue    = "{newAsset}";

            _updateAsset.RunCommand(_engine);

            _getAsset.v_AssetName = "{assetName}";
            _getAsset.v_AssetType = "Number";
            _getAsset.v_OutputUserVariableName = "{output}";

            _getAsset.RunCommand(_engine);

            string outputAsset = (string)await "{output}".EvaluateCode(_engine);

            Assert.Equal("70", outputAsset);

            resetAsset(assetName, "42", "Number");
        }
Exemple #23
0
        public async void ParsesJSONModel()
        {
            _parseJSONModel = new ParseJSONModelCommand();
            _engine         = new AutomationEngineInstance(null);

            string jsonObject = "{\"rect\":{\"length\":10, \"width\":5}}";

            VariableMethods.CreateTestVariable(jsonObject, _engine, "input", typeof(string));
            string selector = "rect.length";

            VariableMethods.CreateTestVariable(selector, _engine, "selector", typeof(string));
            VariableMethods.CreateTestVariable(null, _engine, "r1output", typeof(List <>));

            OBDataTable selectorTable = new OBDataTable();

            selectorTable.Columns.Add("Json Selector");
            selectorTable.Columns.Add("Output Variable");
            DataRow row1 = selectorTable.NewRow();

            row1["Json Selector"]   = "{selector}";
            row1["Output Variable"] = "{r1output}";
            selectorTable.Rows.Add(row1);

            _parseJSONModel.v_JsonObject   = "{input}";
            _parseJSONModel.v_ParseObjects = selectorTable;

            _parseJSONModel.RunCommand(_engine);
            List <string> resultList = (List <string>)await "{r1output}".EvaluateCode(_engine);

            Assert.Equal("10", resultList[0]);
        }
Exemple #24
0
        public async void UpdatesJsonAsset()
        {
            _engine      = new AutomationEngineInstance(null);
            _updateAsset = new UpdateAssetCommand();
            _getAsset    = new GetAssetCommand();

            string assetName = "testJsonAsset";
            string newAsset  = "{ \"text\": \"newText\" }";

            VariableMethods.CreateTestVariable(assetName, _engine, "assetName", typeof(string));
            VariableMethods.CreateTestVariable(newAsset, _engine, "newAsset", typeof(string));
            VariableMethods.CreateTestVariable(null, _engine, "output", typeof(string));

            _updateAsset.v_AssetName     = "{assetName}";
            _updateAsset.v_AssetType     = "Json";
            _updateAsset.v_AssetFilePath = "";
            _updateAsset.v_AssetValue    = "{newAsset}";

            _updateAsset.RunCommand(_engine);

            _getAsset.v_AssetName = "{assetName}";
            _getAsset.v_AssetType = "Json";
            _getAsset.v_OutputUserVariableName = "{output}";

            _getAsset.RunCommand(_engine);

            JObject outputAsset = (JObject)await "{output}".EvaluateCode(_engine);

            Assert.Equal("newText", outputAsset["text"]);

            resetAsset(assetName, "{ \"text\": \"testText\" }", "Json");
        }
        public async void getsDataRowValue(string option)
        {
            _getDataRowValue = new GetDataRowValueCommand();
            _engine          = new AutomationEngineInstance(null);

            OBData.DataTable inputTable = new OBData.DataTable();
            inputTable.Columns.Add("col1");
            DataRow row = inputTable.NewRow();

            row["col1"] = "data11";
            inputTable.Rows.Add(row);

            VariableMethods.CreateTestVariable(row, _engine, "inputRow", typeof(DataRow));
            VariableMethods.CreateTestVariable(null, _engine, "outputValue", typeof(string));

            _getDataRowValue.v_DataRow = "{inputRow}";
            _getDataRowValue.v_Option  = option;
            if (option == "Column Name")
            {
                _getDataRowValue.v_DataValueIndex = "col1";
            }
            else
            {
                _getDataRowValue.v_DataValueIndex = "0";
            }
            _getDataRowValue.v_OutputUserVariableName = "{outputValue}";

            _getDataRowValue.RunCommand(_engine);

            string outputValue = (string)await _getDataRowValue.v_OutputUserVariableName.EvaluateCode(_engine);

            Assert.Equal(inputTable.Rows[0]["col1"], outputValue);
        }
        public void AddsNumberAsset()
        {
            _engine         = new AutomationEngineInstance(null);
            _calculateAsset = new CalculateNumberAssetCommand();
            _getAsset       = new GetAssetCommand();

            string assetName = "testIncrementNumberAsset";
            string newAsset  = "54";

            VariableMethods.CreateTestVariable(assetName, _engine, "assetName", typeof(string));
            VariableMethods.CreateTestVariable(newAsset, _engine, "newAsset", typeof(string));
            VariableMethods.CreateTestVariable(null, _engine, "output", typeof(string));

            _calculateAsset.v_AssetName        = "{assetName}";
            _calculateAsset.v_AssetActionType  = "Add";
            _calculateAsset.v_AssetActionValue = "5";

            _calculateAsset.RunCommand(_engine);

            _getAsset.v_AssetName = "{assetName}";
            _getAsset.v_AssetType = "Number";
            _getAsset.v_OutputUserVariableName = "{output}";

            _getAsset.RunCommand(_engine);

            string outputAsset = "{output}".ConvertUserVariableToString(_engine);

            Assert.Equal(newAsset, outputAsset);

            resetAsset(assetName, "49", "Number");
        }
Exemple #27
0
        public void GetsFiles()
        {
            _engine   = new AutomationEngineInstance(null);
            _getFiles = new GetFilesCommand();

            string projectDirectory = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;
            string inputPath        = Path.Combine(projectDirectory, @"Resources");

            VariableMethods.CreateTestVariable(inputPath, _engine, "inputPath", typeof(string));
            VariableMethods.CreateTestVariable(null, _engine, "output", typeof(List <>));

            _getFiles.v_SourceFolderPath       = "{inputPath}";
            _getFiles.v_OutputUserVariableName = "{output}";

            _getFiles.RunCommand(_engine);

            List <string> fileList = (List <string>) "{output}".ConvertUserVariableToObject(_engine, typeof(List <>));

            List <string> filenames = new List <string>();

            foreach (string file in fileList)
            {
                output.WriteLine(file);
                string[] splitPath = file.Split('\\');
                string   filename  = splitPath[splitPath.Length - 1];
                filenames.Add(filename);
            }

            Assert.Contains("compressed.zip", filenames);
            Assert.Contains("toCompress.txt", filenames);
        }
Exemple #28
0
        public void ExtractsFiles()
        {
            _engine       = new AutomationEngineInstance(null);
            _extractFiles = new ExtractFilesCommand();

            string projectDirectory = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;
            string inputPath        = Path.Combine(projectDirectory, @"Resources\compressed.zip");

            VariableMethods.CreateTestVariable(inputPath, _engine, "inputPath", typeof(string));

            string outputPath = Environment.CurrentDirectory;

            VariableMethods.CreateTestVariable(outputPath, _engine, "outputPath", typeof(string));
            VariableMethods.CreateTestVariable(null, _engine, "output", typeof(List <>));

            _extractFiles.v_FilePathOrigin         = "{inputPath}";
            _extractFiles.v_PathDestination        = "{outputPath}";
            _extractFiles.v_OutputUserVariableName = "{output}";

            _extractFiles.RunCommand(_engine);

            Assert.True(IO.File.Exists(Path.Combine(outputPath, @"compressed\compressed.txt")));
            Assert.True(Directory.Exists(Path.Combine(outputPath, @"compressed\emptyFolder")));
            Assert.True(IO.File.Exists(Path.Combine(outputPath, @"compressed\subfolder\subfolder2\deepfile.txt")));

            IO.File.Delete(Path.Combine(outputPath, @"compressed\compressed.txt"));
            Directory.Delete(Path.Combine(outputPath, @"compressed\emptyFolder"));
            IO.File.Delete(Path.Combine(outputPath, @"compressed\subfolder\subfolder2\deepfile.txt"));
            Directory.Delete(Path.Combine(outputPath, @"compressed\subfolder\subfolder2"));
            Directory.Delete(Path.Combine(outputPath, @"compressed\subfolder"));
            Directory.Delete(Path.Combine(outputPath, @"compressed"));
        }
Exemple #29
0
        public void WorkQueueItemNoAttachments()
        {
            _engine        = new AutomationEngineInstance(null);
            _addQueueItem  = new AddQueueItemCommand();
            _workQueueItem = new WorkQueueItemCommand();
            VariableMethods.CreateTestVariable(null, _engine, "output", typeof(Dictionary <,>));

            _addQueueItem.v_QueueName          = "UnitTestQueue";
            _addQueueItem.v_QueueItemName      = "WorkQueueItemNoAttachmentTest";
            _addQueueItem.v_QueueItemType      = "Text";
            _addQueueItem.v_JsonType           = "Test Type";
            _addQueueItem.v_QueueItemTextValue = "Test Text";
            _addQueueItem.v_Priority           = "10";

            _addQueueItem.RunCommand(_engine);

            _workQueueItem.v_QueueName = "UnitTestQueue";
            _workQueueItem.v_OutputUserVariableName = "{output}";
            _workQueueItem.v_SaveAttachments        = "No";
            _workQueueItem.v_AttachmentDirectory    = "";

            _workQueueItem.RunCommand(_engine);

            var queueItemObject = (Dictionary <string, object>) "{output}".ConvertUserVariableToObject(_engine, typeof(Dictionary <,>));
            var client          = AuthMethods.GetAuthToken();
            var queueItem       = QueueItemMethods.GetQueueItemByLockTransactionKey(client, queueItemObject["LockTransactionKey"].ToString());

            Assert.Equal("InProgress", queueItem.State);
        }
        public void CorrectlyPerformsOperation(DateTime input, string calcMethod, string increment, dynamic expectedResult)
        {
            _dateCalculation = new DateCalculationCommand();
            _engine          = new AutomationEngineInstance(null);
            string defaultFormat = "MM/dd/yyyy hh:mm:ss";

            if (calcMethod.Contains("Get"))
            {
                defaultFormat = null;
            }
            VariableMethods.CreateTestVariable(defaultFormat, _engine, "format", typeof(string));
            VariableMethods.CreateTestVariable(increment, _engine, "increment", typeof(string));
            VariableMethods.CreateTestVariable(input, _engine, "inputDate", typeof(string));
            VariableMethods.CreateTestVariable(null, _engine, "output", typeof(string));

            _dateCalculation.v_InputDate              = "{inputDate}";
            _dateCalculation.v_CalculationMethod      = calcMethod;
            _dateCalculation.v_Increment              = "{increment}";
            _dateCalculation.v_ToStringFormat         = defaultFormat != null ? "{format}":null;
            _dateCalculation.v_OutputUserVariableName = "{output}";

            _dateCalculation.RunCommand(_engine);
            if (expectedResult.GetType() == typeof(DateTime))
            {
                Assert.Equal(expectedResult.ToString(defaultFormat), _dateCalculation.v_OutputUserVariableName.ConvertUserVariableToString(_engine));
            }
            else if (expectedResult.GetType() == typeof(int))
            {
                Assert.Equal(expectedResult, Int32.Parse(_dateCalculation.v_OutputUserVariableName.ConvertUserVariableToString(_engine)));
            }
        }