public void DeleteFileByWildCardTest() { var step = new CreateStep(); step.CreationPath = @"..\..\TestData\DeleteTest_FileToBeDeleted1.wildCardTestxml"; var dl = new FileDataLoader(); dl.FilePath = @"..\..\TestData\PurchaseOrder001.xml"; step.DataSource = dl; step.Execute(new Context()); step.CreationPath = @"..\..\TestData\DeleteTest_FileToBeDeleted2.wildCardTestxml"; step.Execute(new Context()); var deleteStep = new DeleteStep(); deleteStep.FilePathsToDelete.Add(@"..\..\TestData\*.wildCardTestxml"); deleteStep.Execute(new Context()); try { var deletedFile = System.IO.File.Open(@"..\..\TestData\DeleteTest_FileToBeDeleted.wildCardTestxml", FileMode.Open, FileAccess.Read); } catch (System.IO.FileNotFoundException) { ; // Expected! } }
public void DeleteFileTest() { var step = new CreateStep { CreationPath = @"..\..\..\..\Test\BizUnit.TestSteps.Tests\TestData\DeleteTest_FileToBeDeleted.xml" }; var dl = new FileDataLoader { FilePath = @"..\..\..\..\Test\BizUnit.TestSteps.Tests\TestData\PurchaseOrder001.xml" }; step.DataSource = dl; step.Execute(new Context()); var deleteStep = new DeleteStep(); deleteStep.FilePathsToDelete.Add( @"..\..\..\..\Test\BizUnit.TestSteps.Tests\TestData\DeleteTest_FileToBeDeleted.xml"); deleteStep.Execute(new Context()); try { var deletedFile = System.IO.File.Open( @"..\..\..\..\Test\BizUnit.TestSteps.Tests\TestData\DeleteTest_FileToBeDeleted.xml", FileMode.Open, FileAccess.Read); } catch (FileNotFoundException) { // Expected! } }
public void DeleteFileTest() { var step = new CreateStep(); step.CreationPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\DeleteTest_FileToBeDeleted.xml"); var dl = new FileDataLoader(); dl.FilePath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\PurchaseOrder001.xml"); step.DataSource = dl; step.Execute(new Context()); var deleteStep = new DeleteStep(); deleteStep.FilePathsToDelete.Add(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\DeleteTest_FileToBeDeleted.xml")); deleteStep.Execute(new Context()); try { var deletedFile = System.IO.File.Open(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\DeleteTest_FileToBeDeleted.xml"), FileMode.Open, FileAccess.Read); } catch (System.IO.FileNotFoundException) { ; // Expected! } }
public void TestCaseValidationTest() { var step = new CreateStep(); var tc = new TestCase(); tc.ExecutionSteps.Add(step); Assert.Throws <ArgumentNullException>(() => { var bu = new TestRunner(tc); }); }
public void TestCaseValidationTest() { var step = new CreateStep(); var tc = new TestCase(); tc.ExecutionSteps.Add(step); var bu = new BizUnit(tc); bu.RunTest(); }
public void SampleTestCase() { var sourceDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData"); var sourceFilePath = Path.Combine(sourceDirectory, "PurchaseOrder001.xml"); var targetDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestArea"); var targetFilePath = Path.Combine(targetDirectory, "FileCreateStepTest.xml"); var fds = new DeleteStep(); fds.FilePathsToDelete.Add(targetFilePath); var fcs = new CreateStep(); fcs.CreationPath = targetFilePath; var dl = new FileDataLoader(); dl.FilePath = sourceFilePath; fcs.DataSource = dl; var frs = new FileReadStep(); frs.DirectoryPath = targetDirectory; frs.SearchPattern = "*.xml"; frs.Timeout = 3000; frs.DeleteFile = true; var tc = new TestCase(); tc.SetupSteps.Add(fds); tc.ExecutionSteps.Add(fcs); tc.ExecutionSteps.Add(frs); tc.CleanupSteps.Add(fds); var testRunner = new TestRunner(tc); testRunner.Run(); TestCase.SaveToFile( tc, Path.Combine( TestContext.CurrentContext.TestDirectory, @"..\..\", "TestCases", "SampleTest.xaml"), true); }
public void CreateFileTest() { var step = new CreateStep { CreationPath = @"..\..\..\..\Test\BizUnit.TestSteps.Tests\TestData\FileCreateStepTest.testdelxml" }; var dl = new FileDataLoader { FilePath = @"..\..\..\..\Test\BizUnit.TestSteps.Tests\TestData\PurchaseOrder001.xml" }; step.DataSource = dl; step.Execute(new Context()); var readStep = new FileReadMultipleStep { DirectoryPath = @"..\..\..\..\Test\BizUnit.TestSteps.Tests\TestData\.", SearchPattern = "*.testdelxml" }; var validation = new XmlValidationStep(); var schemaPurchaseOrder = new SchemaDefinition { XmlSchemaPath = @"..\..\..\..\Test\BizUnit.TestSteps.Tests\TestData\PurchaseOrder.xsd", XmlSchemaNameSpace = "http://SendMail.PurchaseOrder" }; validation.XmlSchemas.Add(schemaPurchaseOrder); var xpathProductId = new XPathDefinition { Description = "PONumber", XPath = "/*[local-name()='PurchaseOrder' and namespace-uri()='http://SendMail.PurchaseOrder']/*[local-name()='PONumber' and namespace-uri()='']", Value = "12323" }; validation.XPathValidations.Add(xpathProductId); readStep.SubSteps.Add(validation); readStep.Execute(new Context()); }
private TestCase BuildFirstTestCase() { var testCase1 = new TestCase { Name = "Copy First File Test" }; var step = new CreateStep(); step.CreationPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "File1.xml"); var dl = new FileDataLoader(); dl.FilePath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\PurchaseOrder001.xml"); step.DataSource = dl; step.Execute(new Context()); testCase1.ExecutionSteps.Add(step); return(testCase1); }
private TestCase BuildFirstTestCase() { var testCase1 = new TestCase { Name = "Copy First File Test" }; var step = new CreateStep(); step.CreationPath = @"File1.xml"; var dl = new FileDataLoader(); dl.FilePath = @"..\..\TestData\PurchaseOrder001.xml"; step.DataSource = dl; step.Execute(new Context()); testCase1.ExecutionSteps.Add(step); return(testCase1); }
public void Test_03_XmlPokeStep() { //setup the steps required //this is the setup stage CreateStep fcStep = new CreateStep(); fcStep.DataSource = new FileDataLoader { FilePath = @".\..\..\TestData\XmlPokeData.xml" }; fcStep.CreationPath = @".\..\..\TestData\XmlPokeDataOut.xml"; //this is the actual execution XmlPokeStep xpStep = new XmlPokeStep(); xpStep.FileName = @".\..\..\TestData\XmlPokeDataOut.xml"; xpStep.Expressions.Add("/PersonObject/partyid||1000"); //Instantiate the test case container TestCase tc = new TestCase(); tc.Name = "Test_03_XmlPokeStep"; //Add the test steps into the container at the required stages tc.SetupSteps.Add(fcStep); tc.ExecutionSteps.Add(xpStep); //Initialise BizUnit runner with the test case container BizUnit bizUnit = new BizUnit(tc); //run the test bizUnit.RunTest(); //Do an ordinary XPath evaluation of the result as part of the assertion //because there is no strong typing of the validation steps XmlDocument xDoc = new XmlDocument(); xDoc.Load(@".\..\..\TestData\XmlPokeDataOut.xml"); XmlNode testNode = xDoc.SelectSingleNode("/PersonObject/partyid"); string actualValue = testNode.InnerText; //Do an assertion on the XpAth value Assert.AreEqual("1000", actualValue); //now delete the file File.Delete(@".\..\..\TestData\XmlPokeDataOut.xml"); }
private TestCase BuildFirstTestCase() { var testCase1 = new TestCase { Name = "Copy First File Test" }; var step = new CreateStep { CreationPath = @"File1.xml", DataSource = new FileDataLoader { FilePath = @"..\..\..\..\Test\BizUnit.TestSteps.Tests\TestData\PurchaseOrder001.xml" } }; step.Execute(new Context()); testCase1.ExecutionSteps.Add(step); return(testCase1); }
public void LoadSampleTest() { DelaySampleTest(); // Load Test Case var testCase = TestCase.LoadFromFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "DelaySampleTest.xaml")); // Create test steps... var dataLoader = new FileDataLoader { FilePath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\InputPO.xaml") }; var fileCreate = new CreateStep { CreationPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"InputFile"), DataSource = dataLoader }; testCase.ExecutionSteps.Add(fileCreate); // Save Test Case TestCase.SaveToFile(testCase, Path.Combine(TestContext.CurrentContext.TestDirectory, "ExtendedDelaySampleTest.xaml")); }
public void LoadSampleTest() { DelaySampleTest(); // Load Test Case var testCase = TestCase.LoadFromFile("DelaySampleTest.xml"); // Create test steps... var dataLoader = new FileDataLoader { FilePath = @"TestData\InputPO.xml" }; var fileCreate = new CreateStep { CreationPath = @"C\InputFile", DataSource = dataLoader }; testCase.ExecutionSteps.Add(fileCreate); // Save Test Case TestCase.SaveToFile(testCase, "DelaySampleTest.xml"); }
public void CreateFileTest() { var step = new CreateStep(); step.CreationPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\FileCreateStepTest.testdelxml"); var dl = new FileDataLoader(); dl.FilePath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\PurchaseOrder001.xml"); step.DataSource = dl; step.Execute(new Context()); var readStep = new FileReadMultipleStep(); readStep.DirectoryPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\."); readStep.SearchPattern = "*.testdelxml"; var validation = new XmlValidationStep(); var schemaPurchaseOrder = new SchemaDefinition { XmlSchemaPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\TestData\PurchaseOrder.xsd"), XmlSchemaNameSpace = "http://SendMail.PurchaseOrder" }; validation.XmlSchemas.Add(schemaPurchaseOrder); var xpathProductId = new XPathDefinition(); xpathProductId.Description = "PONumber"; xpathProductId.XPath = "/*[local-name()='PurchaseOrder' and namespace-uri()='http://SendMail.PurchaseOrder']/*[local-name()='PONumber' and namespace-uri()='']"; xpathProductId.Value = "12323"; validation.XPathValidations.Add(xpathProductId); readStep.SubSteps.Add(validation); readStep.Execute(new Context()); }
public void ImportSingleTestCaseTest() { TestHelper.DeleteFile("ImportSingleTestCaseTest.xml"); // Create the first test case i a helper method... var testCase1 = BuildFirstTestCase(); // Create the second test case and import the first test case into it... var testCase2 = new TestCase { Name = "Copy First File Test" }; var createFileStep = new CreateStep { CreationPath = @"File2.xml" }; var dl = new FileDataLoader { FilePath = @"..\..\TestData\PurchaseOrder001.xml" }; createFileStep.DataSource = dl; testCase2.ExecutionSteps.Add(createFileStep); var import = new ImportTestCaseStep { TestCase = testCase1 }; testCase2.ExecutionSteps.Add(import); // Create a validating read step... var validatingFileReadStep = new FileReadMultipleStep { DirectoryPath = @".", SearchPattern = "File*.xml", ExpectedNumberOfFiles = 2 }; var validation = new XmlValidationStep(); var schemaPurchaseOrder = new SchemaDefinition { XmlSchemaPath = @"..\..\TestData\PurchaseOrder.xsd", XmlSchemaNameSpace = "http://SendMail.PurchaseOrder" }; validation.XmlSchemas.Add(schemaPurchaseOrder); var xpathProductId = new XPathDefinition { Description = "PONumber", XPath = "/*[local-name()='PurchaseOrder' and namespace-uri()='http://SendMail.PurchaseOrder']/*[local-name()='PONumber' and namespace-uri()='']", Value = "12323" }; validation.XPathValidations.Add(xpathProductId); validatingFileReadStep.SubSteps.Add(validation); testCase2.ExecutionSteps.Add(validatingFileReadStep); // Run the second test case... var bizUnit = new BizUnit(testCase2); bizUnit.RunTest(); TestCase.SaveToFile(testCase2, "ImportSingleTestCaseTest.xml"); }
/// <summary> /// “定位”操作的处理 /// </summary> public void LocateHandle() { //进行新的定位前先讲缓冲器内的暂存工序清除 tempProcess.Clear(); CanForward = false; //添加一道工序到当前工位的工序列表 CreatingModel.StationList[(int)stationNo].Add(getProcessType(), getProcessShape(), this.IsOutside, Servo.GetPosition()); //更新提示框消息 this.Tips = "铣入一定深度之后点击“确定”按钮"; CreatingStep = CreateStep.Confirm; }
/// <summary> /// “确定操作的处理” /// </summary> public void ConfirmHandle() { if (IsMill) { this.Tips = "选择要加工的形状,定位到要加工的点,输入相应的参数,点击“定位”按钮。"; } else { this.Tips = "定位到切边点,点击“定位”按钮。"; } //设置铣入点坐标 CreatingModel.StationList[(int)stationNo].LastProcess.setIntoPoint(Servo.GetPosition(), IsMill, CreatingModel.StationList[(int)stationNo].CutNum); if (IsCirShape) { CreatingModel.StationList[(int)stationNo].LastProcess.Diameter = Diameter; } else if (IsRecShape) { CreatingModel.StationList[(int)stationNo].LastProcess.Height = Height; CreatingModel.StationList[(int)stationNo].LastProcess.Width = Width; CreatingModel.StationList[(int)stationNo].LastProcess.RecDirection = IsRecClockWise ? Direction.ClockWise : Direction.CounterClockWise; } CreatingStep = CreateStep.Locate; }
public void SummaryTest() { //var totalItemsTest = new TestCase { Name = "Total Items is 3" }; var sourceFilePath = @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\Testing\OrderSample.xml"; //var targetDirectory = @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\Testing\Order"; var targetFilePath = @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\Testing\Order\OrderSample.xml"; var DestinationDirSummary = @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\Testing\Summary"; //Get rid of any files that are already there var deleteStep = new DeleteStep(); deleteStep.FilePathsToDelete.Add(targetFilePath); //Create the test step var createStep = new CreateStep(); createStep.CreationPath = targetFilePath; //Where are we going to create the file var dataLoader = new FileDataLoader(); //Where are we getting the file from? dataLoader.FilePath = sourceFilePath; createStep.DataSource = dataLoader; //Create a validating read step //We should only have one file in the directory var ValidateFileStep = new FileReadMultipleStep(); ValidateFileStep.DirectoryPath = DestinationDirSummary; ValidateFileStep.SearchPattern = "*.xml"; ValidateFileStep.Timeout = 3000; ValidateFileStep.ExpectedNumberOfFiles = 1; ValidateFileStep.DeleteFiles = true; //Create an XML Validation step //This will check the result against the XSD for the document var summarySchemaValidationStep = new XmlValidationStep(); var schemaSummary = new SchemaDefinition(); schemaSummary.XmlSchemaPath = @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\Timewave.BizUnit.Sample\Timewave.BizUnit.Sample\Schemas\SummarySchema.xsd"; schemaSummary.XmlSchemaNameSpace = "http://Timewave.BizTalkUnit.Sample.DestinationSchema"; summarySchemaValidationStep.XmlSchemas.Add(schemaSummary); //Create an XPath Validation. This will check a value in the output. //The Xpath for the node can be grabbed from the Instance XPath property on the XSD. var xpathProductId = new XPathDefinition(); xpathProductId.Description = "ItemsOrdered"; xpathProductId.XPath = "/*[local-name()='CustomerSummary' and namespace-uri()='http://Timewave.BizTalkUnit.Sample.DestinationSchema']/*[local-name()='ItemsOrdered' and namespace-uri()='']"; xpathProductId.Value = "2"; summarySchemaValidationStep.XPathValidations.Add(xpathProductId); ValidateFileStep.SubSteps.Add(summarySchemaValidationStep); var testCase = new TestCase(); testCase.SetupSteps.Add(deleteStep); testCase.ExecutionSteps.Add(createStep); testCase.ExecutionSteps.Add(ValidateFileStep); testCase.CleanupSteps.Add(deleteStep); var testRunner = new TestRunner(testCase); try { testRunner.Run(); } catch (Exception ex) { string filePath = @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\TestResult\Error.txt"; using (StreamWriter writer = new StreamWriter(filePath, true)) { writer.WriteLine("-----------------------------------------------------------------------------"); writer.WriteLine("Date : " + DateTime.Now.ToString()); writer.WriteLine(); while (ex != null) { writer.WriteLine(ex.GetType().FullName); writer.WriteLine("Message : " + ex.Message); writer.WriteLine("StackTrace : " + ex.StackTrace); ex = ex.InnerException; } } } finally { TestCase.SaveToFile( testCase, @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\TestResult\SampleTest.xaml", true); } }
/// <summary> /// 流程任务处理 /// </summary> /// <param name="stepId">流程步骤Id</param> /// <returns>返回操作结果</returns> public OperationResult ActionTask(Guid stepId) { OperationResult or = new OperationResult(OperationResultType.Error); String msg = String.Empty; if (this.NowUser.IsNullOrEmpty()) { msg = "流程启动者未空."; return(new OperationResult(OperationResultType.QueryNull, msg)); } if (this.MainId.IsNullOrEmpty()) { msg = "流程无主题依赖."; return(new OperationResult(OperationResultType.QueryNull, msg)); } // 获取当前流程运行实例 List <WFRunInstance> instances = WFRunInstanceService.Entities.Where(c => c.MainId == MainId).ToList(); WFRunInstance runInstance = instances.FirstOrDefault(); if (runInstance.IsNullOrEmpty()) { msg = "该流程不存在!"; return(new OperationResult(OperationResultType.QueryNull, msg)); } // 当前流程实例对应步骤信息 List <WFRunStep> rSteps = WFRunStepService.Entities.Where(c => c.InstanceId == runInstance.Id).OrderByDescending(c => c.Sort).ToList(); // 上去步骤 WFRunStep rStep = rSteps.FirstOrDefault(c => c.Id == stepId && c.Status == 0); if (rStep.IsNullOrEmpty()) { msg = "该步骤已过期或无效!"; return(new OperationResult(OperationResultType.QueryNull, msg)); } // 获取当前实例 WFInfo wfInfo = this.GetWFInstall(runInstance.DesignJSON); List <Line> lines = wfInfo.Lines.Where(c => c.FromID == rStep.SId).ToList(); // 声明下一步骤默认处理者Id和名称 String rId = String.Empty; foreach (Line line in lines) { Step toStep = wfInfo.Steps.Where(c => c.Id == line.ToID).FirstOrDefault(); String id = toStep.DefaultUser; rId = rId.IsNullOrEmpty() ? id : rId + ";" + id; WFRunStep item = new WFRunStep { Id = Guid.NewGuid(), ParentId = rStep.Id, SId = toStep.Id, Name = toStep.Name, FormUrl = toStep.FormUrl, FormId = toStep.FormId.GetGuid(), InstanceId = runInstance.Id, SenderId = NowUser.Id, SenderTime = DateTime.Now, ReceiveTime = DateTime.Now, ReceiveId = id, Status = 0, Sort = (rSteps.Count == 0 ? 1 : rSteps.Count) + 1 }; rSteps.Add(item); if (!CreateStep.IsNullOrEmpty()) { WFTaskArgs args = new WFTaskArgs(item, wfInfo, runInstance, NowUser); CreateStep(args); } //tasks.Add(this.CreateTask(item, user, mainId, wfInfo.Name)); } // 标记当前步骤完成 rStep.Status = 2; rSteps.Add(rStep); if (!CreateStep.IsNullOrEmpty()) { WFTaskArgs args = new WFTaskArgs(rStep, wfInfo, runInstance, NowUser); CreateStep(args); } or = WFRunStepService.AddOrUpdate(c => new { c.Id }, rSteps); if (or.ResultType == OperationResultType.Success) { or = new OperationResult(OperationResultType.Success, "任务处理完成", true); if (!WFComplete.IsNullOrEmpty()) { WFTaskArgs args = new WFTaskArgs(rStep, wfInfo, runInstance, NowUser); WFComplete(args); } } else { or = new OperationResult(OperationResultType.QueryNull, "任务处理失败", false); } return(or); }
/// <summary> /// 根据指定参数启动流程 /// 根据指定步骤Id查询数据为空,则创建一个新流程 /// </summary> /// <returns>返回操作结果</returns> public OperationResult Execute() { OperationResult or = new OperationResult(OperationResultType.Error); String msg = String.Empty; if (this.DesignId.IsNullOrEmpty()) { msg = "流程设计Id为空."; return(new OperationResult(OperationResultType.QueryNull, msg)); } if (this.MainId.IsNullOrEmpty()) { msg = "流程无主题依赖."; return(new OperationResult(OperationResultType.QueryNull, msg)); } if (this.NowUser.IsNullOrEmpty()) { msg = "流程启动者未空."; return(new OperationResult(OperationResultType.QueryNull, msg)); } // 声明流程实例 WFInfo wfInfo = new WFInfo(); // 获取当前流程运行实例 List <WFRunInstance> instances = WFRunInstanceRepository.Entities.Where(c => c.MainId == this.MainId).ToList(); WFRunInstance runInstance = instances.FirstOrDefault(); // 如果流程实例不存在,这创建流程实例 if (runInstance.IsNullOrEmpty()) { WFDesign design = WFDesignRepository.GetByKey(this.DesignId); // 实例当前流程设计 wfInfo = this.GetWFInstall(design.DesignJSON); runInstance = this.CreateInstance(design.DesignJSON, this.MainId, this.NowUser.Id); } else { // 实例当前流程设计 wfInfo = this.GetWFInstall(runInstance.DesignJSON); } // 获取指定实体对应运行步骤信息 List <WFRunStep> rSteps = WFRunStepRepository.Entities.Where(c => c.InstanceId == runInstance.Id).OrderByDescending(c => c.Sort).ToList(); // 获得当前运行步骤 WFRunStep rStep = rSteps.FirstOrDefault(); Boolean isFirst = false; // 判断步骤是否为空,如果为空则为第一次启动流程,并创建一个新步骤信息 if (rStep.IsNullOrEmpty()) { // 流程当前步骤 Step step = wfInfo.Steps.Where(c => c.Id == wfInfo.FirstStepID).FirstOrDefault(); rStep = new WFRunStep { ParentId = Guid.Empty, SId = step.Id, Name = step.Name, FormUrl = step.FormUrl, InstanceId = runInstance.Id, SenderId = this.NowUser.Id, Status = 2, Sort = 1 }; isFirst = true; } // 获取当前步骤下一步路线 List <Line> lines = wfInfo.Lines.Where(c => c.FromID == rStep.SId).ToList(); // 判断当前步骤是否为空 if (lines.IsNullOrEmpty() || lines.Count == 0) { msg = "流程设计中连线存在问题."; return(new OperationResult(OperationResultType.QueryNull, msg)); } // 声明下一步骤默认处理者Id和名称 String rId = String.Empty; foreach (Line line in lines) { Step toStep = wfInfo.Steps.Where(c => c.Id == line.ToID).FirstOrDefault(); String id = toStep.DefaultUser; rId = rId.IsNullOrEmpty() ? id : rId + ";" + id; WFRunStep item = new WFRunStep { Id = Guid.NewGuid(), ParentId = rStep.SId, SId = toStep.Id, Name = toStep.Name, FormUrl = toStep.FormUrl, InstanceId = runInstance.Id, SenderId = NowUser.Id, ReceiveId = id, Status = 0, Sort = (rSteps.Count == 0 ? 1 : rSteps.Count) + 1 }; rSteps.Add(item); //or = this.Insert(item); if (!CreateStep.IsNullOrEmpty()) { WFTaskArgs args = new WFTaskArgs(item, wfInfo, runInstance, NowUser); CreateStep(args); } } // 第一次创建流程 if (isFirst) { rStep.ReceiveId = rId; rSteps.Add(rStep); if (!CreateStep.IsNullOrEmpty()) { WFTaskArgs args = new WFTaskArgs(rStep, wfInfo, runInstance, NowUser); CreateStep(args); } } if (WFRunStepRepository.AddOrUpdate(c => new { c.Id }, rSteps.ToArray()).Equals(0)) { or = new OperationResult(OperationResultType.QueryNull, "流程启动失败", false); } else { or = new OperationResult(OperationResultType.Success, "流程启动成功", true); if (!WFComplete.IsNullOrEmpty()) { WFTaskArgs args = new WFTaskArgs(rStep, wfInfo, runInstance, NowUser); WFComplete(args); } } return(or); }
public void Upgrade_Elligable_Test() { var testCase = new TestCase(); testCase.Name = "Upgrade_Elligable_Test"; testCase.Purpose = "Test successful upgrade"; testCase.Description = "Test upgrade succeeds for passenger/flight not elligable for upgrade"; testCase.Category = "BizUnit SDK: BVT"; testCase.Reference = "Use case: 10.3.4"; testCase.ExpectedResults = "Upgrade succeeds"; testCase.Preconditions = "Solution should be deployed, bound and started"; // First ensure the target directory is empty... var delFiles = new DeleteStep(); delFiles.FilePathsToDelete = new Collection <string> { @"C:\Temp\BizTalk\BizUnitSdkOut\*.xml" }; testCase.SetupSteps.Add(delFiles); // Then execute the main scenario, execute a response-response web set step which is executed concurrently. // i.e. whilst this step is waiting for the response the next step, FileReadMultipleStep and then CreateStep // will be executed. var wsStep = new WebServiceStep(); wsStep.Action = "Upgrade"; wsStep.ServiceUrl = "http://localhost/BizUnit.Sdk.FlightUpgrade/BizUnit_Sdk_FlightUpgrade_ProcessRequest_UpgradePort.svc"; wsStep.RequestBody = new FileDataLoader { FilePath = @"..\..\..\Tests\FlightUpgrade.Tests\Data\Request.xml" }; wsStep.RunConcurrently = true; // Add validation.... var validation = new XmlValidationStep(); var schemaResultType = new SchemaDefinition { XmlSchemaPath = @"..\..\..\Src\FlightUpgrade\ResponseMsg.xsd", XmlSchemaNameSpace = "http://bizUnit.sdk.flightUpgrade/upgradeResponse" }; validation.XmlSchemas.Add(schemaResultType); var responseXpath = new XPathDefinition(); responseXpath.Description = "GetProducts_RS/Result/result"; responseXpath.XPath = "/*[local-name()='UpgradeResponse' and namespace-uri()='http://bizUnit.sdk.flightUpgrade/upgradeResponse']/*[local-name()='UpgradeResult' and namespace-uri()='']/*[local-name()='Result' and namespace-uri()='']"; responseXpath.Value = "true"; validation.XPathValidations.Add(responseXpath); var fileReadStep = new FileReadMultipleStep(); fileReadStep.DirectoryPath = @"C:\Temp\BizTalk\BizUnitSdkOut"; fileReadStep.SearchPattern = "*.xml"; fileReadStep.ExpectedNumberOfFiles = 1; fileReadStep.Timeout = 5000; fileReadStep.DeleteFiles = true; var createFileStep = new CreateStep(); createFileStep.CreationPath = @"..\..\..\Data\In\UpgradeResponse.xml"; createFileStep.DataSource = new FileDataLoader { FilePath = @"..\..\..\Tests\FlightUpgrade.Tests\Data\Response.xml" }; testCase.ExecutionSteps.Add(wsStep); testCase.ExecutionSteps.Add(fileReadStep); testCase.ExecutionSteps.Add(createFileStep); var bizUnit = new BizUnit(testCase); bizUnit.RunTest(); TestCase.SaveToFile(testCase, "Upgrade_Elligable_Test.xml"); }
public void Integration_Test() { #region Variable Intialization var sourceFilePath = @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\Testing\OrderSample.xml"; var targetFilePath = @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\Testing\Order\OrderSample.xml"; var DestinationDirSummary = @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\Testing\Summary"; #endregion #region Initial CleanUp Step //Get rid of any files that are already there var deleteStep = new DeleteStep(); deleteStep.FilePathsToDelete.Add(targetFilePath); #endregion #region Create step //Create the test step var createStep = new CreateStep(); createStep.CreationPath = targetFilePath; //Where are we going to create the file var dataLoader = new FileDataLoader(); //Where are we getting the file from? dataLoader.FilePath = sourceFilePath; createStep.DataSource = dataLoader; #endregion #region Execution steps #region File Validation Step //Create a validating read step //We should only have one file in the directory var ValidateFileStep = new FileReadMultipleStep(); ValidateFileStep.DirectoryPath = DestinationDirSummary; ValidateFileStep.SearchPattern = "*.xml"; ValidateFileStep.Timeout = 60000; ValidateFileStep.ExpectedNumberOfFiles = 1; ValidateFileStep.DeleteFiles = true; #endregion #region #SubSteps - Schema and node value Validation Step //Create an XML Validation step //This will check the result against the XSD for the document var summarySchemaValidationStep = new XmlValidationStep(); var schemaSummary = new SchemaDefinition(); schemaSummary.XmlSchemaPath = @"C:\Users\amigupta7\Desktop\Amit\Project\POC\Timewave.BizUnit.Sample\Timewave.BizUnit.Sample\Timewave.BizUnit.Sample\Schemas\SummarySchema.xsd"; schemaSummary.XmlSchemaNameSpace = "http://Timewave.BizTalkUnit.Sample.DestinationSchema"; summarySchemaValidationStep.XmlSchemas.Add(schemaSummary); //Create an XPath Validation. This will check a value in the output. //The Xpath for the node can be grabbed from the Instance XPath property on the XSD. var xpathProductId = new XPathDefinition(); xpathProductId.Description = "ItemsOrdered"; xpathProductId.XPath = "/*[local-name()='CustomerSummary' and namespace-uri()='http://Timewave.BizTalkUnit.Sample.DestinationSchema']/*[local-name()='ItemsOrdered' and namespace-uri()='']"; xpathProductId.Value = "1"; summarySchemaValidationStep.XPathValidations.Add(xpathProductId); ValidateFileStep.SubSteps.Add(summarySchemaValidationStep); #endregion #endregion #region Test Case Execution var testCase = new TestCase(); testCase.SetupSteps.Add(deleteStep); testCase.ExecutionSteps.Add(createStep); testCase.ExecutionSteps.Add(ValidateFileStep); testCase.CleanupSteps.Add(deleteStep); var testRunner = new TestRunner(testCase); testRunner.Run(); #endregion }
public void Upgrade_Eligible_Test_FILE() { var testCase = new TestCase(); testCase.Name = "Upgrade_Eligible_Test_FILE"; testCase.Purpose = "Test successful upgrade"; testCase.Description = "Test upgrade succeeds for passenger/flight eligible for upgrade"; testCase.Category = "BizUnit SDK: BVT"; testCase.Reference = "Use case: 10.3.4"; testCase.ExpectedResults = "Upgrade succeeds"; testCase.Preconditions = "Solution should be deployed, bound and started"; // First ensure the target directory is empty... var delFiles = new DeleteStep(); delFiles.FilePathsToDelete = new Collection <string> { @"C:\Temp\BizTalk\BizUnitSdkOut\*.xml" }; testCase.SetupSteps.Add(delFiles); // Then execute the main scenario. var testStep = new CreateStep(); // Where are we going to create the file. testStep.CreationPath = @"C:\Temp\BizTalk\BizUnitSdkIn\Request.xml"; var dataLoader = new FileDataLoader(); // Where are we getting the original file from? dataLoader.FilePath = @"..\..\Data\Request.xml"; testStep.DataSource = dataLoader; testCase.ExecutionSteps.Add(testStep); // Add validation.... var validation = new XmlValidationStep(); var schemaResultType = new SchemaDefinition { XmlSchemaPath = @"..\..\..\..\Src\FlightUpgrade\ResponseMsg.xsd", XmlSchemaNameSpace = "http://bizUnit.sdk.flightUpgrade/upgradeResponse" }; validation.XmlSchemas.Add(schemaResultType); var responseXpath = new XPathDefinition(); responseXpath.Description = "GetProducts_RS/Result/result"; responseXpath.XPath = "/*[local-name()='UpgradeResponse' and namespace-uri()='http://bizUnit.sdk.flightUpgrade/upgradeResponse']/*[local-name()='UpgradeResult' and namespace-uri()='']/*[local-name()='Result' and namespace-uri()='']"; responseXpath.Value = "true"; validation.XPathValidations.Add(responseXpath); // Check that an output file has been created. var finalFileReadStep = new FileReadMultipleStep(); finalFileReadStep.DirectoryPath = @"C:\Temp\BizTalk\BizUnitSdkOut"; finalFileReadStep.SearchPattern = "*.xml"; finalFileReadStep.ExpectedNumberOfFiles = 1; finalFileReadStep.Timeout = 5000; finalFileReadStep.DeleteFiles = false; finalFileReadStep.SubSteps.Add(validation); testCase.ExecutionSteps.Add(finalFileReadStep); var bizUnit = new BizUnit(testCase); bizUnit.RunTest(); TestCase.SaveToFile(testCase, System.String.Format("Upgrade_Eligible_Test_File_{0}.xml", System.String.Format("{0:yyyy-MM-dd-hh_mm_ss}", System.DateTime.Now))); }
/// <summary> /// 根据指定参数启动流程 /// 根据指定步骤Id查询数据为空,则创建一个新流程 /// </summary> /// <returns>返回操作结果</returns> public OperationResult Execute() { OperationResult or = new OperationResult(OperationResultType.Error); String msg = String.Empty; if (this.DesignId.IsNullOrEmpty()) { msg = "流程设计Id为空."; return(new OperationResult(OperationResultType.QueryNull, msg)); } if (this.MainId.IsNullOrEmpty()) { msg = "流程无主题依赖."; return(new OperationResult(OperationResultType.QueryNull, msg)); } if (this.NowUser.IsNullOrEmpty()) { msg = "流程启动者不能为空."; return(new OperationResult(OperationResultType.QueryNull, msg)); } // 声明流程实例 WFInfo wfInfo = new WFInfo(); // 获取当前流程运行实例 List <WFRunInstance> instances = WFRunInstanceService.Entities.Where(c => c.MainId == this.MainId).ToList(); WFRunInstance runInstance = instances.FirstOrDefault(); // 如果流程实例不存在,这创建流程实例 if (runInstance.IsNullOrEmpty()) { or = WFModelService.GetByKey(this.DesignId); WFModel design = or.AppendData as WFModel; if (!or.IsNullOrEmpty()) { // 实例当前流程设计 wfInfo = this.GetWFInstall(design.DesignJSON); runInstance = this.CreateInstance(design.DesignJSON, this.MainId, this.NowUser.Id); } else { msg = "流程模型未找到!"; return(new OperationResult(OperationResultType.QueryNull, msg)); } } else { // 实例当前流程设计 wfInfo = this.GetWFInstall(runInstance.DesignJSON); } // 获取指定实体对应运行步骤信息 List <WFRunStep> rSteps = WFRunStepService.Entities.Where(c => c.InstanceId == runInstance.Id).OrderByDescending(c => c.Sort).ToList(); // 获得当前运行步骤 WFRunStep rStep = rSteps.FirstOrDefault(); Boolean isFirst = false; // 判断步骤是否为空,如果为空则为第一次启动流程,并创建一个新步骤信息 if (rStep.IsNullOrEmpty()) { // 流程当前步骤 Step step = wfInfo.Steps.Where(c => c.Id == wfInfo.FirstStepID).FirstOrDefault(); rStep = new WFRunStep { ParentId = Guid.Empty, SId = step.Id, FormId = step.FormId.GetGuid(), Name = step.Name, FormUrl = step.FormUrl, InstanceId = runInstance.Id, SenderId = this.NowUser.Id, SenderTime = DateTime.Now, Status = 2, Sort = 1 }; isFirst = true; } // 获取当前步骤下一步路线 List <Line> lines = wfInfo.Lines.Where(c => c.FromID == rStep.SId).ToList(); // 判断当前步骤是否为空 if (lines.IsNullOrEmpty() || lines.Count == 0) { msg = "流程设计中连线存在问题."; return(new OperationResult(OperationResultType.QueryNull, msg)); } // 声明下一步骤默认处理者Id和名称 String rId = String.Empty; foreach (Line line in lines) { Boolean isTrue = false; // 判断连线是否满足规则 if (!line.Expression.IsNullOrEmpty()) { isTrue = LineWhere(line.Expression, wfInfo.DBTableName); } if (!line.TSql.IsNullOrEmpty()) { //or = WFModelService.Context. SqlParameter s = new SqlParameter("@mainId", SqlDbType.UniqueIdentifier) { Value = "00000000-0000-0000-0000-000000000001".GetGuid() }; Int32 result = WFModelService.DB.SqlQuery <Int32>(line.TSql, s).FirstOrDefault(); isTrue = result > 0 ? true : false; //if (or.ResultType == OperationResultType.Success) //{ // or.AppendData // isTrue = true; //} } //Boolean isTrue = true; if (isTrue) { // 连线下一步骤 Step toStep = wfInfo.Steps.Where(c => c.Id == line.ToID).FirstOrDefault(); String id = toStep.DefaultUser; rId = rId.IsNullOrEmpty() ? id : rId + ";" + id; WFRunStep item = new WFRunStep { Id = Guid.NewGuid(), ParentId = rStep.SId, SId = toStep.Id, Name = toStep.Name, FormUrl = toStep.FormUrl, InstanceId = runInstance.Id, FormId = toStep.FormId.GetGuid(), SenderId = NowUser.Id, SenderTime = DateTime.Now, ReceiveId = id, Status = 0, Sort = (rSteps.Count == 0 ? 1 : rSteps.Count) + 1 }; rSteps.Add(item); //or = this.Insert(item); if (!CreateStep.IsNullOrEmpty()) { WFTaskArgs args = new WFTaskArgs(item, wfInfo, runInstance, NowUser); CreateStep(args); } } } // 第一次创建流程 if (isFirst) { rStep.ReceiveId = rId; rSteps.Add(rStep); if (!CreateStep.IsNullOrEmpty()) { WFTaskArgs args = new WFTaskArgs(rStep, wfInfo, runInstance, NowUser); CreateStep(args); } } or = WFRunStepService.AddOrUpdate(c => new { c.Id }, rSteps); if (or.ResultType == OperationResultType.Success) { or = new OperationResult(OperationResultType.Success, "流程启动成功", true); if (!WFComplete.IsNullOrEmpty()) { WFTaskArgs args = new WFTaskArgs(rStep, wfInfo, runInstance, NowUser); WFComplete(args); } } else { or = new OperationResult(OperationResultType.QueryNull, "流程启动失败", false); } return(or); }