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 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 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 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)); }
private void GenerateView() { picIdList.Clear(); assetIdList.Clear(); //List<Recommend> recommends = LogicController.GetRecommends(); List <Recommend> recommends = GetTestData(); for (int i = 0; i < recommends.Count; ++i) { RecommendItemView itemView = RecommendItemView.Create(table); itemView.RecommendId = recommends[i].recommendId; itemView.PictureId = recommends[i].pictureId; PositionSerialize(recommends[i].position, out itemView.x, out itemView.y, out itemView.width, out itemView.height); UIEventListener.Get(itemView.gameObject).onClick = ItemClick; itemViewList.Add(itemView); Picture picture = LogicController.GetPicture(recommends[i].pictureId); if (picture == null) { picIdList.Add(recommends[i].pictureId); } else { Asset asset = LogicController.GetAsset(picture.assetId); if (asset == null) { assetIdList.Add(picture.assetId); } } } tableComp.Reposition(); if (picIdList.Count != 0) { GetPictureCommand cmd = new GetPictureCommand(); cmd.Callback = AfterGetPicture; cmd.PictureIds = picIdList; cmd.execute(); } if (assetIdList.Count != 0) { GetAssetCommand cmd = new GetAssetCommand(); cmd.Callback = AfterGetAsset; cmd.AssetIds = assetIdList; cmd.execute(); } picIdList.Clear(); assetIdList.Clear(); }
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 HandlesNonexistentAsset() { _engine = new AutomationEngineInstance(null); _calculateAsset = new CalculateNumberAssetCommand(); _getAsset = new GetAssetCommand(); string assetName = "noAsset"; string newAsset = "50"; VariableMethods.CreateTestVariable(assetName, _engine, "{assetName}", typeof(string)); VariableMethods.CreateTestVariable(newAsset, _engine, "{assetName}", typeof(string)); _calculateAsset.v_AssetName = "{assetName}"; _calculateAsset.v_AssetActionType = "Increment"; _calculateAsset.v_AssetActionValue = ""; Assert.Throws <DataException>(() => _calculateAsset.RunCommand(_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 async System.Threading.Tasks.Task HandlesNonexistentAsset() { _engine = new AutomationEngineInstance(null); _updateAsset = new UpdateAssetCommand(); _getAsset = new GetAssetCommand(); string assetName = "noAsset"; string newAsset = "newText"; VariableMethods.CreateTestVariable(assetName, _engine, "{assetName}", typeof(string)); VariableMethods.CreateTestVariable(newAsset, _engine, "{newAsset}", typeof(string)); _updateAsset.v_AssetName = "{assetName}"; _updateAsset.v_AssetType = "Text"; _updateAsset.v_AssetFilePath = ""; _updateAsset.v_AssetValue = "{newAsset}"; Assert.ThrowsAsync <ArgumentNullException>(() => _updateAsset.RunCommand(_engine)); }
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 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 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"); }