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"); }
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"); }
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 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.Parse("{output}".ConvertUserVariableToString(_engine)); Assert.Equal("newText", outputAsset["text"]); resetAsset(assetName, "{ \"text\": \"testText\" }", "JSON"); }
public async void DecrementsNumberAsset() { _engine = new AutomationEngineInstance(null); _calculateAsset = new CalculateNumberAssetCommand(); _getAsset = new GetAssetCommand(); string assetName = "testIncrementNumberAsset"; string newAsset = "48"; 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 = "Decrement"; _calculateAsset.v_AssetActionValue = ""; _calculateAsset.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(newAsset, outputAsset); resetAsset(assetName, "49", "Number"); }
public void AppendsTextAsset() { _engine = new AutomationEngineInstance(null); _appendTextAsset = new AppendTextAssetCommand(); _getAsset = new GetAssetCommand(); string assetName = "testUpdateTextAsset"; string toAppend = "textToAppend"; VariableMethods.CreateTestVariable(assetName, _engine, "assetName", typeof(string)); VariableMethods.CreateTestVariable(toAppend, _engine, "toAppend", typeof(string)); VariableMethods.CreateTestVariable(null, _engine, "initialText", typeof(string)); VariableMethods.CreateTestVariable(null, _engine, "updatedAsset", typeof(string)); _getAsset.v_AssetName = assetName; _getAsset.v_AssetType = "Text"; _getAsset.v_OutputUserVariableName = "{initialText}"; _getAsset.RunCommand(_engine); _appendTextAsset.v_AssetName = "{assetName}"; _appendTextAsset.v_AppendText = "{toAppend}"; _appendTextAsset.RunCommand(_engine); _getAsset.v_AssetName = assetName; _getAsset.v_AssetType = "Text"; _getAsset.v_OutputUserVariableName = "{updatedAsset}"; _getAsset.RunCommand(_engine); string initialText = "{initialText}".ConvertUserVariableToString(_engine); string updatedAsset = "{updatedAsset}".ConvertUserVariableToString(_engine); resetAsset(assetName, initialText, "Text"); Assert.Equal(initialText + " " + toAppend, updatedAsset); }
public async System.Threading.Tasks.Task HandlesNonexistentAsset() { _engine = new AutomationEngineInstance(null); _getAsset = new GetAssetCommand(); VariableMethods.CreateTestVariable(null, _engine, "output", typeof(string)); _getAsset.v_AssetName = "noAsset"; _getAsset.v_AssetType = "Text"; _getAsset.v_OutputDirectoryPath = ""; _getAsset.v_OutputUserVariableName = "{output}"; Assert.ThrowsAsync <InvalidOperationException>(() => _getAsset.RunCommand(_engine)); }
public async void GetsTextAsset() { _engine = new AutomationEngineInstance(null); _getAsset = new GetAssetCommand(); VariableMethods.CreateTestVariable(null, _engine, "output", typeof(string)); _getAsset.v_AssetName = "testTextAsset"; _getAsset.v_AssetType = "Text"; _getAsset.v_OutputDirectoryPath = ""; _getAsset.v_OutputUserVariableName = "{output}"; _getAsset.RunCommand(_engine); Assert.Equal("testText", (string)await "{output}".EvaluateCode(_engine)); }
public void GetsNumberAsset() { _engine = new AutomationEngineInstance(null); _getAsset = new GetAssetCommand(); VariableMethods.CreateTestVariable(null, _engine, "output", typeof(string)); _getAsset.v_AssetName = "testNumberAsset"; _getAsset.v_AssetType = "Number"; _getAsset.v_OutputDirectoryPath = ""; _getAsset.v_OutputUserVariableName = "{output}"; _getAsset.RunCommand(_engine); var asset = "{output}".ConvertUserVariableToString(_engine); Assert.Equal("42", asset); }
public void GetsFileAsset() { _engine = new AutomationEngineInstance(null); _getAsset = new GetAssetCommand(); string projectDirectory = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName; string filepath = Path.Combine(projectDirectory, @"Resources\"); _getAsset.v_AssetName = "testFileAsset"; _getAsset.v_AssetType = "File"; _getAsset.v_OutputDirectoryPath = filepath; _getAsset.v_OutputUserVariableName = ""; _getAsset.RunCommand(_engine); Assert.True(File.Exists(filepath + "test.txt")); File.Delete(filepath + "test.txt"); }
public async void GetsJsonAsset() { _engine = new AutomationEngineInstance(null); _getAsset = new GetAssetCommand(); VariableMethods.CreateTestVariable(null, _engine, "output", typeof(string)); _getAsset.v_AssetName = "testJsonAsset"; _getAsset.v_AssetType = "Json"; _getAsset.v_OutputDirectoryPath = ""; _getAsset.v_OutputUserVariableName = "{output}"; _getAsset.RunCommand(_engine); string jsonString = (string)await "{output}".EvaluateCode(_engine); JObject jsonObject = JObject.Parse(jsonString); Assert.Equal("testText", jsonObject["text"]); }
public void UpdatesFileAsset() { _engine = new AutomationEngineInstance(null); _updateAsset = new UpdateAssetCommand(); _getAsset = new GetAssetCommand(); string projectDirectory = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName; string filepath = Path.Combine(projectDirectory, @"Resources\"); string assetName = "testUpdateFileAsset"; string newAsset = filepath + @"Upload\newtest.txt"; VariableMethods.CreateTestVariable(assetName, _engine, "assetName", typeof(string)); VariableMethods.CreateTestVariable(newAsset, _engine, "newAsset", typeof(string)); _updateAsset.v_AssetName = "{assetName}"; _updateAsset.v_AssetType = "File"; _updateAsset.v_AssetFilePath = "{newAsset}"; _updateAsset.RunCommand(_engine); _getAsset.v_AssetName = "{assetName}"; _getAsset.v_AssetType = "File"; _getAsset.v_OutputDirectoryPath = filepath + @"Download\"; if (!Directory.Exists(_getAsset.v_OutputDirectoryPath)) { Directory.CreateDirectory(_getAsset.v_OutputDirectoryPath); } _getAsset.RunCommand(_engine); Assert.True(File.Exists(filepath + @"Download\newtest.txt")); File.Delete(filepath + @"Download\newtest.txt"); resetAsset(assetName, filepath + @"Upload\oldtest.txt", "File"); }