Beispiel #1
0
        public void IsBDDObjectsNull_Should_ReturnFalse_Given_ANonEmptyBDDObjectsArray()
        {
            RunnerEditorBusinessLogicParametersRebuild runnerEditorBusinessLogicParametersRebuild = new RunnerEditorBusinessLogicParametersRebuild();
            RunnerEditorBusinessLogicData runnerBusinessLogicData = new RunnerEditorBusinessLogicData();

            runnerBusinessLogicData.BDDObjects = new object[1];
            bool result = runnerEditorBusinessLogicParametersRebuild.IsBDDObjectsNull(runnerBusinessLogicData);

            Assert.IsFalse(result, "The method IsBDDObjectsNull doesn't return the right state of the BDDObjects");
        }
        /// <summary>
        /// Determines whether the stored BDDObjects collection is null.
        /// </summary>
        /// <param name="runnerBusinessLogicData">The runner business logic data.</param>
        /// <returns>
        ///   <c>true</c> if  the stored BDDObjects collection is null; otherwise, <c>false</c>.
        /// </returns>
        public bool IsBDDObjectsNull(RunnerEditorBusinessLogicData runnerBusinessLogicData)
        {
            bool result = false;

            if (runnerBusinessLogicData.BDDObjects == null)
            {
                result = true;
            }

            return(result);
        }
        /// <summary>
        /// Determines if the BDD Components are changed inside the Integration Test.
        /// </summary>
        /// <param name="components">The components.</param>
        /// <param name="runnerBusinessLogicData">The runner business logic data.</param>
        /// <param name="bddComponentsFilter">The BDD components filter.</param>
        /// <returns>True if some component is changed.</returns>
        public bool BddObjectsHaveChanged(Component[] components, RunnerEditorBusinessLogicData runnerBusinessLogicData, ComponentsFilter bddComponentsFilter)
        {
            bool result = false;

            object[] newBddObjects       = bddComponentsFilter.Filter(components);
            object[] previuousBDDObjects = null;
            if (runnerBusinessLogicData.BDDObjects == null)
            {
                previuousBDDObjects = new object[0];
            }
            else
            {
                previuousBDDObjects = runnerBusinessLogicData.BDDObjects;
            }

            // Checking for some new BDD Object.
            foreach (object mainObj in newBddObjects)
            {
                bool found = false;
                foreach (object obj in previuousBDDObjects)
                {
                    if (obj.Equals(mainObj))
                    {
                        found = true;
                    }
                }

                if (!found)
                {
                    result = true;
                }
            }

            // Checking for some BDD Object removed
            foreach (object mainObj in previuousBDDObjects)
            {
                bool found = false;
                foreach (object obj in newBddObjects)
                {
                    if (obj.Equals(mainObj))
                    {
                        found = true;
                    }
                }

                if (!found)
                {
                    result = true;
                }
            }

            return(result);
        }
Beispiel #4
0
        public void IsEditorApplicationCompilingJustFinished_Should_ReturnTrueAndSetTheValueOfIsCompilingPropertyToFalse_Given_TheStateOfIsCompilingPropertyIsTrueAndTheStateOfTheEditorApplicationIsCompilingPropertyIsFalse()
        {
            RunnerEditorBusinessLogicParametersRebuild runnerEditorBusinessLogicParametersRebuild = new RunnerEditorBusinessLogicParametersRebuild();
            RunnerEditorBusinessLogicData runnerBusinessLogicData = new RunnerEditorBusinessLogicData();

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

            unityInterfaceWrapper.EditorApplicationIsCompiling().Returns(false);
            runnerBusinessLogicData.IsCompiling = true;
            bool result = runnerEditorBusinessLogicParametersRebuild.IsEditorApplicationCompilingJustFinished(unityInterfaceWrapper, runnerBusinessLogicData);

            Assert.IsTrue(result, "The method IsEditorApplicationCompilingJustFinished doesn't return the right state of editor compilation just finished");
            Assert.IsFalse(runnerBusinessLogicData.IsCompiling, "The method IsEditorApplicationCompilingJustFinished doesn't return the right last state of editor compilation");
        }
Beispiel #5
0
        public void BddObjectsHaveChanged_Should_ReturnFalse_GivenTheBDDObjectsArrayIsNullAndTheCurrentComponentsArrayIsEmpty()
        {
            RunnerEditorBusinessLogicParametersRebuild runnerEditorBusinessLogicParametersRebuild = new RunnerEditorBusinessLogicParametersRebuild();
            RunnerEditorBusinessLogicData runnerBusinessLogicData = new RunnerEditorBusinessLogicData();

            runnerBusinessLogicData.BDDObjects = null;
            Component[]      currentComponents   = new Component[0];
            ComponentsFilter bddComponentsFilter = Substitute.For <ComponentsFilter>();

            Component[] bddComponentsFilterResult = new Component[0];
            bddComponentsFilter.Filter(currentComponents).Returns <Component[]>(bddComponentsFilterResult);

            bool result = runnerEditorBusinessLogicParametersRebuild.BddObjectsHaveChanged(currentComponents, runnerBusinessLogicData, bddComponentsFilter);

            Assert.IsFalse(result, "The method BddObjectsHaveChanged doesn't return the right state");
        }
Beispiel #6
0
        public void BddObjectsHaveChanged_Should_ReturnTrue_GivenTheBDDObjectsArrayIsNullAndTheCurrentComponentsArrayIsNotEmpty()
        {
            RunnerEditorBusinessLogicParametersRebuild runnerEditorBusinessLogicParametersRebuild = new RunnerEditorBusinessLogicParametersRebuild();
            RunnerEditorBusinessLogicData runnerBusinessLogicData = new RunnerEditorBusinessLogicData();

            runnerBusinessLogicData.BDDObjects = null;
            Component[] currentComponents = new Component[1] {
                UnitTestUtility.CreateComponent <RunnerEditorBusinessLogicParametersRebuildUTDynamicBDDForTest>()
            };
            ComponentsFilter bddComponentsFilter = Substitute.For <ComponentsFilter>();

            Component[] bddComponentsFilterResult = new Component[1] {
                currentComponents[0]
            };
            bddComponentsFilter.Filter(currentComponents).Returns <Component[]>(bddComponentsFilterResult);

            bool result = runnerEditorBusinessLogicParametersRebuild.BddObjectsHaveChanged(currentComponents, runnerBusinessLogicData, bddComponentsFilter);

            Assert.IsTrue(result, "The method BddObjectsHaveChanged doesn't return the right state");
        }
Beispiel #7
0
        /// <summary>
        /// Draws the options.
        /// </summary>
        /// <param name="businessLogicData">The business logic data.</param>
        /// <param name="isStaticScenario">If set to <c>true</c> [is static scenario].</param>
        /// <param name="script">The script.</param>
        /// <param name="unityInterface">The unity interface.</param>
        /// <param name="bddComponents">The BDD components.</param>
        private void DrawOptions(RunnerEditorBusinessLogicData businessLogicData, bool isStaticScenario, BDDExtensionRunner script, IUnityInterfaceWrapper unityInterface, Component[] bddComponents)
        {
            Rect rect = unityInterface.EditorGUILayoutGetControlRect();

            businessLogicData.OptionsFoldout = unityInterface.EditorGUIFoldout(rect, businessLogicData.OptionsFoldout, "Options");
            if (businessLogicData.OptionsFoldout)
            {
                if (!isStaticScenario)
                {
                    this.ForceRebuildParametersButton(script, bddComponents);
                }

                unityInterface.EditorGUILayoutSeparator();
                this.ChooseBetweenUpdateAndFixedUpdate(script, this.unityIntefaceWrapper);
                float  width = unityInterface.EditorGUIUtilityCurrentViewWidth();
                int    numberOfSeparatorChars = (int)width / 7;
                string text = string.Empty.PadLeft(numberOfSeparatorChars, '_');

                unityInterface.EditorGUILayoutLabelFieldTruncate(text, width);
            }
        }
        /// <summary>
        /// Determines whether the rebuild of the parameters indexes is needed.
        /// </summary>
        /// <param name="unityInterfaceWrapper">The unity interface wrapper.</param>
        /// <param name="runnerBusinessLogicData">The runner business logic data.</param>
        /// <param name="components">The components.</param>
        /// <param name="bddComponentsFilter">The BDD components filter.</param>
        /// <returns>
        ///   <c>true</c> if the rebuild of the parameters indexes is needed; otherwise, <c>false</c>.
        /// </returns>
        public bool IsParametersRebuildNeeded(IUnityInterfaceWrapper unityInterfaceWrapper, RunnerEditorBusinessLogicData runnerBusinessLogicData, Component[] components, ComponentsFilter bddComponentsFilter)
        {
            bool isBDDObjectsNull      = this.IsBDDObjectsNull(runnerBusinessLogicData);
            bool bddObjectsHaveChanged = this.BddObjectsHaveChanged(components, runnerBusinessLogicData, bddComponentsFilter);
            bool isEditorApplicationCompilingJustFinished = this.IsEditorApplicationCompilingJustFinished(unityInterfaceWrapper, runnerBusinessLogicData);
            bool isDynamicScenario = this.IsDynamicScenario(components);

            return(this.IsParametersRebuildNeeded(isBDDObjectsNull, bddObjectsHaveChanged, runnerBusinessLogicData.IsCompiling, isEditorApplicationCompilingJustFinished, runnerBusinessLogicData.Rebuild, isDynamicScenario));
        }
        /// <summary>
        /// Determines whether the build process is just finished.
        /// </summary>
        /// <param name="unityInterfaceWrapper">The unity interface wrapper.</param>
        /// <param name="runnerBusinessLogicData">The runner business logic data.</param>
        /// <returns>
        ///   <c>true</c> if the build process is just finished; otherwise, <c>false</c>.
        /// </returns>
        public bool IsEditorApplicationCompilingJustFinished(IUnityInterfaceWrapper unityInterfaceWrapper, RunnerEditorBusinessLogicData runnerBusinessLogicData)
        {
            bool result = false;

            if (!unityInterfaceWrapper.EditorApplicationIsCompiling())
            {
                if (runnerBusinessLogicData.IsCompiling)
                {
                    result = true;
                    runnerBusinessLogicData.IsCompiling = false;
                }
            }
            else
            {
                runnerBusinessLogicData.IsCompiling = true;
                result = false;
            }

            return(result);
        }
Beispiel #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);
        }