コード例 #1
0
        public void LoadMethodsDescriptionsFromChosenMethods_Should_ReturnTheExpectedMethodDescriptionObjects_Given_ADynamicComponentAndAListOfChosenMethods()
        {
            MethodsManagementUtilities methodsManagementUtilities = new MethodsManagementUtilities();
            MethodsManagementUtilitiesTestFirstDynamicComponent  bddComponent1 = UnitTestUtility.CreateComponent <MethodsManagementUtilitiesTestFirstDynamicComponent>();
            MethodsManagementUtilitiesTestSecondDynamicComponent bddComponent2 = UnitTestUtility.CreateComponent <MethodsManagementUtilitiesTestSecondDynamicComponent>();

            ArrayStorageUtilities arrayStorageUtilities   = new ArrayStorageUtilities();
            FieldInfo             firstStringArrayStorage = arrayStorageUtilities.GetArrayStorageFieldInfoByType(bddComponent1, typeof(string));

            firstStringArrayStorage.SetValue(bddComponent1, new string[1] {
                "Parameter For The MethodsManagementUtilitiesTestFirstDynamicComponent.GivenMethod"
            });

            FieldInfo secondStringArrayStorage = arrayStorageUtilities.GetArrayStorageFieldInfoByType(bddComponent2, typeof(string));

            secondStringArrayStorage.SetValue(bddComponent2, new string[1] {
                "Parameter For The MethodsManagementUtilitiesTestSecondDynamicComponent.GivenMethod"
            });

            Component[] dynamicBDDComponents = new Component[2] {
                bddComponent1, bddComponent2
            };

            BaseMethodDescriptionBuilder methodBuilder = new BaseMethodDescriptionBuilder();

            string[] chosenMethods = new string[2] {
                "MethodsManagementUtilitiesTestSecondDynamicComponent.GivenMethod", "MethodsManagementUtilitiesTestFirstDynamicComponent.GivenMethod"
            };
            IMethodsFilter           methodFilter             = new MethodsFilterByMethodsFullNameList(chosenMethods);
            MethodsLoader            methodsLoader            = new MethodsLoader(methodBuilder, methodFilter);
            MethodDescriptionBuilder methodDescriptionBuilder = new MethodDescriptionBuilder();
            MethodParametersLoader   methodParametersLoader   = new MethodParametersLoader();

            string[] chosenMethodsParametersIndexes = new string[2] {
                ";string,MethodsManagementUtilitiesTestSecondDynamicComponent.GivenMethod.stringParam.,stringPVS.Array.data[0];", ";string,MethodsManagementUtilitiesTestFirstDynamicComponent.GivenMethod.stringParam.,stringPVS.Array.data[0];"
            };

            List <MethodDescription> methodDescriptionList = methodsManagementUtilities.LoadMethodsDescriptionsFromChosenMethods <GivenBaseAttribute>(dynamicBDDComponents, methodsLoader, methodDescriptionBuilder, methodParametersLoader, chosenMethods, chosenMethodsParametersIndexes);

            Assert.AreEqual(2, methodDescriptionList.Count, "The method LoadMethodsDescriptionsFromChosenMethods doesn't return the expected amount of Method Descriptions");
            MethodDescription expectedMethodDescription1 = null;
            MethodDescription expectedMethodDescription2 = null;

            if (chosenMethods[0].Equals(methodDescriptionList[0].Method.DeclaringType.Name + "." + methodDescriptionList[0].Method.Name))
            {
                expectedMethodDescription1 = methodDescriptionList[0];
                expectedMethodDescription2 = methodDescriptionList[1];
            }
            else
            {
                expectedMethodDescription1 = methodDescriptionList[1];
                expectedMethodDescription2 = methodDescriptionList[0];
            }

            Assert.AreEqual(chosenMethods[0], expectedMethodDescription1.GetFullName(), "The method LoadMethodsDescriptionsFromChosenMethods doesn't return the expected methods");
            Assert.AreEqual(chosenMethods[1], expectedMethodDescription2.GetFullName(), "The method LoadMethodsDescriptionsFromChosenMethods doesn't return the expected methods");
        }
コード例 #2
0
        /// <summary>
        /// Builds the static scenario.
        /// </summary>
        /// <param name="bddComponents">The BDD components.</param>
        private void BuildStaticScenario(Component[] bddComponents)
        {
            BaseMethodDescriptionBuilder  baseMethodDescriptionBuilder  = new BaseMethodDescriptionBuilder();
            MethodsFilterByExecutionOrder methodsFilterByExecutionOrder = new MethodsFilterByExecutionOrder();
            MethodsLoader bddStepMethodsLoader = new MethodsLoader(baseMethodDescriptionBuilder, methodsFilterByExecutionOrder);

            this.businessLogicStaticRows.DrawStaticRows <GivenBaseAttribute>(this.unityIntefaceWrapper, bddStepMethodsLoader, bddComponents, RunnerEditorBusinessLogicData.LabelWidthAbsolute, RunnerEditorBusinessLogicData.ButtonsWidthAbsolute);
            this.businessLogicStaticRows.DrawStaticRows <WhenBaseAttribute>(this.unityIntefaceWrapper, bddStepMethodsLoader, bddComponents, RunnerEditorBusinessLogicData.LabelWidthAbsolute, RunnerEditorBusinessLogicData.ButtonsWidthAbsolute);
            this.businessLogicStaticRows.DrawStaticRows <ThenBaseAttribute>(this.unityIntefaceWrapper, bddStepMethodsLoader, bddComponents, RunnerEditorBusinessLogicData.LabelWidthAbsolute, RunnerEditorBusinessLogicData.ButtonsWidthAbsolute);
        }
        public void LoadStepMethods_Should_ReturnAnEmptyListOfBaseMethodDescriptionObjects_GivenADynamicComponentWithoutWhenMethodsLoadingWhenMethods()
        {
            Component[] components = new Component[1] {
                UnitTestUtility.CreateComponent <MethodsLoaderTestDynamicComponent>()
            };
            BaseMethodDescriptionBuilder baseMethodDescriptionBuilder = new BaseMethodDescriptionBuilder();
            MethodsFilterByStepType      methodsFilterByStepType      = new MethodsFilterByStepType();
            MethodsLoader bddStepMethodsLoader   = new MethodsLoader(baseMethodDescriptionBuilder, methodsFilterByStepType);
            List <BaseMethodDescription> methods = bddStepMethodsLoader.LoadStepMethods <WhenBaseAttribute>(components);

            Assert.AreEqual(0, methods.Count, "The BDDStepMethodsFilter.FilterAllStepMethods method doesn't return the expected amount of elements");
        }
        public void DrawStaticRows_Should_CallTheRightUnityEditoStatements_Given_AStaticComponentWithTwoWhenMethods()
        {
            Component[] bddComponents = new Component[1] {
                UnitTestUtility.CreateComponent <RunnerEditorBusinessLogicStaticRowsTestStaticComponent>()
            };

            IUnityInterfaceWrapper unityInterface = Substitute.For <IUnityInterfaceWrapper>();

            unityInterface.EditorGUIUtilityCurrentViewWidth().Returns <float>(500F);

            BaseMethodDescriptionBuilder methodBuilder = Substitute.For <BaseMethodDescriptionBuilder>();

            BaseMethodDescriptionBuilder  baseMethodDescriptionBuilder  = new BaseMethodDescriptionBuilder();
            MethodsFilterByExecutionOrder methodsFilterByExecutionOrder = new MethodsFilterByExecutionOrder();
            MethodsLoader bddStepMethodsLoader = new MethodsLoader(baseMethodDescriptionBuilder, methodsFilterByExecutionOrder);
            List <BaseMethodDescription> baseMethodDescriptionList = bddStepMethodsLoader.LoadStepMethods <WhenBaseAttribute>(bddComponents);
            MethodInfo whenMethodInfo       = typeof(RunnerEditorBusinessLogicStaticRowsTestStaticComponent).GetMethod("WhenMethod");
            MethodInfo secondWhenMethodInfo = typeof(RunnerEditorBusinessLogicStaticRowsTestStaticComponent).GetMethod("SecondWhenMethod");

            methodBuilder.Build <WhenBaseAttribute>(bddComponents[0], whenMethodInfo).Returns <BaseMethodDescription>(baseMethodDescriptionList[0]);

            methodBuilder.Build <WhenBaseAttribute>(bddComponents[0], secondWhenMethodInfo).Returns <BaseMethodDescription>(baseMethodDescriptionList[1]);

            IMethodsFilter methodFilter = Substitute.For <IMethodsFilter>();

            methodFilter.Filter <WhenBaseAttribute>(whenMethodInfo).Returns(true);
            methodFilter.Filter <WhenBaseAttribute>(secondWhenMethodInfo).Returns(true);

            object[] constructorArguments = new object[2] {
                new BaseMethodDescriptionBuilder(), new MethodsFilterByExecutionOrder()
            };
            MethodsLoader stepMethodsLoader = Substitute.For <MethodsLoader>(constructorArguments);

            stepMethodsLoader.LoadStepMethods <WhenBaseAttribute>(bddComponents).Returns(baseMethodDescriptionList);
            RunnerEditorBusinessLogicStaticRows runnerEditorBusinessLogicStaticRows = new RunnerEditorBusinessLogicStaticRows();

            runnerEditorBusinessLogicStaticRows.DrawStaticRows <WhenBaseAttribute>(unityInterface, stepMethodsLoader, bddComponents, RunnerEditorBusinessLogicData.LabelWidthAbsolute, RunnerEditorBusinessLogicData.ButtonsWidthAbsolute);
            Received.InOrder(() =>
            {
                unityInterface.EditorGUILayoutBeginHorizontal();
                unityInterface.EditorGUIUtilityCurrentViewWidth();
                unityInterface.EditorGUILayoutLabelField("When", RunnerEditorBusinessLogicData.LabelWidthAbsolute);
                unityInterface.EditorGUILayoutLabelField("When method", 368);
                unityInterface.EditorGUILayoutEndHorizontal();

                unityInterface.EditorGUILayoutBeginHorizontal();
                unityInterface.EditorGUIUtilityCurrentViewWidth();
                unityInterface.EditorGUILayoutLabelField("and", RunnerEditorBusinessLogicData.LabelWidthAbsolute);
                unityInterface.EditorGUILayoutLabelField("Second When method", 368);
                unityInterface.EditorGUILayoutEndHorizontal();
            });
        }
        public void LoadStepMethods_Should_ReturnAnEmptyList_Given_AStaticComponentWithARepetedExecutionOrderValue()
        {
            Component[] components = new Component[1] {
                UnitTestUtility.CreateComponent <MethodsLoaderTestThirdStaticComponent>()
            };

            BaseMethodDescriptionBuilder baseMethodDescriptionBuilder = new BaseMethodDescriptionBuilder();
            MethodsFilterByStepType      methodsFilterByStepType      = new MethodsFilterByStepType();
            MethodsLoader bddStepMethodsLoader  = new MethodsLoader(baseMethodDescriptionBuilder, methodsFilterByStepType);
            List <BaseMethodDescription> result = bddStepMethodsLoader.LoadStepMethods <GivenBaseAttribute>(components);

            Assert.AreEqual(0, result.Count, "The method LoadStepMethods does not return the right list.");
        }
コード例 #6
0
        /// <summary>
        /// Gets list of <see cref="FullMethodDescription"/> objects inside a Static Component.
        /// </summary>
        /// <typeparam name="T">The type of the Step Method.</typeparam>
        /// <param name="bddComponents">The BDD components.</param>
        /// <param name="methodsManagementUtilities">The methods management utilities.</param>
        /// <returns>The list of <see cref="FullMethodDescription"/> objects inside a Static Component.</returns>
        public List <FullMethodDescription> GetAllStaticFullMethodsDescriptions <T>(Component[] bddComponents, MethodsManagementUtilities methodsManagementUtilities) where T : IGivenWhenThenDeclaration
        {
            List <FullMethodDescription>  result = null;
            BaseMethodDescriptionBuilder  baseMethodDescriptionBuilder  = new BaseMethodDescriptionBuilder();
            MethodsFilterByExecutionOrder methodsFilterByExecutionOrder = new MethodsFilterByExecutionOrder();
            MethodsLoader bddStepMethodsLoader       = new MethodsLoader(baseMethodDescriptionBuilder, methodsFilterByExecutionOrder);
            List <BaseMethodDescription> methodsList = bddStepMethodsLoader.LoadStepMethods <T>(bddComponents);
            FullMethodDescriptionBuilder fullMethodDescriptionBuilder = new FullMethodDescriptionBuilder();

            result = methodsManagementUtilities.LoadFullMethodsDescriptions <T>(methodsList, fullMethodDescriptionBuilder);

            return(result);
        }
コード例 #7
0
        public void GetMethodDescriptionForTheChosenMethod_Should_ReturnTheExpectedMethodDescriptionObject_Given_ADynamicComponentAndTheMethodFullNameAndTheParametersIndexes()
        {
            MethodDescriptionBuilder methodDescriptionBuilder = Substitute.For <MethodDescriptionBuilder>();

            MethodParametersLoader parametersLoader = Substitute.For <MethodParametersLoader>();

            RunnerEditorBusinessLogicMethodsUtilitiesTestDynamicComponent component = UnitTestUtility.CreateComponent <RunnerEditorBusinessLogicMethodsUtilitiesTestDynamicComponent>();

            ArrayStorageUtilities arrayStorageUtilities   = new ArrayStorageUtilities();
            FieldInfo             firstStringArrayStorage = arrayStorageUtilities.GetArrayStorageFieldInfoByType(component, typeof(string));

            firstStringArrayStorage.SetValue(component, new string[2] {
                "FirstValue", "SecondValue"
            });

            FieldInfo firstIntArrayStorage = arrayStorageUtilities.GetArrayStorageFieldInfoByType(component, typeof(int));

            firstIntArrayStorage.SetValue(component, new int[2] {
                33, 14
            });

            MethodInfo             method                 = component.GetType().GetMethod("WhenMethod");
            string                 parametersIndex        = ";string,RunnerEditorBusinessLogicMethodsUtilitiesTestDynamicComponent.WhenMethod.whenStringParam.,stringPVS.Array.data[0];int,RunnerEditorBusinessLogicMethodsUtilitiesTestDynamicComponent.WhenMethod.whenIntParam.,intPVS.Array.data[0];";
            MethodParametersLoader methodParametersLoader = new MethodParametersLoader();
            MethodParameters       methodParameters       = methodParametersLoader.LoadMethodParameters(component, method, string.Empty, parametersIndex);

            parametersLoader.LoadMethodParameters(component, method, string.Empty, parametersIndex).Returns(methodParameters);

            BaseMethodDescriptionBuilder baseMethodDescriptionBuilder = new BaseMethodDescriptionBuilder();
            BaseMethodDescription        baseMethodDescription        = baseMethodDescriptionBuilder.Build <WhenBaseAttribute>(component, method);

            MethodDescriptionBuilder methodDescriptionBuilderInstance = new MethodDescriptionBuilder();
            MethodDescription        methodDescription = methodDescriptionBuilderInstance.Build(parametersLoader, baseMethodDescription, parametersIndex);

            methodDescriptionBuilder.Build(parametersLoader, baseMethodDescription, parametersIndex).Returns(methodDescription);

            string chosenMethodName                 = "RunnerEditorBusinessLogicMethodsUtilitiesTestDynamicComponent.WhenMethod";
            string chosenMethodParametersIndex      = parametersIndex;
            List <BaseMethodDescription> methodList = new List <BaseMethodDescription>();

            methodList.Add(baseMethodDescriptionBuilder.Build <WhenBaseAttribute>(component, component.GetType().GetMethod("SecondWhenMethod")));
            methodList.Add(baseMethodDescriptionBuilder.Build <WhenBaseAttribute>(component, component.GetType().GetMethod("WhenMethod")));
            methodList.Add(baseMethodDescriptionBuilder.Build <WhenBaseAttribute>(component, component.GetType().GetMethod("ThirdWhenMethod")));

            RunnerEditorBusinessLogicMethodsUtilities methodsUtilities = new RunnerEditorBusinessLogicMethodsUtilities();
            MethodDescription result = methodsUtilities.GetMethodDescriptionForTheChosenMethod(methodDescriptionBuilder, parametersLoader, chosenMethodName, chosenMethodParametersIndex, methodList);

            Assert.IsTrue(methodDescription.Equals(result), "The method UnityTestToolsBDDExtensionRunnerEditorBusinessLogic.GetMethodDescriptionForTheChosenMethod doesn't return the right object");
        }
コード例 #8
0
        public void BuildParametersLocation_Should_LoadTheExpectedValuesForTheParametersAndBuildTheExpectedParametersIndexes_Given_AFullMethodDescriptionListOnASIngleDynamicComponentOnASingleMethodWithACallBeforeAttibute()
        {
            RunnerEditorBusinessLogicParametersLocationsBuilder parametersLocationsBuilder = new RunnerEditorBusinessLogicParametersLocationsBuilder();

            BaseMethodDescriptionBuilder metodBuilder = new BaseMethodDescriptionBuilder();

            string[] methodsFullNamesList = new string[1] {
                "RunnerEditorBusinessLogicParametersLocationsBuilderUTDynamicCallBeforeParameters.SecondWhenMethod"
            };
            string[] parametersIndexes = new string[1] {
                ";System.String,RunnerEditorBusinessLogicParametersLocationsBuilderUTDynamicCallBeforeParameters.SecondWhenMethod.whenStringParam.,stringPVS.Array.data[2];System.String,RunnerEditorBusinessLogicParametersLocationsBuilderUTDynamicCallBeforeParameters.GivenMethod.stringParam.,stringPVS.Array.data[3]"
            };
            IMethodsFilter methodFilter  = new MethodsFilterByMethodsFullNameList(methodsFullNamesList);
            MethodsLoader  methodsLoader = new MethodsLoader(metodBuilder, methodFilter);
            RunnerEditorBusinessLogicParametersLocationsBuilderUTDynamicCallBeforeParameters firstDynamicBDDComponent = UnitTestUtility.CreateComponent <RunnerEditorBusinessLogicParametersLocationsBuilderUTDynamicCallBeforeParameters>();

            Component[] components = new Component[1] {
                firstDynamicBDDComponent
            };
            string secondWhenMethodParam = "String Value for the parameter SecondWhenMethod";
            string givenMethodParam      = "String Value for the parameter GivenMethod";

            string[] stringArray = new string[4] {
                string.Empty, string.Empty, secondWhenMethodParam, givenMethodParam
            };
            FieldInfo stringPVS = this.SetPVSAndReturnFieldInfo(firstDynamicBDDComponent, typeof(string), stringArray);

            MethodsManagementUtilities methodsManagementUtilities = new MethodsManagementUtilities();
            MethodDescriptionBuilder   methodDescriptionBuilder   = new MethodDescriptionBuilder();
            MethodParametersLoader     methodParametersLoader     = new MethodParametersLoader();
            List <MethodDescription>   methodsDescriptionsList    = methodsManagementUtilities.LoadMethodsDescriptionsFromChosenMethods <WhenBaseAttribute>(components, methodsLoader, methodDescriptionBuilder, methodParametersLoader, methodsFullNamesList, parametersIndexes);

            FullMethodDescriptionBuilder fullMethodDescriptionBuilder = new FullMethodDescriptionBuilder();
            List <FullMethodDescription> fullMethodsDescriptionsList  = fullMethodDescriptionBuilder.Build(methodsDescriptionsList[0], 1);

            stringArray = new string[0];
            stringPVS   = this.SetPVSAndReturnFieldInfo(firstDynamicBDDComponent, typeof(string), stringArray);

            parametersLocationsBuilder.BuildParametersLocation(fullMethodsDescriptionsList);

            Array currentStringPVS = stringPVS.GetValue(firstDynamicBDDComponent) as Array;

            Assert.AreEqual(2, currentStringPVS.Length, "The method BuildParametersLocation doesn't build the ParameterArrayStorage properly");
            Assert.That(givenMethodParam.Equals(currentStringPVS.GetValue(0)), "The method BuildParametersLocation doesn't build the ParameterArrayStorage properly");
            Assert.That(secondWhenMethodParam.Equals(currentStringPVS.GetValue(1)), "The method BuildParametersLocation doesn't build the ParameterArrayStorage properly");

            Assert.AreEqual(";System.String,RunnerEditorBusinessLogicParametersLocationsBuilderUTDynamicCallBeforeParameters.GivenMethod.stringParam.,stringPVS.Array.data[0];System.String,RunnerEditorBusinessLogicParametersLocationsBuilderUTDynamicCallBeforeParameters.SecondWhenMethod.whenStringParam.,stringPVS.Array.data[1]", fullMethodsDescriptionsList[1].ParametersIndex, "The method BuildParametersLocation doesn't build the parametersIndex properly");
        }
コード例 #9
0
        /// <summary>
        /// Gets the list of <see cref="FullMethodDescription"/> objects to run for a Dynamic Scenario.
        /// </summary>
        /// <typeparam name="T">The type of the Step Method to filter.</typeparam>
        /// <param name="components">The components.</param>
        /// <param name="methodsManagementUtilities">The methods management utilities.</param>
        /// <param name="methodsFullNamesList">The methods full names list.</param>
        /// <param name="methodsParametersList">The methods parameters list.</param>
        /// <returns>The list of <see cref="FullMethodDescription"/> objects to run for a Dynamic Scenario.</returns>
        private List <FullMethodDescription> GetAllDynamicFullMethodsDescriptions <T>(Component[] components, MethodsManagementUtilities methodsManagementUtilities, string[] methodsFullNamesList, string[] methodsParametersList) where T : IGivenWhenThenDeclaration
        {
            List <FullMethodDescription>       result = null;
            BaseMethodDescriptionBuilder       baseMethodDescriptionBuilder       = new BaseMethodDescriptionBuilder();
            MethodsFilterByMethodsFullNameList methodsFilterByMethodsFullNameList = new MethodsFilterByMethodsFullNameList(methodsFullNamesList);
            MethodsLoader bddStepMethodsLoader = new MethodsLoader(baseMethodDescriptionBuilder, methodsFilterByMethodsFullNameList);

            MethodDescriptionBuilder methodDescriptionBuilder = new MethodDescriptionBuilder();
            MethodParametersLoader   methodParametersLoader   = new MethodParametersLoader();
            List <MethodDescription> methodsList = methodsManagementUtilities.LoadMethodsDescriptionsFromChosenMethods <T>(components, bddStepMethodsLoader, methodDescriptionBuilder, methodParametersLoader, methodsFullNamesList, methodsParametersList);

            FullMethodDescriptionBuilder fullMethodDescriptionBuilder = new FullMethodDescriptionBuilder();

            result = methodsManagementUtilities.LoadFullMethodsDescriptions <T>(methodsList, fullMethodDescriptionBuilder);

            return(result);
        }
コード例 #10
0
        /// <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 Build_Should_ReturnTheExpectedBaseMethodDescriptionObject_Given_ADynamicComponentAndASimpleGivenMethod()
        {
            BaseMethodDescriptionBuilderTestDynamicComponent component = UnitTestUtility.CreateComponent<BaseMethodDescriptionBuilderTestDynamicComponent>();
            MethodInfo methodInfo = component.GetType().GetMethod("GivenMethod");

            BaseMethodDescription expectedBaseMethodDescription = new BaseMethodDescription();
            expectedBaseMethodDescription.ComponentObject = component;
            expectedBaseMethodDescription.Method = methodInfo;
            expectedBaseMethodDescription.StepType = typeof(GivenBaseAttribute);
            expectedBaseMethodDescription.Text = ((IGivenWhenThenDeclaration)methodInfo.GetCustomAttributes(typeof(GivenBaseAttribute), true)[0]).GetStepScenarioText();
            expectedBaseMethodDescription.ExecutionOrder = ((IGivenWhenThenDeclaration)methodInfo.GetCustomAttributes(typeof(GivenBaseAttribute), true)[0]).GetExecutionOrder();

            BaseMethodDescriptionBuilder baseMethodDescriptionBuilder = new BaseMethodDescriptionBuilder();
            BaseMethodDescription builderResult = baseMethodDescriptionBuilder.Build<GivenBaseAttribute>(component, methodInfo);

            Assert.IsTrue(expectedBaseMethodDescription.Equals(builderResult), "The method BaseMethodDescriptionBuilder.Build does not return the expected object");
            Assert.AreEqual(expectedBaseMethodDescription.Text, builderResult.Text, "The method BaseMethodDescriptionBuilder.Build does not return the expected Text");
        }
        public void LoadStepMethods_Should_ReturnTheExpectedListOfBaseMethodDescriptionObjects_Given_ADynamicComponentWithTwoThenMethodsLoadingThenMethods()
        {
            Component[] components = new Component[1] {
                UnitTestUtility.CreateComponent <MethodsLoaderTestDynamicComponent>()
            };
            BaseMethodDescription expectedMethod1 = new BaseMethodDescription();

            expectedMethod1.ComponentObject = components[0];
            expectedMethod1.Method          = components[0].GetType().GetMethod("ThenMethod");
            expectedMethod1.StepType        = typeof(ThenBaseAttribute);
            expectedMethod1.Text            = ((IGivenWhenThenDeclaration)expectedMethod1.Method.GetCustomAttributes(typeof(ThenBaseAttribute), true)[0]).GetStepScenarioText();
            expectedMethod1.ExecutionOrder  = ((IGivenWhenThenDeclaration)expectedMethod1.Method.GetCustomAttributes(typeof(ThenBaseAttribute), true)[0]).GetExecutionOrder();

            BaseMethodDescription expectedMethod2 = new BaseMethodDescription();

            expectedMethod2.ComponentObject = components[0];
            expectedMethod2.Method          = components[0].GetType().GetMethod("SecondThenMethod");
            expectedMethod2.StepType        = typeof(ThenBaseAttribute);
            expectedMethod2.Text            = ((IGivenWhenThenDeclaration)expectedMethod2.Method.GetCustomAttributes(typeof(ThenBaseAttribute), true)[0]).GetStepScenarioText();
            expectedMethod2.ExecutionOrder  = ((IGivenWhenThenDeclaration)expectedMethod2.Method.GetCustomAttributes(typeof(ThenBaseAttribute), true)[0]).GetExecutionOrder();

            BaseMethodDescriptionBuilder baseMethodDescriptionBuilder = new BaseMethodDescriptionBuilder();
            MethodsFilterByStepType      methodsFilterByStepType      = new MethodsFilterByStepType();
            MethodsLoader bddStepMethodsLoader   = new MethodsLoader(baseMethodDescriptionBuilder, methodsFilterByStepType);
            List <BaseMethodDescription> methods = bddStepMethodsLoader.LoadStepMethods <ThenBaseAttribute>(components);

            Assert.AreEqual(2, methods.Count, "The BDDStepMethodsFilter.FilterAllStepMethods method doesn't return the expected amount of elements");
            BaseMethodDescription returnedMethod1 = null;
            BaseMethodDescription returnedMethod2 = null;

            if (methods[0].Method.Name.Equals(expectedMethod1.Method.Name))
            {
                returnedMethod1 = methods[0];
                returnedMethod2 = methods[1];
            }
            else
            {
                returnedMethod1 = methods[1];
                returnedMethod2 = methods[2];
            }

            Assert.IsTrue(expectedMethod1.Equals(returnedMethod1), "The BDDStepMethodsFilter.FilterAllStepMethods method doesn't return the expected Method Object");
            Assert.IsTrue(expectedMethod2.Equals(returnedMethod2), "The BDDStepMethodsFilter.FilterAllStepMethods method doesn't return the expected Method Object");
        }
コード例 #13
0
        /// <summary>
        /// Builds the dynamic scenario.
        /// </summary>
        /// <param name="script">The script.</param>
        /// <param name="bddComponents">The BDD components.</param>
        /// <param name="lockParametersRows">If set to <c>true</c> [lock parameters rows].</param>
        /// <param name="dirtyStatus">If set to <c>true</c> [dirty status].</param>
        private void BuildDynamicScenario(BDDExtensionRunner script, Component[] bddComponents, bool lockParametersRows, out bool dirtyStatus)
        {
            bool   givenDirtyStatus = false;
            bool   whenDirtyStatus  = false;
            bool   thenDirtyStatus  = false;
            string undoText;
            MethodParametersLoader parametersLoader = new MethodParametersLoader();
            RunnerEditorBusinessLogicMethodsUtilities    methodsUtilities    = new RunnerEditorBusinessLogicMethodsUtilities();
            RunnerEditorBusinessLogicDynamicRowsElements dynamicRowsElements = new RunnerEditorBusinessLogicDynamicRowsElements();
            BaseMethodDescriptionBuilder baseMethodDescriptionBuilder        = new BaseMethodDescriptionBuilder();
            MethodDescriptionBuilder     methodDescriptionBuilder            = new MethodDescriptionBuilder();
            IMethodsFilter methodFilter  = new MethodsFilterByStepType();
            MethodsLoader  methodsLoader = new MethodsLoader(baseMethodDescriptionBuilder, methodFilter);

            ChosenMethods chosenMethods = new ChosenMethods();

            chosenMethods.ChosenMethodsNames           = script.Given;
            chosenMethods.ChosenMethodsParametersIndex = script.GivenParametersIndex;

            this.runnerBusinessLogicData.Rebuild = this.businessLogicDynamicRows.DrawDynamicRows <GivenBaseAttribute>(this.unityIntefaceWrapper, methodsLoader, methodDescriptionBuilder, parametersLoader, bddComponents, chosenMethods, this.runnerBusinessLogicData.GivenFoldouts, this.runnerBusinessLogicData.SerializedObjects, script, methodsUtilities, dynamicRowsElements, lockParametersRows, this.runnerBusinessLogicData.Rebuild, out chosenMethods, out this.runnerBusinessLogicData.GivenFoldouts, out givenDirtyStatus, out undoText);
            this.RegisterUndoInformation(this.target, bddComponents, undoText);
            script.Given = chosenMethods.ChosenMethodsNames;
            script.GivenParametersIndex = chosenMethods.ChosenMethodsParametersIndex;

            chosenMethods.ChosenMethodsNames           = script.When;
            chosenMethods.ChosenMethodsParametersIndex = script.WhenParametersIndex;

            this.runnerBusinessLogicData.Rebuild = this.businessLogicDynamicRows.DrawDynamicRows <WhenBaseAttribute>(this.unityIntefaceWrapper, methodsLoader, methodDescriptionBuilder, parametersLoader, bddComponents, chosenMethods, this.runnerBusinessLogicData.WhenFoldouts, this.runnerBusinessLogicData.SerializedObjects, script, methodsUtilities, dynamicRowsElements, lockParametersRows, this.runnerBusinessLogicData.Rebuild, out chosenMethods, out this.runnerBusinessLogicData.WhenFoldouts, out whenDirtyStatus, out undoText);
            this.RegisterUndoInformation(this.target, bddComponents, undoText);

            script.When = chosenMethods.ChosenMethodsNames;
            script.WhenParametersIndex = chosenMethods.ChosenMethodsParametersIndex;

            chosenMethods.ChosenMethodsNames           = script.Then;
            chosenMethods.ChosenMethodsParametersIndex = script.ThenParametersIndex;
            this.runnerBusinessLogicData.Rebuild       = this.businessLogicDynamicRows.DrawDynamicRows <ThenBaseAttribute>(this.unityIntefaceWrapper, methodsLoader, methodDescriptionBuilder, parametersLoader, bddComponents, chosenMethods, this.runnerBusinessLogicData.ThenFoldouts, this.runnerBusinessLogicData.SerializedObjects, script, methodsUtilities, dynamicRowsElements, lockParametersRows, this.runnerBusinessLogicData.Rebuild, out chosenMethods, out this.runnerBusinessLogicData.ThenFoldouts, out thenDirtyStatus, out undoText);
            this.RegisterUndoInformation(this.target, bddComponents, undoText);

            script.Then = chosenMethods.ChosenMethodsNames;
            script.ThenParametersIndex = chosenMethods.ChosenMethodsParametersIndex;

            dirtyStatus = givenDirtyStatus || whenDirtyStatus || thenDirtyStatus;
        }
コード例 #14
0
        public void GetMethodsNames_Should_ReturnTheExpectedArrayOfStringsContainingTheFullNamesOfTheMethods_Given_ALIstOfBaseMethodDescriptionObjects()
        {
            string[]    expectedResult = new string[3];
            Component[] components     = new Component[1] {
                UnitTestUtility.CreateComponent <RunnerEditorBusinessLogicMethodsUtilitiesTestDynamicComponent>()
            };
            BaseMethodDescriptionBuilder baseMethodDescriptionBuilder = new BaseMethodDescriptionBuilder();
            MethodsFilterByStepType      methodsFilterByStepType      = new MethodsFilterByStepType();
            MethodsLoader bddStepMethodsLoader       = new MethodsLoader(baseMethodDescriptionBuilder, methodsFilterByStepType);
            List <BaseMethodDescription> methodsList = bddStepMethodsLoader.LoadStepMethods <WhenBaseAttribute>(components);

            expectedResult[0] = methodsList[0].GetFullName();
            expectedResult[1] = methodsList[1].GetFullName();
            expectedResult[2] = methodsList[2].GetFullName();
            RunnerEditorBusinessLogicMethodsUtilities methodsUtilities = new RunnerEditorBusinessLogicMethodsUtilities();

            string[] result = methodsUtilities.GetMethodsNames(methodsList);
            Assert.AreEqual(expectedResult, result, "The method UnityTestToolsBDDExtensionRunnerEditorBusinessLogic.GetMethodsNames doesn't return the right list of methods names.");
        }
コード例 #15
0
        public void LoadFullMethodsDescriptions_Should_ReturnTheExpectedListOfFullMethodDescriptionObjects_Given_AListOfMethodDescriptionObjectsOfMethodsContainingCallBeforeAttributes()
        {
            // Create the MethodDescription
            MethodsManagementUtilitiesUTDynamicBDDForTestForCallBeforeMethodsList component = UnitTestUtility.CreateComponent <MethodsManagementUtilitiesUTDynamicBDDForTestForCallBeforeMethodsList>();

            MethodInfo mainMethodInfo = component.GetType().GetMethod("SecondThenMethod");
            MethodDescriptionBuilder     methodDescriptionBuilder     = new MethodDescriptionBuilder();
            MethodParametersLoader       methodParametersLoader       = new MethodParametersLoader();
            BaseMethodDescriptionBuilder baseMethodDescriptionBuilder = new BaseMethodDescriptionBuilder();
            BaseMethodDescription        mainBaseMethodDescription    = baseMethodDescriptionBuilder.Build <ThenBaseAttribute>(component, mainMethodInfo);
            string            parametersIndex = string.Empty;
            MethodDescription firstChosenMethodDescription = methodDescriptionBuilder.Build(methodParametersLoader, mainBaseMethodDescription, parametersIndex);

            // Create the expected FullMethodDescription
            MethodInfo                   firstCallBeforeMethodInfo             = component.GetType().GetMethod("ThenMethod");
            BaseMethodDescription        firstCallBeforeBaseMethodDescription  = baseMethodDescriptionBuilder.Build <ThenBaseAttribute>(component, firstCallBeforeMethodInfo);
            MethodDescription            secondChosenMethodDescription         = methodDescriptionBuilder.Build(methodParametersLoader, firstCallBeforeBaseMethodDescription, parametersIndex);
            FullMethodDescriptionBuilder fullMethodDescriptionBuilder          = new FullMethodDescriptionBuilder();
            List <FullMethodDescription> firstChosenFullMethodDescriptionsList = fullMethodDescriptionBuilder.BuildFromBaseMethodDescription(firstChosenMethodDescription, 1);
            List <FullMethodDescription> seconChosenFullMethodDescriptionsList = fullMethodDescriptionBuilder.BuildFromBaseMethodDescription(secondChosenMethodDescription, 2);
            List <FullMethodDescription> expectedFullMethodDescriptionsList    = new List <FullMethodDescription>();

            expectedFullMethodDescriptionsList.AddRange(firstChosenFullMethodDescriptionsList);
            expectedFullMethodDescriptionsList.AddRange(seconChosenFullMethodDescriptionsList);

            // Build the fullMethodDescription
            List <MethodDescription> methodsDescriptionsList = new List <MethodDescription>();

            methodsDescriptionsList.Add(firstChosenMethodDescription);
            methodsDescriptionsList.Add(secondChosenMethodDescription);
            MethodsManagementUtilities   methodsManagementUtilities = new MethodsManagementUtilities();
            List <FullMethodDescription> result = methodsManagementUtilities.LoadFullMethodsDescriptions <ThenBaseAttribute>(methodsDescriptionsList, fullMethodDescriptionBuilder);

            // Compare the FullMethodDescriptions
            Assert.AreEqual(6, result.Count, "The method build doesn't return the right number of element in the list");
            Assert.AreEqual(expectedFullMethodDescriptionsList[0], result[0], "The method build doesn't return the right fullMethodDescription");
            Assert.AreEqual(expectedFullMethodDescriptionsList[1], result[1], "The method build doesn't return the right fullMethodDescription");
            Assert.AreEqual(expectedFullMethodDescriptionsList[2], result[2], "The method build doesn't return the right fullMethodDescription");
            Assert.AreEqual(expectedFullMethodDescriptionsList[3], result[3], "The method build doesn't return the right fullMethodDescription");
            Assert.AreEqual(expectedFullMethodDescriptionsList[4], result[4], "The method build doesn't return the right fullMethodDescription");
            Assert.AreEqual(expectedFullMethodDescriptionsList[5], result[5], "The method build doesn't return the right fullMethodDescription");
        }
コード例 #16
0
        public void LoadFullMethodsDescriptions_Should_LoadParametersForTheCallBeforeMethod_When_TheParameterIndexOfTheMainMethodDescriptionIsProperlySet()
        {
            // Create the MethodDescription
            MethodsManagementUtilitiesTestThirdDynamicComponent component = UnitTestUtility.CreateComponent <MethodsManagementUtilitiesTestThirdDynamicComponent>();

            MethodInfo mainMethodInfo = component.GetType().GetMethod("SecondGivenMethod");
            MethodDescriptionBuilder     methodDescriptionBuilder     = new MethodDescriptionBuilder();
            MethodParametersLoader       methodParametersLoader       = new MethodParametersLoader();
            BaseMethodDescriptionBuilder baseMethodDescriptionBuilder = new BaseMethodDescriptionBuilder();
            FullMethodDescriptionBuilder fullMethodDescriptionBuilder = new FullMethodDescriptionBuilder();

            BaseMethodDescription mainBaseMethodDescription = baseMethodDescriptionBuilder.Build <GivenBaseAttribute>(component, mainMethodInfo);
            string parametersIndex = ";System.String,MethodsManagementUtilitiesUTDynamicCallBeforeParameterLoad.SecondGivenMethod.stringParam.,stringPVS.Array.data[0]" +
                                     ";System.String,MethodsManagementUtilitiesUTDynamicCallBeforeParameterLoad.GivenMethod.stringParam.,stringPVS.Array.data[1]";
            ArrayStorageUtilities arrayStorageUtilities = new ArrayStorageUtilities();
            FieldInfo             stringPVS             = arrayStorageUtilities.GetArrayStorageFieldInfoByType(component, typeof(string));

            string[] stringArray = new string[2] {
                "FirstElementForTheMainMethod", "SecondElementForTheCallBeforeMethod"
            };
            stringPVS.SetValue(component, stringArray);

            MethodDescription mainMethodDescription = methodDescriptionBuilder.Build(methodParametersLoader, mainBaseMethodDescription, parametersIndex);

            // Creating the expected FullMethodDescription list
            MethodInfo callBeforeMethodInfo = component.GetType().GetMethod("GivenMethod");
            List <FullMethodDescription> expectedFullMethodDescriptionsList = fullMethodDescriptionBuilder.Build(mainMethodDescription, 1);

            expectedFullMethodDescriptionsList[0].Parameters = methodParametersLoader.LoadMethodParameters(component, callBeforeMethodInfo, string.Empty, parametersIndex);

            // Executing LoadFullMethodsDescriptions
            List <MethodDescription> methodsDescriptionsList = new List <MethodDescription>();

            methodsDescriptionsList.Add(mainMethodDescription);
            MethodsManagementUtilities   methodsManagementUtilities = new MethodsManagementUtilities();
            List <FullMethodDescription> result = methodsManagementUtilities.LoadFullMethodsDescriptions <GivenBaseAttribute>(methodsDescriptionsList, fullMethodDescriptionBuilder);

            // Compare the FullMethodDescriptions
            Assert.AreEqual(2, result.Count, "The method build doesn't return the right number of element in the list");
            Assert.AreEqual(expectedFullMethodDescriptionsList[0], result[0], "The method build doesn't return the right fullMethodDescription");
            Assert.AreEqual(expectedFullMethodDescriptionsList[1], result[1], "The method build doesn't return the right fullMethodDescription");
        }
        public void LoadStepMethods_Should_ReturnTheExpectedListOfBaseMethodDescriptionObjects_Given_ADynamicComponentLoadingGivenMethods()
        {
            Component[] components = new Component[1] {
                UnitTestUtility.CreateComponent <MethodsLoaderTestDynamicComponent>()
            };
            BaseMethodDescription expectedMethod = new BaseMethodDescription();

            expectedMethod.ComponentObject = components[0];
            expectedMethod.Method          = components[0].GetType().GetMethod("GivenMethod");
            expectedMethod.StepType        = typeof(GivenBaseAttribute);
            expectedMethod.Text            = ((IGivenWhenThenDeclaration)expectedMethod.Method.GetCustomAttributes(typeof(GivenBaseAttribute), true)[0]).GetStepScenarioText();
            expectedMethod.ExecutionOrder  = ((IGivenWhenThenDeclaration)expectedMethod.Method.GetCustomAttributes(typeof(GivenBaseAttribute), true)[0]).GetExecutionOrder();
            BaseMethodDescriptionBuilder baseMethodDescriptionBuilder = new BaseMethodDescriptionBuilder();
            MethodsFilterByStepType      methodsFilterByStepType      = new MethodsFilterByStepType();
            MethodsLoader bddStepMethodsLoader   = new MethodsLoader(baseMethodDescriptionBuilder, methodsFilterByStepType);
            List <BaseMethodDescription> methods = bddStepMethodsLoader.LoadStepMethods <GivenBaseAttribute>(components);

            Assert.AreEqual(1, methods.Count, "The BDDStepMethodsFilter.FilterAllStepMethods method doesn't return the expected amount of elements");
            Assert.IsTrue(expectedMethod.Equals(methods[0]), "The BDDStepMethodsFilter.FilterAllStepMethods method doesn't return the expected Method Object");
        }
コード例 #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MethodsLoader"/> class.
 /// </summary>
 /// <param name="methodBuilder">The BaseMethodDescription builder.</param>
 /// <param name="methodFilter">The method filter.</param>
 public MethodsLoader(BaseMethodDescriptionBuilder methodBuilder, IMethodsFilter methodFilter)
 {
     this.methodBuilder = methodBuilder;
     this.methodFilter  = methodFilter;
 }
コード例 #19
0
        public void BuildParametersLocation_Should_LoadTheExpectedValuesForTheParametersAndBuildTheExpectedParametersIndexes_Given_AFullMethodDescriptionListOnASingleDynamicComponentAndOnThreeMethods()
        {
            RunnerEditorBusinessLogicParametersLocationsBuilder parametersLocationsBuilder = new RunnerEditorBusinessLogicParametersLocationsBuilder();

            BaseMethodDescriptionBuilder metodBuilder = new BaseMethodDescriptionBuilder();

            string[] methodsFullNamesList = new string[3]
            {
                "RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.WhenMethod", "RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.SecondWhenMethod", "RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.ThirdWhenMethod"
            };
            string[] parametersIndexes = new string[3]
            {
                ";System.String,RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.WhenMethod.whenStringParam.,stringPVS.Array.data[3]" +
                ";System.Int32,RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.WhenMethod.whenIntParam.,intPVS.Array.data[2]",
                ";String,RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.SecondWhenMethod.whenStringParam.,stringPVS.Array.data[0]",
                ";System.Int32,RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.ThirdWhenMethod.whenIntParam.,intPVS.Array.data[0]"
            };

            RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest firstDynamicBDDComponent = UnitTestUtility.CreateComponent <RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest>();

            Component[] components = new Component[1] {
                firstDynamicBDDComponent
            };

            string[] stringArray = new string[4] {
                "String Value for the SecondWhenMethod WhenStringParam parameter", string.Empty, string.Empty, "String Value for the WhenMethod WhenStringParam parameter"
            };
            FieldInfo stringPVS = this.SetPVSAndReturnFieldInfo(firstDynamicBDDComponent, typeof(string), stringArray);

            int[] intArray = new int[3] {
                103, 0, 201
            };
            FieldInfo intPVS = this.SetPVSAndReturnFieldInfo(firstDynamicBDDComponent, typeof(int), intArray);

            IMethodsFilter             methodFilter  = new MethodsFilterByMethodsFullNameList(methodsFullNamesList);
            MethodsLoader              methodsLoader = new MethodsLoader(metodBuilder, methodFilter);
            MethodsManagementUtilities methodsManagementUtilities = new MethodsManagementUtilities();
            MethodDescriptionBuilder   methodDescriptionBuilder   = new MethodDescriptionBuilder();
            MethodParametersLoader     methodParametersLoader     = new MethodParametersLoader();
            List <MethodDescription>   methodsDescriptionsList    = methodsManagementUtilities.LoadMethodsDescriptionsFromChosenMethods <WhenBaseAttribute>(components, methodsLoader, methodDescriptionBuilder, methodParametersLoader, methodsFullNamesList, parametersIndexes);

            stringArray = new string[0];
            stringPVS   = this.SetPVSAndReturnFieldInfo(firstDynamicBDDComponent, typeof(string), stringArray);

            intArray = new int[0];
            intPVS   = this.SetPVSAndReturnFieldInfo(firstDynamicBDDComponent, typeof(int), intArray);

            FullMethodDescriptionBuilder fullMethodDescriptionBuilder = new FullMethodDescriptionBuilder();
            List <FullMethodDescription> fullMethodsDescriptionsList  = fullMethodDescriptionBuilder.Build(methodsDescriptionsList[0], 1);

            fullMethodsDescriptionsList.AddRange(fullMethodDescriptionBuilder.Build(methodsDescriptionsList[1], 2));
            fullMethodsDescriptionsList.AddRange(fullMethodDescriptionBuilder.Build(methodsDescriptionsList[2], 3));

            parametersLocationsBuilder.BuildParametersLocation(fullMethodsDescriptionsList);

            Array stringArrayPVS = stringPVS.GetValue(firstDynamicBDDComponent) as Array;
            Array intArrayPVS    = intPVS.GetValue(firstDynamicBDDComponent) as Array;

            Assert.AreEqual(2, stringArrayPVS.Length, "The method BuildParametersLocation doesn't build the ParameterArrayStorage properly");
            Assert.AreEqual(2, intArrayPVS.Length, "The method BuildParametersLocation doesn't build the ParameterArrayStorage properly");

            Assert.AreEqual("String Value for the WhenMethod WhenStringParam parameter", stringArrayPVS.GetValue(0), "The method BuildParametersLocation doesn't build the ParameterArrayStorage properly");
            Assert.AreEqual("String Value for the SecondWhenMethod WhenStringParam parameter", stringArrayPVS.GetValue(1), "The method BuildParametersLocation doesn't build the ParameterArrayStorage properly");
            Assert.AreEqual(201, intArrayPVS.GetValue(0), "The method BuildParametersLocation doesn't build the ParameterArrayStorage properly");
            Assert.AreEqual(103, intArrayPVS.GetValue(1), "The method BuildParametersLocation doesn't build the ParameterArrayStorage properly");
            FullMethodDescription whenFullMethodMethodDescription       = null;
            FullMethodDescription secondWhenFullMethodMethodDescription = null;
            FullMethodDescription thirdWhenFullMethodMethodDescription  = null;

            foreach (FullMethodDescription fullMethodDescription in fullMethodsDescriptionsList)
            {
                if (fullMethodDescription.GetFullName().Equals("RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.WhenMethod"))
                {
                    whenFullMethodMethodDescription = fullMethodDescription;
                }
                else if (fullMethodDescription.GetFullName().Equals("RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.SecondWhenMethod"))
                {
                    secondWhenFullMethodMethodDescription = fullMethodDescription;
                }
                else if (fullMethodDescription.GetFullName().Equals("RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.ThirdWhenMethod"))
                {
                    thirdWhenFullMethodMethodDescription = fullMethodDescription;
                }
            }

            Assert.AreEqual(
                ";System.String,RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.WhenMethod.whenStringParam.,stringPVS.Array.data[0]" +
                ";System.Int32,RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.WhenMethod.whenIntParam.,intPVS.Array.data[0]",
                whenFullMethodMethodDescription.ParametersIndex,
                "The method BuildParametersLocation doesn't build the parametersIndex properly");
            Assert.AreEqual(";System.String,RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.SecondWhenMethod.whenStringParam.,stringPVS.Array.data[1]", secondWhenFullMethodMethodDescription.ParametersIndex, "The method BuildParametersLocation doesn't build the parametersIndex properly");
            Assert.AreEqual(";System.Int32,RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.ThirdWhenMethod.whenIntParam.,intPVS.Array.data[1]", thirdWhenFullMethodMethodDescription.ParametersIndex, "The method BuildParametersLocation doesn't build the parametersIndex properly");
        }
コード例 #20
0
        public void BuildParametersLocation_Should_LoadTheExpectedValuesForTheParametersAndBuildTheExpectedParametersIndexes_Given_AFullMethodDescriptionListOnTwoDynamicComponentsAndOnThreeMethodsInAdding()
        {
            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"
            };
            FieldInfo firstStringPVS = this.SetPVSAndReturnFieldInfo(firstDynamicBDDComponent, typeof(string), stringArray);

            int[] intArray = new int[3] {
                -1, -1, 103
            };
            FieldInfo firstIntPVS = this.SetPVSAndReturnFieldInfo(firstDynamicBDDComponent, typeof(int), intArray);

            stringArray = new string[4] {
                string.Empty, "SecondWhenMethodSecondClass", string.Empty, string.Empty
            };
            FieldInfo secondStringPVS = this.SetPVSAndReturnFieldInfo(secondDynamicBDDComponent, typeof(string), stringArray);

            intArray = null;
            FieldInfo secondIntPVS = 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);

            firstStringPVS  = this.SetPVSAndReturnFieldInfo(firstDynamicBDDComponent, typeof(string), new string[0]);
            firstIntPVS     = this.SetPVSAndReturnFieldInfo(firstDynamicBDDComponent, typeof(int), new int[0]);
            secondStringPVS = this.SetPVSAndReturnFieldInfo(secondDynamicBDDComponent, typeof(string), new string[0]);
            secondIntPVS    = 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);

            Array firstStringArrayPVS  = firstStringPVS.GetValue(firstDynamicBDDComponent) as Array;
            Array firstIntArrayPVS     = firstIntPVS.GetValue(firstDynamicBDDComponent) as Array;
            Array secondStringArrayPVS = secondStringPVS.GetValue(secondDynamicBDDComponent) as Array;
            Array secondIntArrayPVS    = secondIntPVS.GetValue(secondDynamicBDDComponent) as Array;

            Assert.AreEqual(2, firstStringArrayPVS.Length, "The method BuildParametersLocation doesn't build the ParameterArrayStorage properly");
            Assert.AreEqual(1, firstIntArrayPVS.Length, "The method BuildParametersLocation doesn't build the ParameterArrayStorage properly");

            Assert.AreEqual(1, secondStringArrayPVS.Length, "The method BuildParametersLocation doesn't build the ParameterArrayStorage properly");
            Assert.AreEqual(0, secondIntArrayPVS.Length, "The method BuildParametersLocation doesn't build the ParameterArrayStorage properly");

            Assert.AreEqual("GivenStringParamFirstClass", firstStringArrayPVS.GetValue(0), "The method BuildParametersLocation doesn't build the ParameterArrayStorage properly");
            Assert.AreEqual(103, firstIntArrayPVS.GetValue(0), "The method BuildParametersLocation doesn't build the ParameterArrayStorage properly");

            Assert.AreEqual("SecondWhenMethodSecondClass", secondStringArrayPVS.GetValue(0), "The method BuildParametersLocation doesn't build the ParameterArrayStorage properly");

            FullMethodDescription givenFullMethodMethodDescription      = givenFullMethodsDescriptionsList[0];
            FullMethodDescription whenFullMethodMethodDescription       = null;
            FullMethodDescription secondWhenFullMethodMethodDescription = null;

            foreach (FullMethodDescription fullMethodDescription in whenFullMethodsDescriptionsList)
            {
                if (fullMethodDescription.GetFullName().Equals("RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.WhenMethod"))
                {
                    whenFullMethodMethodDescription = fullMethodDescription;
                }
                else if (fullMethodDescription.GetFullName().Equals("RunnerEditorBusinessLogicParametersLocationsBuilderUTSecondDynamicBDDForTest.SecondWhenMethod"))
                {
                    secondWhenFullMethodMethodDescription = fullMethodDescription;
                }
            }

            Assert.AreEqual(";System.String,RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.GivenMethod.stringParam.,stringPVS.Array.data[0]", givenFullMethodMethodDescription.ParametersIndex, "The method BuildParametersLocation doesn't build the parametersIndex properly");
            Assert.AreEqual(
                ";System.String,RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.WhenMethod.whenStringParam.,stringPVS.Array.data[1]" +
                ";System.Int32,RunnerEditorBusinessLogicParametersLocationsBuilderUTFirstDynamicBDDForTest.WhenMethod.whenIntParam.,intPVS.Array.data[0]",
                whenFullMethodMethodDescription.ParametersIndex,
                "The method BuildParametersLocation doesn't build the parametersIndex properly");
            Assert.AreEqual(";System.String,RunnerEditorBusinessLogicParametersLocationsBuilderUTSecondDynamicBDDForTest.SecondWhenMethod.whenStringParam.,stringPVS.Array.data[0]", secondWhenFullMethodMethodDescription.ParametersIndex, "The method BuildParametersLocation doesn't build the parametersIndex properly");
        }
コード例 #21
0
        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");
        }