/// <summary> /// Rebuilds the parameters. /// </summary> /// <param name="script">The script.</param> /// <param name="dynamicBDDComponents">The dynamic BDD components.</param> /// <param name="runnerBusinessLogicData">The runner business logic data.</param> private void RebuildParameters(BDDExtensionRunner script, Component[] dynamicBDDComponents, RunnerEditorBusinessLogicData runnerBusinessLogicData) { // Generate the three list of MethodDescription for each step type: Given, When, Then MethodsManagementUtilities methodsManagementUtilities = new MethodsManagementUtilities(); BaseMethodDescriptionBuilder methodBuilder = new BaseMethodDescriptionBuilder(); IMethodsFilter givenMethodFilter = new MethodsFilterByMethodsFullNameList(script.Given); MethodsLoader givenMethodsLoader = new MethodsLoader(methodBuilder, givenMethodFilter); MethodDescriptionBuilder methodDescriptionBuilder = new MethodDescriptionBuilder(); FullMethodDescriptionBuilder fullMethodDescriptionBuilder = new FullMethodDescriptionBuilder(); MethodParametersLoader methodsParametersLoader = new MethodParametersLoader(); List <MethodDescription> givenMethodsDescriptionList = methodsManagementUtilities.LoadMethodsDescriptionsFromChosenMethods <GivenBaseAttribute>(dynamicBDDComponents, givenMethodsLoader, methodDescriptionBuilder, methodsParametersLoader, script.Given, script.GivenParametersIndex); List <FullMethodDescription> givenFullMethodsDescriptionList = methodsManagementUtilities.LoadFullMethodsDescriptions <GivenBaseAttribute>(givenMethodsDescriptionList, fullMethodDescriptionBuilder); IMethodsFilter whenMethodFilter = new MethodsFilterByMethodsFullNameList(script.When); MethodsLoader whenMethodsLoader = new MethodsLoader(methodBuilder, whenMethodFilter); List <MethodDescription> whenMethodsDescriptionList = methodsManagementUtilities.LoadMethodsDescriptionsFromChosenMethods <WhenBaseAttribute>(dynamicBDDComponents, whenMethodsLoader, methodDescriptionBuilder, methodsParametersLoader, script.When, script.WhenParametersIndex); List <FullMethodDescription> whenFullMethodsDescriptionList = methodsManagementUtilities.LoadFullMethodsDescriptions <WhenBaseAttribute>(whenMethodsDescriptionList, fullMethodDescriptionBuilder); IMethodsFilter thenMethodFilter = new MethodsFilterByMethodsFullNameList(script.Then); MethodsLoader thenMethodsLoader = new MethodsLoader(methodBuilder, thenMethodFilter); List <MethodDescription> thenMethodsDescriptionList = methodsManagementUtilities.LoadMethodsDescriptionsFromChosenMethods <ThenBaseAttribute>(dynamicBDDComponents, thenMethodsLoader, methodDescriptionBuilder, methodsParametersLoader, script.Then, script.ThenParametersIndex); List <FullMethodDescription> thenFullMethodsDescriptionList = methodsManagementUtilities.LoadFullMethodsDescriptions <ThenBaseAttribute>(thenMethodsDescriptionList, fullMethodDescriptionBuilder); // Reset the valuesArrayStorages for each component ArrayStorageUtilities arrayStorageUtilities = new ArrayStorageUtilities(); arrayStorageUtilities.ResetAllArrayStorage(dynamicBDDComponents); // Rebuild the parameters indexes and locations for each list of MethodDescription RunnerEditorBusinessLogicParametersLocationsBuilder parametersLocationsBuilder = new RunnerEditorBusinessLogicParametersLocationsBuilder(); parametersLocationsBuilder.BuildParametersLocation(givenFullMethodsDescriptionList); parametersLocationsBuilder.BuildParametersLocation(whenFullMethodsDescriptionList); parametersLocationsBuilder.BuildParametersLocation(thenFullMethodsDescriptionList); // Rebuild the parameters Indexes arrays script.GivenParametersIndex = parametersLocationsBuilder.RebuildParametersIndexesArrays(givenFullMethodsDescriptionList, script.Given); script.WhenParametersIndex = parametersLocationsBuilder.RebuildParametersIndexesArrays(whenFullMethodsDescriptionList, script.When); script.ThenParametersIndex = parametersLocationsBuilder.RebuildParametersIndexesArrays(thenFullMethodsDescriptionList, script.Then); }
public void RebuildParametersIndexesArrays_Should_ReturnTheExpectedParametersIndexesArrays_Given_TheValuesInTheFullmethodDescriptionObjectAreChanged() { RunnerEditorBusinessLogicParametersLocationsBuilder parametersLocationsBuilder = new RunnerEditorBusinessLogicParametersLocationsBuilder(); BaseMethodDescriptionBuilder metodBuilder = new BaseMethodDescriptionBuilder(); string[] givenMethodsFullNamesList = new string[1] { "RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.GivenMethod" }; string[] givenParametersIndexes = new string[1] { ";System.String,RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.GivenMethod.stringParam.,stringPVS.Array.data[2]" }; string[] whenMethodsFullNamesList = new string[2] { "RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.WhenMethod", "RunnerEditorBusinessLogicParametersLocationsBuilderUTSecondDynamicBDDForTest.SecondWhenMethod" }; string[] whenParametersIndexes = new string[2] { ";System.String,RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.WhenMethod.whenStringParam.,stringPVS.Array.data[3]" + ";System.Int32,RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.WhenMethod.whenIntParam.,intPVS.Array.data[2]", ";System.String,RunnerEditorBusinessLogicParametersLocationsBuilderUTSecondDynamicBDDForTest.SecondWhenMethod.whenStringParam.,stringPVS.Array.data[1]" }; RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest firstDynamicBDDComponent = UnitTestUtility.CreateComponent <RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest>(); RunnerEditorBusinessLogicParametersLocationsBuilderUTSecondDynamicBDDForTest secondDynamicBDDComponent = UnitTestUtility.CreateComponent <RunnerEditorBusinessLogicParametersLocationsBuilderUTSecondDynamicBDDForTest>(); Component[] components = new Component[2] { secondDynamicBDDComponent, firstDynamicBDDComponent }; string[] stringArray = new string[4] { string.Empty, string.Empty, "GivenStringParamFirstClass", "WhenStringParamFirstClass" }; this.SetPVSAndReturnFieldInfo(firstDynamicBDDComponent, typeof(string), stringArray); int[] intArray = new int[3] { -1, -1, 103 }; this.SetPVSAndReturnFieldInfo(firstDynamicBDDComponent, typeof(int), intArray); stringArray = new string[4] { string.Empty, "SecondWhenMethodSecondClass", string.Empty, string.Empty }; this.SetPVSAndReturnFieldInfo(secondDynamicBDDComponent, typeof(string), stringArray); intArray = null; this.SetPVSAndReturnFieldInfo(secondDynamicBDDComponent, typeof(int), intArray); IMethodsFilter methodFilterForGivenList = new MethodsFilterByMethodsFullNameList(givenMethodsFullNamesList); IMethodsFilter methodFilterForWhenList = new MethodsFilterByMethodsFullNameList(whenMethodsFullNamesList); MethodsLoader methodsLoaderForGivenMethods = new MethodsLoader(metodBuilder, methodFilterForGivenList); MethodsLoader methodsLoaderForWhenMethods = new MethodsLoader(metodBuilder, methodFilterForWhenList); MethodsManagementUtilities methodsManagementUtilities = new MethodsManagementUtilities(); MethodDescriptionBuilder methodDescriptionBuilder = new MethodDescriptionBuilder(); MethodParametersLoader methodParametersLoader = new MethodParametersLoader(); List <MethodDescription> givenMethodsDescriptionsList = methodsManagementUtilities.LoadMethodsDescriptionsFromChosenMethods <GivenBaseAttribute>(components, methodsLoaderForGivenMethods, methodDescriptionBuilder, methodParametersLoader, givenMethodsFullNamesList, givenParametersIndexes); List <MethodDescription> whenMethodsDescriptionsList = methodsManagementUtilities.LoadMethodsDescriptionsFromChosenMethods <WhenBaseAttribute>(components, methodsLoaderForWhenMethods, methodDescriptionBuilder, methodParametersLoader, whenMethodsFullNamesList, whenParametersIndexes); this.SetPVSAndReturnFieldInfo(firstDynamicBDDComponent, typeof(string), new string[0]); this.SetPVSAndReturnFieldInfo(firstDynamicBDDComponent, typeof(int), new int[0]); this.SetPVSAndReturnFieldInfo(secondDynamicBDDComponent, typeof(string), new string[0]); this.SetPVSAndReturnFieldInfo(secondDynamicBDDComponent, typeof(int), new int[0]); FullMethodDescriptionBuilder fullMethodDescriptionBuilder = new FullMethodDescriptionBuilder(); List <FullMethodDescription> givenFullMethodsDescriptionsList = fullMethodDescriptionBuilder.Build(givenMethodsDescriptionsList[0], 1); parametersLocationsBuilder.BuildParametersLocation(givenFullMethodsDescriptionsList); List <FullMethodDescription> whenFullMethodsDescriptionsList = fullMethodDescriptionBuilder.Build(whenMethodsDescriptionsList[0], 1); whenFullMethodsDescriptionsList.AddRange(fullMethodDescriptionBuilder.Build(whenMethodsDescriptionsList[1], 2)); parametersLocationsBuilder.BuildParametersLocation(whenFullMethodsDescriptionsList); string[] newGivenIndexes = parametersLocationsBuilder.RebuildParametersIndexesArrays(givenFullMethodsDescriptionsList, givenMethodsFullNamesList); string[] newWhenIndexes = parametersLocationsBuilder.RebuildParametersIndexesArrays(whenFullMethodsDescriptionsList, whenMethodsFullNamesList); Assert.AreEqual(";System.String,RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.GivenMethod.stringParam.,stringPVS.Array.data[0]", newGivenIndexes[0], "The method RebuildParametersIndexesArrays does not rebuild the parametersIndexArray correctly"); Assert.AreEqual( ";System.String,RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.WhenMethod.whenStringParam.,stringPVS.Array.data[1]" + ";System.Int32,RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.WhenMethod.whenIntParam.,intPVS.Array.data[0]", newWhenIndexes[0], "The method RebuildParametersIndexesArrays does not rebuild the parametersIndexArray correctly"); Assert.AreEqual(";System.String,RunnerEditorBusinessLogicParametersLocationsBuilderUTSecondDynamicBDDForTest.SecondWhenMethod.whenStringParam.,stringPVS.Array.data[0]", newWhenIndexes[1], "The method RebuildParametersIndexesArrays does not rebuild the parametersIndexArray correctly"); }