public void BizFlowAddActivitiesFromSharedRepoSaveLoad() { //Arrange int ActivitiesToCreate = 5; string FileName = TestResources.GetTempFile("BFSaveLoad.xml"); BusinessFlow BF = new BusinessFlow() { Name = "Biz flow 1", Description = "Desc 1" }; BF.Activities = new ObservableList <Activity>(); for (int i = 1; i <= ActivitiesToCreate; i++) { Activity a = new Activity() { ActivityName = "Activity " + i, Description = "desc" + i, Status = eRunStatus.Passed }; BF.AddActivity(a); //for (int j = 1; j <= 2; j++) //{ // ActTextBox t = new ActTextBox(); // t.Description = "Set text box " + j; // t.LocateBy = Act.eLocatorType.ByID; // t.LocateValue = "ID" + j; // a.Acts.Add(t); // ActGotoURL g = new ActGotoURL(); // g.Description = "goto URL " + j; // g.LocateValue = "ID" + j; // a.Acts.Add(g); //} } VariableString v = new VariableString(); v.Name = "Var1"; v.Description = "VDesc 1"; BF.AddVariable(v); //ValidationDB vdb = new ValidationDB() { Description ="DBV1", Expected ="exp1" }; //BF.Activities[0].Asserts.Add(vdb); //Act BF.RepositorySerializer.SaveToFile(BF, FileName); // Assert NewRepositorySerializer newRepositorySerializer = new NewRepositorySerializer(); BusinessFlow BF2 = (BusinessFlow)newRepositorySerializer.DeserializeFromFile(typeof(BusinessFlow), FileName); Assert.AreEqual(BF2.Activities.Count(), ActivitiesToCreate); //Assert.AreEqual(BF2. Activities[0].Asserts.Count(), 1); //BF2.Description = "aaa"; }
public void BizFlowSaveLoad() { //Arrange int ActivitiesToCreate = 5; //Act BusinessFlow BF = new BusinessFlow(); BF.Name = "Biz flow 1"; BF.Description = "Desc 1"; //BF.Status = BusinessFlow.eBusinessFlowStatus.Active; //TODOL do NOT write to XML if null or empty BF.Activities = new ObservableList <Activity>(); for (int i = 1; i <= ActivitiesToCreate; i++) { Activity a = new Activity(); a.ActivityName = "Activity number " + i; a.Description = "Desc - " + i; BF.Activities.Add(a); a.Status = eRunStatus.Passed; for (int j = 1; j <= 2; j++) { ActTextBox t = new ActTextBox(); t.Description = "Set text box " + j; t.LocateBy = eLocateBy.ByID; t.LocateValue = "ID" + j; a.Acts.Add(t); ActGotoURL g = new ActGotoURL(); g.Description = "goto URL " + j; g.LocateValue = "ID" + j; a.Acts.Add(g); } } VariableString v = new VariableString(); v.Name = "Var1"; v.Description = "VDesc 1"; BF.AddVariable(v); string FileName = TestResources.GetTempFile("bf1.xml"); BF.SaveToFile(FileName); // Assert BusinessFlow BF2 = (BusinessFlow)RepositoryItem.LoadFromFile(typeof(BusinessFlow), FileName); Assert.AreEqual(BF2.Name, BF.Name); Assert.AreEqual(BF2.Description, BF.Description); Assert.AreEqual(BF2.Activities.Count, ActivitiesToCreate); Assert.AreEqual(BF2.Variables.Count, 1); //Validations }
public void RunsetConfigBFVariablesTest() { //Arrange ObservableList <BusinessFlow> bfList = SR.GetAllRepositoryItems <BusinessFlow>(); BusinessFlow BF1 = bfList[0]; ObservableList <Activity> activityList = BF1.Activities; Activity activity = activityList[0]; ActDummy act1 = new ActDummy() { Value = "", Active = true }; activity.Acts.Add(act1); VariableString v1 = new VariableString() { Name = "v1", InitialStringValue = "aaa" }; BF1.AddVariable(v1); BF1.Active = true; mGR.BusinessFlows.Add(BF1); //Adding Same Business Flow Again to GingerRunner BusinessFlow bfToAdd = (BusinessFlow)BF1.CreateCopy(false); bfToAdd.ContainingFolder = BF1.ContainingFolder; bfToAdd.Active = true; bfToAdd.Reset(); bfToAdd.InstanceGuid = Guid.NewGuid(); mGR.BusinessFlows.Add(bfToAdd); WorkSpace.Instance.SolutionRepository = SR; //Act //Changing initial value of 2nd BF from BusinessFlow Config mGR.BusinessFlows[2].Variables[0].Value = "bbb"; mGR.BusinessFlows[2].Variables[0].DiffrentFromOrigin = true; mGR.RunRunner(); //Assert Assert.AreEqual(BF1.RunStatus, eRunStatus.Passed); Assert.AreEqual(activity.Status, eRunStatus.Passed); Assert.AreEqual(bfToAdd.RunStatus, eRunStatus.Passed); Assert.AreEqual(mGR.BusinessFlows[1].Variables[0].Value, "aaa"); Assert.AreEqual(mGR.BusinessFlows[2].Variables[0].Value, "bbb"); }
public void BizFlowCheckIsDirtyTrue() { //Arrange int ActivitiesToCreate = 2; string TempFilepath = TestResources.GetTempFile("bfIsDirtyTrue.xml"); BusinessFlow BF = new BusinessFlow(); BF.Name = "Biz flow 1"; BF.Description = "Desc 1"; //BF.Status = BusinessFlow.eBusinessFlowStatus.Active; //TODOL do NOT write to XML if null or empty BF.Activities = new ObservableList <Activity>(); for (int i = 1; i <= ActivitiesToCreate; i++) { Activity a = new Activity(); a.ActivityName = "Activity number " + i; a.Description = "Desc - " + i; BF.Activities.Add(a); a.Status = eRunStatus.Passed; for (int j = 1; j <= 2; j++) { ActTextBox t = new ActTextBox(); t.Description = "Set text box " + j; t.LocateBy = eLocateBy.ByID; t.LocateValue = "ID" + j; a.Acts.Add(t); ActGotoURL g = new ActGotoURL(); g.Description = "goto URL " + j; g.LocateValue = "ID" + j; a.Acts.Add(g); } } VariableString v = new VariableString(); v.Name = "Var1"; v.Description = "VDesc 1"; BF.AddVariable(v); //Act BF.RepositorySerializer.SaveToFile(BF, TempFilepath); // Assert NewRepositorySerializer newRepositorySerializer = new NewRepositorySerializer(); BusinessFlow BF2 = (BusinessFlow)newRepositorySerializer.DeserializeFromFile(typeof(BusinessFlow), TempFilepath); BF2.StartDirtyTracking(); BF2.Description = "aaa"; Assert.IsTrue(BF2.DirtyStatus == Amdocs.Ginger.Common.Enums.eDirtyStatus.Modified); }
public void BizFlowCheckIsDirtyTrue() { //Arrange int ActivitiesToCreate = 2; string TempFilepath = TestResources.GetTempFile("bfIsDirtyTrue.xml"); BusinessFlow BF = new BusinessFlow(); BF.Name = "Biz flow 1"; BF.Description = "Desc 1"; //BF.Status = BusinessFlow.eBusinessFlowStatus.Active; //TODOL do NOT write to XML if null or empty BF.Activities = new ObservableList <Activity>(); for (int i = 1; i <= ActivitiesToCreate; i++) { Activity a = new Activity(); a.ActivityName = "Activity number " + i; a.Description = "Desc - " + i; BF.Activities.Add(a); a.Status = eRunStatus.Passed; for (int j = 1; j <= 2; j++) { ActTextBox t = new ActTextBox(); t.Description = "Set text box " + j; t.LocateBy = eLocateBy.ByID; t.LocateValue = "ID" + j; a.Acts.Add(t); ActGotoURL g = new ActGotoURL(); g.Description = "goto URL " + j; g.LocateValue = "ID" + j; a.Acts.Add(g); } } VariableString v = new VariableString(); v.Name = "Var1"; v.Description = "VDesc 1"; BF.AddVariable(v); //Act BF.SaveToFile(TempFilepath); // Assert BusinessFlow BF2 = (BusinessFlow)RepositoryItem.LoadFromFile(typeof(BusinessFlow), TempFilepath); BF2.SaveBackup();//dirty now just indicate if backup exist BF2.Description = "aaa"; Assert.IsTrue(BF2.IsDirty); }
public static void ClassInit(TestContext context) { mBF = new BusinessFlow(); mBF.Activities = new ObservableList <Activity>(); mBF.Name = "BF Test Fire Fox"; mBF.Active = true; Platform p = new Platform(); p.PlatformType = ePlatformType.Web; mBF.TargetApplications.Add(new TargetApplication() { AppName = "SCM" }); VariableString v1 = new VariableString() { Name = "v1", InitialStringValue = "1" }; mBF.AddVariable(v1); mGR = new GingerRunner(); mGR.CurrentSolution = new Ginger.SolutionGeneral.Solution(); Agent a = new Agent(); //a.DriverType = Agent.eDriverType.SeleniumFireFox;//have known firefox issues with selenium 3 a.DriverType = Agent.eDriverType.SeleniumChrome; mGR.SolutionAgents = new ObservableList <Agent>(); mGR.SolutionAgents.Add(a); // p2.Agent = a; mGR.ApplicationAgents.Add(new ApplicationAgent() { AppName = "SCM", Agent = a }); mGR.SolutionApplications = new ObservableList <ApplicationPlatform>(); mGR.SolutionApplications.Add(new ApplicationPlatform() { AppName = "SCM", Platform = ePlatformType.Web, Description = "New application" }); mGR.BusinessFlows.Add(mBF); string path = Path.Combine(TestResources.GetTestResourcesFolder(@"Solutions" + Path.DirectorySeparatorChar + "BasicSimple")); SR = GingerSolutionRepository.CreateGingerSolutionRepository(); SR.Open(path); }
public void TestBusinessFlowVariableSyncWithRepo() { string variableName = "BFV1"; string initialValue = "123"; string updatedValue = "abc123"; mBF = new BusinessFlow() { Name = "TestBFVarSync", Active = true }; VariableString V1 = new VariableString() { Name = variableName, InitialStringValue = initialValue }; mBF.AddVariable(V1); // add business flow to the solution repository mSolutionRepository.AddRepositoryItem(mBF); // prepare to add the variable to the shared repository UploadItemSelection uploadItemSelection = new UploadItemSelection() { UsageItem = V1, ItemUploadType = UploadItemSelection.eItemUploadType.New }; (new SharedRepositoryOperations()).UploadItemToRepository(new Context() { BusinessFlow = mBF }, uploadItemSelection); // find the newly added variable from the shared repo VariableBase sharedVariableBase = (from x in mSolutionRepository.GetAllRepositoryItems <VariableBase>() where x.Name == variableName select x).SingleOrDefault(); VariableString sharedV1 = (VariableString)sharedVariableBase; //update the new value in the shared repo variable sharedV1.InitialStringValue = updatedValue; //sync the updated instance with the business flow instance sharedV1.UpdateInstance(V1, "All", mBF); // get the updated value from the business flow VariableString V2 = (VariableString)mBF.Variables[0]; //Assert Assert.AreEqual(1, mBF.Variables.Count); Assert.AreNotSame(V1, V2); Assert.AreEqual(updatedValue, V2.InitialStringValue); }
public void VBS_CalcWithVars() { //Arrange //mBF.Variables.Add(new VariableString() { Name= "Param1", Value="5"}); //mBF.Variables.Add(new VariableString() { Name = "Param2", Value = "3" }); mBF.AddVariable(new VariableString() { Name = "Param1", Value = "5" }); mBF.AddVariable(new VariableString() { Name = "Param2", Value = "3" }); ValueExpression VE = new ValueExpression(mEnv, mBF); VE.Value = "{VBS Eval={Var Name=Param1} + {Var Name=Param2}}"; //Act string v = VE.ValueCalculated; //Assert Assert.AreEqual(v, "8"); }
public static void ClassInit(TestContext context) { AutoLogProxy.Init("Unit Tests"); mBF = new BusinessFlow(); mBF.Activities = new ObservableList <Activity>(); mBF.Name = "BF Test Fire Fox"; mBF.Active = true; Platform p = new Platform(); p.PlatformType = ePlatformType.Web; mBF.Platforms = new ObservableList <Platform>(); mBF.Platforms.Add(p); mBF.TargetApplications.Add(new TargetApplication() { AppName = "SCM" }); VariableString v1 = new VariableString() { Name = "v1", InitialStringValue = "1" }; mBF.AddVariable(v1); mGR = new GingerRunner(); mGR.CurrentSolution = new Ginger.Environments.Solution(); Agent a = new Agent(); //a.DriverType = Agent.eDriverType.SeleniumFireFox;//have knowen firefox issues with selenium 3 a.DriverType = Agent.eDriverType.SeleniumChrome; mGR.SolutionAgents = new ObservableList <Agent>(); mGR.SolutionAgents.Add(a); // p2.Agent = a; mGR.ApplicationAgents.Add(new ApplicationAgent() { AppName = "SCM", Agent = a }); mGR.SolutionApplications = new ObservableList <ApplicationPlatform>(); mGR.SolutionApplications.Add(new ApplicationPlatform() { AppName = "SCM", Platform = ePlatformType.Web, Description = "New application" }); mGR.BusinessFlows.Add(mBF); }
public static void ClassInit(TestContext context) { string solutionfolder = TestResources.GetTempFolder("GingerVariableTests"); WorkspaceHelper.CreateWorkspaceWithTempSolution(solutionfolder); mBF = new BusinessFlow(); mBF.Activities = new ObservableList <Activity>(); mBF.Name = "BF Test Fire Fox"; mBF.Active = true; Platform p = new Platform(); p.PlatformType = ePlatformType.Web; mBF.TargetApplications.Add(new TargetApplication() { AppName = "SCM" }); VariableString busFlowV1 = new VariableString() { Name = "BFV1", InitialStringValue = "1" }; mBF.AddVariable(busFlowV1); mGR = new GingerRunner(); mGR.CurrentSolution = new Ginger.SolutionGeneral.Solution(); Agent a = new Agent(); a.AgentType = Agent.eAgentType.Service; // Simple agent which anyhow we don't need to start for this test and will work on Linux mGR.SolutionAgents = new ObservableList <Agent>(); mGR.SolutionAgents.Add(a); mGR.ApplicationAgents.Add(new ApplicationAgent() { AppName = "SCM", Agent = a }); mGR.SolutionApplications = new ObservableList <ApplicationPlatform>(); mGR.SolutionApplications.Add(new ApplicationPlatform() { AppName = "SCM", Platform = ePlatformType.Web, Description = "New application" }); mGR.BusinessFlows.Add(mBF); }
public void TestInitialize() { mBF = new BusinessFlow(); mBF.Activities = new ObservableList <Activity>(); mBF.Name = "BF Status Result Test"; mBF.Active = true; Platform p = new Platform(); p.PlatformType = ePlatformType.Web; mBF.Platforms = new ObservableList <Platform>(); mBF.Platforms.Add(p); mBF.TargetApplications.Add(new TargetApplication() { AppName = "SCM" }); VariableString v1 = new VariableString() { Name = "v1", InitialStringValue = "1" }; mBF.AddVariable(v1); mGR = new GingerRunner(); mGR.CurrentSolution = new Ginger.SolutionGeneral.Solution(); mGR.GiveUserFeedback = true; Agent a = new Agent(); a.DriverType = Agent.eDriverType.SeleniumChrome; mGR.SolutionAgents = new ObservableList <Agent>(); mGR.SolutionAgents.Add(a); mGR.SolutionApplications = new ObservableList <ApplicationPlatform>(); mGR.SolutionApplications.Add(new ApplicationPlatform() { AppName = "SCM", Platform = ePlatformType.Web }); mGR.ApplicationAgents.Add(new ApplicationAgent() { AppName = "SCM", Agent = a }); mGR.BusinessFlows.Add(mBF); }
public static void ClassInit(TestContext context) { AutoLogProxy.Init("Unit Tests"); RepositoryItemHelper.RepositoryItemFactory = new RepositoryItemFactory(); mBF = new BusinessFlow(); mBF.Activities = new ObservableList <Activity>(); mBF.Name = "BF Test Chrome"; mBF.Active = true; Platform p = new Platform(); p.PlatformType = ePlatformType.Web; mBF.TargetApplications.Add(new TargetApplication() { AppName = "WebApp" }); VariableString v1 = new VariableString() { Name = "v1", InitialStringValue = "1" }; mBF.AddVariable(v1); mGR = new GingerRunner(); mGR.CurrentSolution = new Ginger.SolutionGeneral.Solution(); Agent a = new Agent(); a.DriverType = Agent.eDriverType.SeleniumChrome; mGR.SolutionAgents = new ObservableList <Agent>(); mGR.SolutionAgents.Add(a); mGR.ApplicationAgents.Add(new ApplicationAgent() { AppName = "WebApp", Agent = a }); mGR.SolutionApplications = new ObservableList <ApplicationPlatform>(); mGR.SolutionApplications.Add(new ApplicationPlatform() { AppName = "WebApp", Platform = ePlatformType.Web, Description = "New application" }); mGR.BusinessFlows.Add(mBF); }
public static void ClassInit(TestContext context) { TargetFrameworkHelper.Helper = new DotNetFrameworkHelper(); mBF = new BusinessFlow(); mBF.Activities = new ObservableList <Activity>(); mBF.Name = "BF Test Chrome"; mBF.Active = true; Platform p = new Platform(); p.PlatformType = ePlatformType.Web; mBF.TargetApplications.Add(new TargetApplication() { AppName = "WebApp" }); VariableString v1 = new VariableString() { Name = "v1", InitialStringValue = "1" }; mBF.AddVariable(v1); mGR = new GingerRunner(); mGR.Executor.CurrentSolution = new Ginger.SolutionGeneral.Solution(); Agent a = new Agent(); a.DriverType = Agent.eDriverType.SeleniumChrome; ((GingerExecutionEngine)mGR.Executor).SolutionAgents = new ObservableList <Agent>(); ((GingerExecutionEngine)mGR.Executor).SolutionAgents.Add(a); mGR.ApplicationAgents.Add(new ApplicationAgent() { AppName = "WebApp", Agent = a }); mGR.Executor.SolutionApplications = new ObservableList <ApplicationPlatform>(); mGR.Executor.SolutionApplications.Add(new ApplicationPlatform() { AppName = "WebApp", Platform = ePlatformType.Web, Description = "New application" }); mGR.Executor.BusinessFlows.Add(mBF); }
public void BackUpRestore() { //Arrange int ActivitiesToCreate = 5; string BizFlowName = "Biz flow Back/Rest"; string BizFlowDescription = "Desc Back/Rest tester"; BusinessFlow BF = new BusinessFlow() { Name = BizFlowName }; BF.Status = BusinessFlow.eBusinessFlowStatus.Development; BF.Activities = new ObservableList <Activity>(); ObservableList <Activity> OriginalActivitiesObj = BF.Activities; for (int i = 1; i <= ActivitiesToCreate; i++) { Activity a = new Activity() { ActivityName = "Activity " + i, Description = "desc" + i, Status = eRunStatus.Passed }; BF.AddActivity(a); } // Create Activity to check ref Activity a6 = new Activity() { ActivityName = "a6" }; BF.Activities.Add(a6); // Add one action to make sure backup drill down, and restore the ref item not a copy ActGotoURL act1 = new ActGotoURL(); act1.Description = "Goto URL 1"; a6.Acts.Add(act1); //add action with input/output vals act1.InputValues = new ObservableList <ActInputValue>(); string firstInputValName = "Param1"; ActInputValue firstInputVal = new ActInputValue() { Param = firstInputValName }; act1.InputValues.Add(firstInputVal); act1.InputValues.Add(new ActInputValue() { Param = "Param2" }); //add flow control act1.FlowControls = new ObservableList <FlowControl>(); act1.FlowControls.Add(new GingerCore.FlowControlLib.FlowControl() { Condition = "A=B", FlowControlAction = eFlowControlAction.GoToActivity }); eFlowControlAction secondFlowControlAction = eFlowControlAction.RerunAction; GingerCore.FlowControlLib.FlowControl secondFlowControl = new GingerCore.FlowControlLib.FlowControl() { Condition = "C>123", FlowControlAction = secondFlowControlAction }; act1.FlowControls.Add(secondFlowControl); act1.FlowControls.Add(new GingerCore.FlowControlLib.FlowControl() { Condition = "D=111", FlowControlAction = eFlowControlAction.StopRun }); //BF Variables VariableString v = new VariableString(); v.Name = "Var1"; v.Description = "VDesc 1"; BF.AddVariable(v); VariableSelectionList sl = new VariableSelectionList(); sl.Name = "Var 2"; sl.OptionalValuesList = new ObservableList <OptionalValue>(); sl.OptionalValuesList.Add(new OptionalValue("11")); sl.OptionalValuesList.Add(new OptionalValue("22")); sl.OptionalValuesList.Add(new OptionalValue("33")); BF.AddVariable(sl); // BF.SaveBackup(); BF.SaveBackup(); //Erase/Modify some stuff BF.Name = "zzzz"; BF.Description = BizFlowDescription; BF.Status = BusinessFlow.eBusinessFlowStatus.Retired; BF.Activities[1].Description = "AAAA"; BF.Activities.Remove(BF.Activities[2]); BF.Activities.Remove(BF.Activities[3]); act1.Description = "ZZZZZ"; act1.InputValues[0].Param = "qqq"; act1.InputValues.Remove(act1.InputValues[1]); act1.FlowControls[1].FlowControlAction = eFlowControlAction.MessageBox; act1.FlowControls.Add(new GingerCore.FlowControlLib.FlowControl() { Condition = "Val=123" }); act1.FlowControls.Add(new GingerCore.FlowControlLib.FlowControl() { Condition = "Val=555" }); sl.OptionalValuesList[0].Value = "aaaa"; sl.OptionalValuesList.Add(new OptionalValue("44")); sl.OptionalValuesList.Add(new OptionalValue("55")); // BF.RestoreFromBackup(); BF.RestoreFromBackup(); // Assert Assert.AreEqual(BF.Name, BizFlowName, "BF.Name"); Assert.AreEqual(BF.Description, null, "BF.Description"); // check enum restore Assert.AreEqual(BF.Status, BusinessFlow.eBusinessFlowStatus.Development, "BF.Status"); Assert.AreEqual(BF.Activities.Count(), ActivitiesToCreate + 1, "BF.Activities.Count()"); //check original list ref obj Assert.AreEqual(BF.Activities, OriginalActivitiesObj, "BF.Activities REF"); Assert.AreEqual(BF.Activities[0].Description, "desc1", "BF.Activities[0].Description"); Assert.AreEqual(BF.Activities[5].ActivityName, "a6", "BF.Activities[5].ActivityName"); // Check original action ref is back Assert.AreEqual(BF.Activities[5], a6, "BF.Activities[5] REF"); Assert.AreEqual(act1.Description, "Goto URL 1", "act1.Description"); Assert.AreEqual(a6.Acts[0], act1, "a6.Acts[0]"); //check Action input values Assert.AreEqual(act1.InputValues.Count, 2, "act1.InputValues.Count"); Assert.AreEqual(act1.InputValues[0], firstInputVal, "act1.InputValues[0] REF"); Assert.AreEqual(act1.InputValues[0].Param, firstInputValName, "act1.InputValues[0].Param"); //check Action flow control Assert.AreEqual(act1.FlowControls.Count, 3, "act1.FlowControls.Count"); Assert.AreEqual(act1.FlowControls[1], secondFlowControl, "act1.FlowControls[1] REF"); Assert.AreEqual(act1.FlowControls[1].FlowControlAction, secondFlowControlAction, "act1.FlowControls[1].FlowControlAction"); //BF variables Assert.AreEqual(BF.Variables.Count, 2, "BF.Variables.Count"); Assert.AreEqual(BF.Variables[1], sl, "BF.Variables[0] REF"); Assert.AreEqual(((VariableSelectionList)BF.Variables[1]).OptionalValuesList[0].Value, "11", "BF.Variables[0].Value"); }
public static void ClassInit(TestContext context) { mBF = new BusinessFlow(); mBF.Name = "BF Test Fire Fox"; mBF.Active = true; Activity activity = new Activity(); mBF.AddActivity(activity); ActDummy action1 = new ActDummy(); ActDummy action2 = new ActDummy(); mBF.Activities[0].Acts.Add(action1); mBF.Activities[0].Acts.Add(action2); Platform p = new Platform(); p.PlatformType = ePlatformType.Web; mBF.TargetApplications.Add(new TargetApplication() { AppName = "SCM" }); VariableString v1 = new VariableString() { Name = "v1", InitialStringValue = "1" }; mBF.AddVariable(v1); mGR = new GingerRunner(); mGR.Name = "Test Runner"; mGR.CurrentSolution = new Ginger.SolutionGeneral.Solution(); mGR.CurrentBusinessFlow = mBF; mGR.CurrentBusinessFlow.CurrentActivity = mBF.Activities[0]; environment = new ProjEnvironment(); environment.Name = "Default"; mBF.Environment = environment.Name; mGR.ProjEnvironment = environment; Agent a = new Agent(); //a.DriverType = Agent.eDriverType.SeleniumFireFox;//have known firefox issues with selenium 3 a.DriverType = Agent.eDriverType.SeleniumChrome; mGR.SolutionAgents = new ObservableList <Agent>(); mGR.SolutionAgents.Add(a); // p2.Agent = a; mGR.ApplicationAgents.Add(new ApplicationAgent() { AppName = "SCM", Agent = a }); mGR.SolutionApplications = new ObservableList <ApplicationPlatform>(); mGR.SolutionApplications.Add(new ApplicationPlatform() { AppName = "SCM", Platform = ePlatformType.Web, Description = "New application" }); mGR.BusinessFlows.Add(mBF); mGR.SpecificEnvironmentName = environment.Name; mGR.UseSpecificEnvironment = false; string path = Path.Combine(TestResources.GetTestResourcesFolder(@"Solutions" + Path.DirectorySeparatorChar + "BasicSimple")); string solutionFile = System.IO.Path.Combine(path, @"Ginger.Solution.xml"); solution = Solution.LoadSolution(solutionFile); SR = GingerSolutionRepository.CreateGingerSolutionRepository(); SR.Open(path); WorkSpace.Instance.Solution = solution; WorkSpace.Instance.Solution.LoggerConfigurations.CalculatedLoggerFolder = WorkSpace.Instance.Solution.LoggerConfigurations.ExecutionLoggerConfigurationExecResultsFolder; }
public BusinessFlow ConvertQCTestSetToBF(QC.ALMTestSet testSet) { GingerActivitiesGroupsRepo = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <ActivitiesGroup>(); GingerActivitiesRepo = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <Activity>(); try { if (testSet == null) { return(null); } //Create Business Flow BusinessFlow busFlow = new BusinessFlow(); busFlow.Name = testSet.TestSetName; busFlow.ExternalID = testSet.TestSetID; busFlow.Status = BusinessFlow.eBusinessFlowStatus.Development; busFlow.Activities = new ObservableList <Activity>(); busFlow.Variables = new ObservableList <VariableBase>(); Dictionary <string, string> busVariables = new Dictionary <string, string>();//will store linked variables //Create Activities Group + Activities for each TC foreach (QC.ALMTSTest tc in testSet.Tests) { //check if the TC is already exist in repository ActivitiesGroup tcActivsGroup; ActivitiesGroup repoActivsGroup = null; if (repoActivsGroup == null) { repoActivsGroup = GingerActivitiesGroupsRepo.Where(x => x.ExternalID == tc.TestID).FirstOrDefault(); } if (repoActivsGroup != null) { List <Activity> repoNotExistsStepActivity = GingerActivitiesRepo.Where(z => repoActivsGroup.ActivitiesIdentifiers.Select(y => y.ActivityExternalID).ToList().Contains(z.ExternalID)) .Where(x => !tc.Steps.Select(y => y.StepID).ToList().Contains(x.ExternalID)).ToList(); tcActivsGroup = (ActivitiesGroup)repoActivsGroup.CreateInstance(); var ActivitySIdentifiersToRemove = tcActivsGroup.ActivitiesIdentifiers.Where(x => repoNotExistsStepActivity.Select(z => z.ExternalID).ToList().Contains(x.ActivityExternalID)); for (int indx = 0; indx < tcActivsGroup.ActivitiesIdentifiers.Count; indx++) { if ((indx < tcActivsGroup.ActivitiesIdentifiers.Count) && (ActivitySIdentifiersToRemove.Contains(tcActivsGroup.ActivitiesIdentifiers[indx]))) { tcActivsGroup.ActivitiesIdentifiers.Remove(tcActivsGroup.ActivitiesIdentifiers[indx]); indx--; } } tcActivsGroup.ExternalID2 = tc.TestID; busFlow.AddActivitiesGroup(tcActivsGroup); busFlow.ImportActivitiesGroupActivitiesFromRepository(tcActivsGroup, GingerActivitiesRepo, ApplicationPlatforms, true); busFlow.AttachActivitiesGroupsAndActivities(); } else //TC not exist in Ginger repository so create new one { tcActivsGroup = new ActivitiesGroup(); tcActivsGroup.Name = tc.TestName; tcActivsGroup.ExternalID = tc.TestID; tcActivsGroup.ExternalID2 = tc.LinkedTestID; tcActivsGroup.Description = tc.Description; busFlow.AddActivitiesGroup(tcActivsGroup); } //Add the TC steps as Activities if not already on the Activities group foreach (QC.ALMTSTestStep step in tc.Steps) { Activity stepActivity; bool toAddStepActivity = false; //check if mapped activity exist in repository Activity repoStepActivity = (Activity)GingerActivitiesRepo.Where(x => x.ExternalID == step.StepID).FirstOrDefault(); if (repoStepActivity != null) { //check if it is part of the Activities Group ActivityIdentifiers groupStepActivityIdent = (ActivityIdentifiers)tcActivsGroup.ActivitiesIdentifiers.Where(x => x.ActivityExternalID == step.StepID).FirstOrDefault(); if (groupStepActivityIdent != null) { //already in Activities Group so get link to it stepActivity = (Activity)busFlow.Activities.Where(x => x.Guid == groupStepActivityIdent.ActivityGuid).FirstOrDefault(); // in any case update description/expected/name - even if "step" was taken from repository stepActivity.Description = StripHTML(step.Description); stepActivity.Expected = StripHTML(step.Expected); stepActivity.ActivityName = tc.TestName + ">" + step.StepName; } else//not in ActivitiesGroup so get instance from repo { stepActivity = (Activity)repoStepActivity.CreateInstance(); toAddStepActivity = true; } } else//Step not exist in Ginger repository so create new one { stepActivity = new Activity(); stepActivity.ActivityName = tc.TestName + ">" + step.StepName; stepActivity.ExternalID = step.StepID; stepActivity.Description = StripHTML(step.Description); toAddStepActivity = true; } if (toAddStepActivity) { //not in group- need to add it busFlow.AddActivity(stepActivity, tcActivsGroup); } //pull TC-Step parameters and add them to the Activity level List <string> stepParamsList = new List <string>(); foreach (string param in stepParamsList) { //get the param value string paramSelectedValue = string.Empty; bool? isflowControlParam = null; QC.ALMTSTestParameter tcParameter = tc.Parameters.Where(x => x.Name.ToUpper() == param.ToUpper()).FirstOrDefault(); //get the param value if (tcParameter != null && tcParameter.Value != null && tcParameter.Value != string.Empty) { paramSelectedValue = tcParameter.Value; } else { isflowControlParam = null;//empty value paramSelectedValue = "<Empty>"; } //check if parameter is part of a link string linkedVariable = null; if (paramSelectedValue.StartsWith("#$#")) { string[] valueParts = paramSelectedValue.Split(new [] { "#$#" }, StringSplitOptions.None); if (valueParts.Count() == 3) { linkedVariable = valueParts[1]; paramSelectedValue = "$$_" + valueParts[2];//so it still will be considered as non-flow control if (!busVariables.Keys.Contains(linkedVariable)) { busVariables.Add(linkedVariable, valueParts[2]); } } } //determine if the param is Flow Control Param or not based on it value and agreed sign "$$_" if (paramSelectedValue.StartsWith("$$_")) { isflowControlParam = false; if (paramSelectedValue.StartsWith("$$_")) { paramSelectedValue = paramSelectedValue.Substring(3);//get value without "$$_" } } else if (paramSelectedValue != "<Empty>") { isflowControlParam = true; } //check if already exist param with that name VariableBase stepActivityVar = stepActivity.Variables.Where(x => x.Name.ToUpper() == param.ToUpper()).FirstOrDefault(); if (stepActivityVar == null) { //#Param not exist so add it if (isflowControlParam == true) { //add it as selection list param stepActivityVar = new VariableSelectionList(); stepActivityVar.Name = param; stepActivity.AddVariable(stepActivityVar); stepActivity.AutomationStatus = eActivityAutomationStatus.Development;//reset status because new flow control param was added } else { //add as String param stepActivityVar = new VariableString(); stepActivityVar.Name = param; ((VariableString)stepActivityVar).InitialStringValue = paramSelectedValue; stepActivity.AddVariable(stepActivityVar); } } else { //#param exist if (isflowControlParam == true) { if (!(stepActivityVar is VariableSelectionList)) { //flow control param must be Selection List so transform it stepActivity.Variables.Remove(stepActivityVar); stepActivityVar = new VariableSelectionList(); stepActivityVar.Name = param; stepActivity.AddVariable(stepActivityVar); stepActivity.AutomationStatus = eActivityAutomationStatus.Development;//reset status because flow control param was added } } else if (isflowControlParam == false) { if (stepActivityVar is VariableSelectionList) { //change it to be string variable stepActivity.Variables.Remove(stepActivityVar); stepActivityVar = new VariableString(); stepActivityVar.Name = param; ((VariableString)stepActivityVar).InitialStringValue = paramSelectedValue; stepActivity.AddVariable(stepActivityVar); stepActivity.AutomationStatus = eActivityAutomationStatus.Development;//reset status because flow control param was removed } } } //add the variable selected value if (stepActivityVar is VariableSelectionList) { OptionalValue stepActivityVarOptionalVar = ((VariableSelectionList)stepActivityVar).OptionalValuesList.Where(x => x.Value == paramSelectedValue).FirstOrDefault(); if (stepActivityVarOptionalVar == null) { //no such variable value option so add it stepActivityVarOptionalVar = new OptionalValue(paramSelectedValue); ((VariableSelectionList)stepActivityVar).OptionalValuesList.Add(stepActivityVarOptionalVar); if (isflowControlParam == true) { stepActivity.AutomationStatus = eActivityAutomationStatus.Development;//reset status because new param value was added } } //set the selected value ((VariableSelectionList)stepActivityVar).SelectedValue = stepActivityVarOptionalVar.Value; } else { //try just to set the value try { stepActivityVar.Value = paramSelectedValue; if (stepActivityVar is VariableString) { ((VariableString)stepActivityVar).InitialStringValue = paramSelectedValue; } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}", ex); } } //add linked variable if needed if (!string.IsNullOrEmpty(linkedVariable)) { stepActivityVar.LinkedVariableName = linkedVariable; } else { stepActivityVar.LinkedVariableName = string.Empty;//clear old links } } } //order the Activities Group activities according to the order of the matching steps in the TC try { int startGroupActsIndxInBf = 0; if (busFlow.Activities.Count > 0) { startGroupActsIndxInBf = busFlow.Activities.IndexOf(tcActivsGroup.ActivitiesIdentifiers[0].IdentifiedActivity); } foreach (QC.ALMTSTestStep step in tc.Steps) { int stepIndx = tc.Steps.IndexOf(step) + 1; ActivityIdentifiers actIdent = (ActivityIdentifiers)tcActivsGroup.ActivitiesIdentifiers.Where(x => x.ActivityExternalID == step.StepID).FirstOrDefault(); if (actIdent == null || actIdent.IdentifiedActivity == null) { break;//something wrong- shouldn't be null } Activity act = (Activity)actIdent.IdentifiedActivity; int groupActIndx = tcActivsGroup.ActivitiesIdentifiers.IndexOf(actIdent); int bfActIndx = busFlow.Activities.IndexOf(act); //set it in the correct place in the group int numOfSeenSteps = 0; int groupIndx = -1; foreach (ActivityIdentifiers ident in tcActivsGroup.ActivitiesIdentifiers) { groupIndx++; if (string.IsNullOrEmpty(ident.ActivityExternalID) || tc.Steps.Where(x => x.StepID == ident.ActivityExternalID).FirstOrDefault() == null) { continue;//activity which not originally came from the TC } numOfSeenSteps++; if (numOfSeenSteps >= stepIndx) { break; } } ActivityIdentifiers identOnPlace = (ActivityIdentifiers)tcActivsGroup.ActivitiesIdentifiers[groupIndx]; if (identOnPlace.ActivityGuid != act.Guid) { //replace places in group tcActivsGroup.ActivitiesIdentifiers.Move(groupActIndx, groupIndx); //replace places in business flow busFlow.Activities.Move(bfActIndx, startGroupActsIndxInBf + groupIndx); } } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}", ex); //failed to re order the activities to match the tc steps order, not worth breaking the import because of this } } //Add the BF variables (linked variables) if (busVariables.Keys.Count > 0) { foreach (KeyValuePair <string, string> var in busVariables) { //add as String param VariableString busVar = new VariableString(); busVar.Name = var.Key; busVar.InitialStringValue = var.Value; busFlow.AddVariable(busVar); } } return(busFlow); } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Failed to import QC test set and convert it into " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow), ex); return(null); } }