Пример #1
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.");
        }
        /// <summary>
        /// Draws the dynamic rows.
        /// </summary>
        /// <typeparam name="T">The type of the Step Methods.</typeparam>
        /// <param name="unityInterface">The unity interface.</param>
        /// <param name="methodsLoader">The methods loader.</param>
        /// <param name="methodDescriptionBuilder">The method description builder.</param>
        /// <param name="parametersLoader">The parameters loader.</param>
        /// <param name="bddComponents">The BDD components.</param>
        /// <param name="chosenMethods">The chosen methods.</param>
        /// <param name="foldouts">The foldouts.</param>
        /// <param name="serializedObjects">The serialized objects.</param>
        /// <param name="target">The target.</param>
        /// <param name="methodsUtilities">The methods utilities.</param>
        /// <param name="dynamicRowsElements">The dynamic rows elements.</param>
        /// <param name="lockParametersRows">If set to <c>true</c> [lock parameters rows].</param>
        /// <param name="rebuild">If set to <c>true</c> [rebuild].</param>
        /// <param name="updatedChosenMethodsList">The updated chosen methods list.</param>
        /// <param name="updatedFoldouts">The updated foldouts.</param>
        /// <param name="dirtyStatus">If set to <c>true</c> [dirty status].</param>
        /// <param name="undoText">The undo text.</param>
        /// <returns>True if a rebuild of the parameters index is requested.</returns>
        public bool DrawDynamicRows <T>(
            IUnityInterfaceWrapper unityInterface,
            MethodsLoader methodsLoader,
            MethodDescriptionBuilder methodDescriptionBuilder,
            MethodParametersLoader parametersLoader,
            Component[] bddComponents,
            ChosenMethods chosenMethods,
            bool[] foldouts,
            Dictionary <Type, ISerializedObjectWrapper> serializedObjects,
            UnityEngine.Object target,
            RunnerEditorBusinessLogicMethodsUtilities methodsUtilities,
            RunnerEditorBusinessLogicDynamicRowsElements dynamicRowsElements,
            bool lockParametersRows,
            bool rebuild,
            out ChosenMethods updatedChosenMethodsList,
            out bool[] updatedFoldouts,
            out bool dirtyStatus,
            out string undoText) where T : IGivenWhenThenDeclaration
        {
            updatedChosenMethodsList = (ChosenMethods)chosenMethods.Clone();
            updatedFoldouts          = new bool[foldouts.Length];
            Array.Copy(foldouts, updatedFoldouts, foldouts.Length);
            undoText    = string.Empty;
            dirtyStatus = false;

            List <BaseMethodDescription> methodsList = methodsLoader.LoadStepMethods <T>(bddComponents);

            string[] methodsNames = methodsUtilities.GetMethodsNames(methodsList);

            FullMethodDescriptionBuilder fullMethodDescriptionBuilder = new FullMethodDescriptionBuilder();

            for (int index = 0; index < chosenMethods.ChosenMethodsNames.Length; index++)
            {
                MethodDescription methodDescription = methodsUtilities.GetMethodDescription(methodDescriptionBuilder, parametersLoader, chosenMethods, methodsList, index);

                methodsNames = methodsUtilities.CheckMissedMethod(chosenMethods, methodsNames, index, methodDescription);

                List <FullMethodDescription> fullMethodDescriptionsList = fullMethodDescriptionBuilder.Build(methodDescription, (uint)index + 1);

                unityInterface.EditorGUILayoutBeginHorizontal();
                dynamicRowsElements.DrawFoldoutSymbol(unityInterface, updatedFoldouts, index, fullMethodDescriptionsList);

                dynamicRowsElements.DrawLabel <T>(unityInterface, index);
                float textSize = (unityInterface.EditorGUIUtilityCurrentViewWidth() - RunnerEditorBusinessLogicData.LabelWidthAbsolute - RunnerEditorBusinessLogicData.ButtonsWidthAbsolute) * RunnerEditorBusinessLogicData.TextWidthPercent;
                dynamicRowsElements.DrawDescription(unityInterface, chosenMethods.ChosenMethodsNames[index], methodDescription, textSize);

                string newChosenMethod = dynamicRowsElements.DrawComboBox(unityInterface, chosenMethods.ChosenMethodsNames[index], methodsNames);
                rebuild     = methodsUtilities.UpdateDataIfNewMethodIsChosen(newChosenMethod, updatedChosenMethodsList, updatedFoldouts, index, rebuild, out undoText);
                dirtyStatus = dirtyStatus || dynamicRowsElements.DrawAddRowButton(unityInterface, index, updatedChosenMethodsList, target, undoText, out updatedChosenMethodsList, out undoText);
                dirtyStatus = dirtyStatus || dynamicRowsElements.DrawRemoveRowButton(unityInterface, index, updatedChosenMethodsList, target, undoText, out updatedChosenMethodsList, out undoText);
                if (dirtyStatus)
                {
                    break;
                }

                dynamicRowsElements.DrawCogButton(unityInterface, methodDescription, (BDDExtensionRunner)target);
                unityInterface.EditorGUILayoutEndHorizontal();

                dynamicRowsElements.DrawParametersRows(unityInterface, foldouts[index], fullMethodDescriptionsList, serializedObjects, lockParametersRows);
            }

            return(rebuild);
        }