Exemple #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);
        }
Exemple #2
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);
        }
Exemple #3
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);
        }
Exemple #4
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);
        }
Exemple #5
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);
        }