Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
        public async void AddTextQueueItem()
        {
            _engine        = new AutomationEngineInstance(null);
            _addQueueItem  = new AddQueueItemCommand();
            _workQueueItem = new WorkQueueItemCommand();

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

            _addQueueItem.v_QueueName          = "UnitTestQueue";
            _addQueueItem.v_QueueItemName      = "QueueItemTextTest";
            _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 queueItem = (Dictionary <string, object>)await "{output}".EvaluateCode(_engine);

            Assert.Equal("Test Text", queueItem["DataJson"]);
        }
Ejemplo n.º 4
0
        public async Task <Dictionary <string, object> > WorkQueueItem()
        {
            _workQueueItem = new WorkQueueItemCommand();
            VariableMethods.CreateTestVariable(null, _engine, "output", typeof(Dictionary <,>));

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

            _workQueueItem.RunCommand(_engine);

            var queueItemDict = (Dictionary <string, object>)await "{output}".EvaluateCode(_engine);

            return(queueItemDict);
        }
Ejemplo n.º 5
0
        public void WorkQueueItemMultipleAttachments()
        {
            _engine        = new AutomationEngineInstance(null);
            _addQueueItem  = new AddQueueItemCommand();
            _workQueueItem = new WorkQueueItemCommand();

            string projectDirectory = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;
            string filePath         = Path.Combine(projectDirectory, @"Resources\");
            string fileName1        = "testFile.txt";
            string fileName2        = "testFile2.txt";
            string attachment1      = Path.Combine(filePath, @"Download\", fileName1);
            string attachment2      = Path.Combine(filePath, @"Download\", fileName2);

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

            _addQueueItem.v_QueueName          = "UnitTestQueue";
            _addQueueItem.v_QueueItemName      = "WorkQueueItemAttachmentsTest";
            _addQueueItem.v_QueueItemType      = "Text";
            _addQueueItem.v_JsonType           = "Test Type";
            _addQueueItem.v_QueueItemTextValue = "Test Text";
            _addQueueItem.v_Priority           = "10";
            _addQueueItem.v_Attachments        = filePath + @"Upload\" + fileName1
                                                 + ";" + filePath + @"Upload\" + fileName2;

            _addQueueItem.RunCommand(_engine);

            _workQueueItem.v_QueueName = "UnitTestQueue";
            _workQueueItem.v_OutputUserVariableName = "{output}";
            _workQueueItem.v_SaveAttachments        = "Yes";
            _workQueueItem.v_AttachmentDirectory    = filePath + @"Download\";

            _workQueueItem.RunCommand(_engine);

            var    queueItemObject = "{output}".ConvertUserVariableToObject(_engine, typeof(Dictionary <,>));
            string queueItemString = JsonConvert.SerializeObject(queueItemObject);
            var    vQueueItem      = JsonConvert.DeserializeObject <QueueItemModel>(queueItemString);

            var client    = AuthMethods.GetAuthToken();
            var queueItem = QueueItemMethods.GetQueueItemByLockTransactionKey(client, vQueueItem.LockTransactionKey.ToString());

            Assert.Equal("InProgress", queueItem.State);
            Assert.True(File.Exists(attachment1));
            Assert.True(File.Exists(attachment2));

            File.Delete(attachment1);
            File.Delete(attachment2);
        }
Ejemplo n.º 6
0
        public async void AddQueueItemMultipleAttachments()
        {
            _engine        = new AutomationEngineInstance(null);
            _addQueueItem  = new AddQueueItemCommand();
            _workQueueItem = new WorkQueueItemCommand();

            string projectDirectory = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;
            string filePath         = Path.Combine(projectDirectory, @"Resources\");
            string fileName1        = "testFile.txt";
            string fileName2        = "testFile2.txt";
            string attachment1      = Path.Combine(filePath, @"Download\", fileName1);
            string attachment2      = Path.Combine(filePath, @"Download\", fileName2);

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

            _addQueueItem.v_QueueName          = "UnitTestQueue";
            _addQueueItem.v_QueueItemName      = "QueueItemAttachmentsTest";
            _addQueueItem.v_QueueItemType      = "Text";
            _addQueueItem.v_JsonType           = "Test Type";
            _addQueueItem.v_QueueItemTextValue = "Test Text";
            _addQueueItem.v_Priority           = "10";
            _addQueueItem.v_Attachments        = filePath + @"Upload\" + fileName1
                                                 + ";" + filePath + @"Upload\" + fileName2;

            _addQueueItem.RunCommand(_engine);

            _workQueueItem.v_QueueName = "UnitTestQueue";
            _workQueueItem.v_OutputUserVariableName = "{output}";
            _workQueueItem.v_SaveAttachments        = "Yes";
            _workQueueItem.v_AttachmentDirectory    = filePath + @"Download\";

            _workQueueItem.RunCommand(_engine);

            var queueItem = (Dictionary <string, object>)await "{output}".EvaluateCode(_engine);

            Assert.Equal("Test Text", queueItem["DataJson"]);
            Assert.True(File.Exists(attachment1));
            Assert.True(File.Exists(attachment2));

            File.Delete(attachment1);
            File.Delete(attachment2);
        }
Ejemplo n.º 7
0
        public async void ExtendQueueItem()
        {
            _engine          = new AutomationEngineInstance(null);
            _addQueueItem    = new AddQueueItemCommand();
            _workQueueItem   = new WorkQueueItemCommand();
            _extendQueueItem = new ExtendQueueItemCommand();

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

            _addQueueItem.v_QueueName          = "UnitTestQueue";
            _addQueueItem.v_QueueItemName      = "ExtendQueueItemTest";
            _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 queueItemDict  = (Dictionary <string, object>)await "{output}".EvaluateCode(_engine);
            var transactionKey = queueItemDict["LockTransactionKey"].ToString();

            var userInfo  = ServerSessionVariableMethods.GetUserInfo(_engine);
            var queueItem = QueueItemMethods.GetQueueItemByLockTransactionKey(userInfo, transactionKey.ToString());

            _extendQueueItem.v_QueueItem = "{vQueueItem}";
            queueItemDict.SetVariableValue(_engine, _extendQueueItem.v_QueueItem);

            _extendQueueItem.RunCommand(_engine);

            var extendedQueueItem = QueueItemMethods.GetQueueItemByLockTransactionKey(userInfo, transactionKey.ToString());

            Assert.True(queueItem.LockedUntilUTC < extendedQueueItem.LockedUntilUTC);
        }
        public void ExtendQueueItem()
        {
            _engine          = new AutomationEngineInstance(null);
            _addQueueItem    = new AddQueueItemCommand();
            _workQueueItem   = new WorkQueueItemCommand();
            _extendQueueItem = new ExtendQueueItemCommand();

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

            _addQueueItem.v_QueueName          = "UnitTestQueue";
            _addQueueItem.v_QueueItemName      = "ExtendQueueItemTest";
            _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 queueItemDict  = (Dictionary <string, object>) "{output}".ConvertUserVariableToObject(_engine, typeof(Dictionary <,>));
            var transactionKey = queueItemDict["LockTransactionKey"].ToString();
            var client         = AuthMethods.GetAuthToken();
            var queueItem      = QueueItemMethods.GetQueueItemByLockTransactionKey(client, transactionKey);

            _extendQueueItem.v_QueueItem = "{vQueueItem}";
            queueItemDict.StoreInUserVariable(_engine, _extendQueueItem.v_QueueItem, typeof(Dictionary <,>));

            _extendQueueItem.RunCommand(_engine);

            var extendedQueueItem = QueueItemMethods.GetQueueItemByLockTransactionKey(client, transactionKey);

            Assert.True(queueItem.LockedUntilUTC < extendedQueueItem.LockedUntilUTC);
        }
Ejemplo n.º 9
0
        public void HandlesNonExistentQueue()
        {
            _engine        = new AutomationEngineInstance(null);
            _addQueueItem  = new AddQueueItemCommand();
            _workQueueItem = new WorkQueueItemCommand();
            VariableMethods.CreateTestVariable(null, _engine, "output", typeof(Dictionary <,>));

            _addQueueItem.v_QueueName          = "UnitTestQueue";
            _addQueueItem.v_QueueItemName      = "WorkQueueItemJsonTest";
            _addQueueItem.v_QueueItemType      = "Json";
            _addQueueItem.v_JsonType           = "Test Type";
            _addQueueItem.v_QueueItemTextValue = "{'text':'testText'}";
            _addQueueItem.v_Priority           = "10";

            _addQueueItem.RunCommand(_engine);

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

            Assert.Throws <DataException>(() => _workQueueItem.RunCommand(_engine));
        }