public void Errors_Should_CallTheExpectedUnityEditorStatements_Given_TwoErrorsOnAComponent()
        {
            UnityTestBDDComponentBaseEditorBusinessLogicTestFirstDynamicComponent component = UnitTestUtility.CreateComponent <UnityTestBDDComponentBaseEditorBusinessLogicTestFirstDynamicComponent>();
            BDDExtensionRunner runner = UnitTestUtility.CreateComponent <BDDExtensionRunner>(component.gameObject);

            BaseBDDComponentEditorBusinessLogic unityTestBDDComponentBaseEditorBusinessLogic = new BaseBDDComponentEditorBusinessLogic(component);
            string expectedFirstMessage     = "FirstMessage";
            string expectedSecondMessage    = "SecondMessage";
            List <UnityTestBDDError> errors = new List <UnityTestBDDError>();
            UnityTestBDDError        error  = new UnityTestBDDError();

            error.Message          = expectedFirstMessage;
            error.Component        = component;
            error.MethodMethodInfo = null;
            errors.Add(error);

            error                  = new UnityTestBDDError();
            error.Message          = expectedSecondMessage;
            error.Component        = component;
            error.MethodMethodInfo = null;
            errors.Add(error);

            string errorTextureFullPath = Utilities.GetAssetFullPath(runner, unityTestBDDComponentBaseEditorBusinessLogic.ErrorTextureFileName);
            string openComponentButtonTextureFullPath = Utilities.GetAssetFullPath(runner, unityTestBDDComponentBaseEditorBusinessLogic.OpenComponentButtonTextureFileName);

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

            unityInterface.EditorGUIUtilityCurrentViewWidth().Returns(600f);
            float     labelWidth   = 500f;
            Texture2D inputTexture = new Texture2D(10, 10);

            unityInterface.AssetDatabaseLoadAssetAtPath(openComponentButtonTextureFullPath, typeof(Texture2D)).Returns(inputTexture);
            Texture2D errorTexture = new Texture2D(10, 10);

            unityInterface.AssetDatabaseLoadAssetAtPath(errorTextureFullPath, typeof(Texture2D)).Returns(errorTexture);

            GUILayoutOption buttonWidth = GUILayout.Width(16);

            unityInterface.GUILayoutWidth(24).Returns(buttonWidth);
            GUILayoutOption buttonHeight = GUILayout.Height(16);

            unityInterface.GUILayoutHeight(24).Returns(buttonHeight);
            GUILayoutOption[] options = new GUILayoutOption[2];
            options[0] = buttonWidth;
            options[1] = buttonHeight;
            unityInterface.GUILayoutButton(inputTexture, EditorStyles.label, options).Returns(false);
            GUILayoutOption[] errorTextureOptions = new GUILayoutOption[2];
            errorTextureOptions[0] = buttonWidth;
            errorTextureOptions[1] = buttonHeight;

            unityTestBDDComponentBaseEditorBusinessLogic.Errors(errors, unityInterface);

            Received.InOrder(() =>
            {
                unityInterface.EditorGUILayoutBeginHorizontal();
                unityInterface.EditorGUILayoutSeparator();
                unityInterface.EditorGUILayoutSeparator();
                unityInterface.EditorGUILayoutEndHorizontal();
                unityInterface.EditorGUILayoutBeginHorizontal();
                unityInterface.EditorGUIUtilityCurrentViewWidth();
                unityInterface.AssetDatabaseLoadAssetAtPath(errorTextureFullPath, typeof(Texture2D));
                unityInterface.GUILayoutWidth(24);
                unityInterface.GUILayoutHeight(24);
                unityInterface.EditorGUILayoutLabelField(errorTexture, Arg.Is <GUILayoutOption[]>(x => x.SequenceEqual(errorTextureOptions) == true));
                unityInterface.EditorGUILayoutLabelField(expectedFirstMessage, labelWidth);
                unityInterface.AssetDatabaseLoadAssetAtPath(openComponentButtonTextureFullPath, typeof(Texture2D));
                unityInterface.GUILayoutWidth(24);
                unityInterface.GUILayoutHeight(24);
                unityInterface.GUILayoutButton(inputTexture, EditorStyles.label, Arg.Is <GUILayoutOption[]>(x => x.SequenceEqual(options) == true));
                unityInterface.EditorGUILayoutEndHorizontal();

                unityInterface.EditorGUILayoutBeginHorizontal();
                unityInterface.EditorGUILayoutSeparator();
                unityInterface.EditorGUILayoutSeparator();
                unityInterface.EditorGUILayoutEndHorizontal();
                unityInterface.EditorGUILayoutBeginHorizontal();
                unityInterface.EditorGUIUtilityCurrentViewWidth();
                unityInterface.AssetDatabaseLoadAssetAtPath(errorTextureFullPath, typeof(Texture2D));
                unityInterface.GUILayoutWidth(24);
                unityInterface.GUILayoutHeight(24);
                unityInterface.EditorGUILayoutLabelField(errorTexture, Arg.Is <GUILayoutOption[]>(x => x.SequenceEqual(errorTextureOptions) == true));
                unityInterface.EditorGUILayoutLabelField(expectedSecondMessage, labelWidth);
                unityInterface.AssetDatabaseLoadAssetAtPath(openComponentButtonTextureFullPath, typeof(Texture2D));
                unityInterface.GUILayoutWidth(24);
                unityInterface.GUILayoutHeight(24);
                unityInterface.GUILayoutButton(inputTexture, EditorStyles.label, Arg.Is <GUILayoutOption[]>(x => x.SequenceEqual(options) == true));
                unityInterface.EditorGUILayoutEndHorizontal();
            });
        }
コード例 #2
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");
        }
コード例 #3
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");
        }
コード例 #4
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");
        }
コード例 #5
0
 public void Cleanup()
 {
     UnitTestUtility.DestroyTemporaryTestGameObjects();
 }
コード例 #6
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");
        }
        public void LoadMethodParameters_Should_ReturnTheExpectedMethodParametersObject_Given_ADynamicComponentAndAMethodWithOneStringParameterAndOneIntParameterWithTheirParameterIndexes()
        {
            MethodParametersLoaderTestDynamicComponent component = UnitTestUtility.CreateComponent <MethodParametersLoaderTestDynamicComponent>();

            ArrayStorageUtilities arrayStorageUtilities = new ArrayStorageUtilities();

            FieldInfo stringArrayStorage = arrayStorageUtilities.GetArrayStorageFieldInfoByType(component, typeof(string));

            stringArrayStorage.SetValue(component, new string[1] {
                "Parameter Value"
            });

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

            intArrayStorage.SetValue(component, new int[1] {
                102
            });

            MethodInfo method = component.GetType().GetMethod("WhenMethod");

            ParameterInfo[] parametersInfo = method.GetParameters();

            MethodParameter expectedParameter1 = new MethodParameter();

            expectedParameter1.ParameterInfoObject = parametersInfo[0];

            ParameterLocation parameterLocation1 = new ParameterLocation();

            parameterLocation1.ParameterClassLocation = new ParameterLocation.ClassLocation();
            parameterLocation1.ParameterClassLocation.ComponentObject = component;
            parameterLocation1.ParameterClassLocation.ComponentType   = component.GetType();
            parameterLocation1.ParameterArrayLocation = new ParameterLocation.ArrayLocation();
            parameterLocation1.ParameterArrayLocation.ArrayFieldInfo = arrayStorageUtilities.GetArrayStorageFieldInfoByType(component, typeof(string));
            parameterLocation1.ParameterArrayLocation.ArrayName      = "stringPVS";
            parameterLocation1.ParameterArrayLocation.ArrayIndex     = 0;

            expectedParameter1.ParameterLocation = parameterLocation1;

            expectedParameter1.Value = "Parameter Value";

            MethodParameter expectedParameter2 = new MethodParameter();

            expectedParameter2.ParameterInfoObject = parametersInfo[1];

            ParameterLocation parameterLocation2 = new ParameterLocation();

            parameterLocation2.ParameterClassLocation = new ParameterLocation.ClassLocation();
            parameterLocation2.ParameterClassLocation.ComponentObject = component;
            parameterLocation2.ParameterClassLocation.ComponentType   = component.GetType();
            parameterLocation2.ParameterArrayLocation = new ParameterLocation.ArrayLocation();
            parameterLocation2.ParameterArrayLocation.ArrayFieldInfo = arrayStorageUtilities.GetArrayStorageFieldInfoByType(component, typeof(int));
            parameterLocation2.ParameterArrayLocation.ArrayName      = "intPVS";
            parameterLocation2.ParameterArrayLocation.ArrayIndex     = 0;

            expectedParameter2.ParameterLocation = parameterLocation2;

            expectedParameter2.Value = 102;

            MethodParameters expectedMethodParameters = new MethodParameters();

            expectedMethodParameters.Parameters = new MethodParameter[2] {
                expectedParameter1, expectedParameter2
            };

            string parametersIndex = ";System.String,MethodParametersLoaderTestDynamicComponent.WhenMethod.whenStringParam.,stringPVS.Array.data[0];System.Int32,MethodParametersLoaderTestDynamicComponent.WhenMethod.whenIntParam.,intPVS.Array.data[0];";
            MethodParametersLoader methodParametersLoader = new MethodParametersLoader();
            MethodParameters       methodParameters       = methodParametersLoader.LoadMethodParameters(component, method, string.Empty, parametersIndex);

            Assert.That(expectedMethodParameters.Equals(methodParameters), "The method MethodParametersLoader.LoadMethodParameters doesn't return the right object.");
        }
        public void GetAllMethodsDescriptions_Should_ReturnTheExpectedListOfFullMethodDescriptionObjects_Given_ACompleteListOfGivenWhenThenChosenMethodsWithNestedCallBeforeAttributesForDynamicComponents()
        {
            ExtensionRunnerBusinessLogicTestFirstDynamicComponent  firstComponent  = UnitTestUtility.CreateComponent <ExtensionRunnerBusinessLogicTestFirstDynamicComponent>();
            ExtensionRunnerBusinessLogicTestSecondDynamicComponent secondComponent = UnitTestUtility.CreateComponent <ExtensionRunnerBusinessLogicTestSecondDynamicComponent>();
            ExtensionRunnerBusinessLogicTestThirdDynamicComponent  thirdComponent  = UnitTestUtility.CreateComponent <ExtensionRunnerBusinessLogicTestThirdDynamicComponent>();

            Component[] components = new Component[3] {
                firstComponent, secondComponent, thirdComponent
            };

            string[] givenMethods = new string[3] {
                "ExtensionRunnerBusinessLogicTestFirstDynamicComponent.GivenMethod", "ExtensionRunnerBusinessLogicTestThirdDynamicComponent.SecondGivenMethod", "ExtensionRunnerBusinessLogicTestSecondDynamicComponent.GivenMethod"
            };
            string[] givenParameters = new string[3] {
                string.Empty, string.Empty, string.Empty
            };

            string[] whenMethods = new string[2] {
                "ExtensionRunnerBusinessLogicTestFirstDynamicComponent.WhenMethod", "ExtensionRunnerBusinessLogicTestSecondDynamicComponent.WhenMethod"
            };
            string[] whenParameters = new string[2] {
                string.Empty, string.Empty
            };

            string[] thenMethods = new string[2] {
                "ExtensionRunnerBusinessLogicTestThirdDynamicComponent.SecondThenMethod", "ExtensionRunnerBusinessLogicTestSecondDynamicComponent.ThenMethod"
            };
            string[] thenParameters = new string[2] {
                string.Empty, string.Empty
            };

            GameObject gameObject = UnitTestUtility.CreateGameObject();
            ExtensionRunnerBusinessLogic businessLogic = new ExtensionRunnerBusinessLogic(gameObject);
            List <FullMethodDescription> resultList    = businessLogic.GetAllMethodsDescriptions(components, givenMethods, givenParameters, whenMethods, whenParameters, thenMethods, thenParameters);

            string expecetdMethod1 = "ExtensionRunnerBusinessLogicTestFirstDynamicComponent.GivenMethod";
            string expecetdMethod2 = "ExtensionRunnerBusinessLogicTestThirdDynamicComponent.SecondGivenMethod";
            string expecetdMethod3 = "ExtensionRunnerBusinessLogicTestSecondDynamicComponent.GivenMethod";
            string expecetdMethod4 = "ExtensionRunnerBusinessLogicTestFirstDynamicComponent.WhenMethod";
            string expecetdMethod5 = "ExtensionRunnerBusinessLogicTestSecondDynamicComponent.WhenMethod";

            string expecetdMethod6 = "ExtensionRunnerBusinessLogicTestThirdDynamicComponent.SecondGivenMethod";
            string expecetdMethod7 = "ExtensionRunnerBusinessLogicTestThirdDynamicComponent.ThenMethod";
            string expecetdMethod8 = "ExtensionRunnerBusinessLogicTestThirdDynamicComponent.SecondGivenMethod";
            string expecetdMethod9 = "ExtensionRunnerBusinessLogicTestThirdDynamicComponent.SecondThenMethod";

            string expecetdMethod10 = "ExtensionRunnerBusinessLogicTestSecondDynamicComponent.SecondGivenMethod";
            string expecetdMethod11 = "ExtensionRunnerBusinessLogicTestSecondDynamicComponent.ThenMethod";

            Assert.AreEqual(11, resultList.Count, "The method GetAllMethodsDescriptions doesn't return the right number of methods.");
            Assert.AreEqual(expecetdMethod1, resultList[0].GetFullName(), "The method GetAllMethodsDescriptions doesn't return the right methods order.");
            Assert.AreEqual(expecetdMethod2, resultList[1].GetFullName(), "The method GetAllMethodsDescriptions doesn't return the right methods order.");
            Assert.AreEqual(expecetdMethod3, resultList[2].GetFullName(), "The method GetAllMethodsDescriptions doesn't return the right methods order.");
            Assert.AreEqual(expecetdMethod4, resultList[3].GetFullName(), "The method GetAllMethodsDescriptions doesn't return the right methods order.");
            Assert.AreEqual(expecetdMethod5, resultList[4].GetFullName(), "The method GetAllMethodsDescriptions doesn't return the right methods order.");
            Assert.AreEqual(expecetdMethod6, resultList[5].GetFullName(), "The method GetAllMethodsDescriptions doesn't return the right methods order.");
            Assert.AreEqual(expecetdMethod7, resultList[6].GetFullName(), "The method GetAllMethodsDescriptions doesn't return the right methods order.");
            Assert.AreEqual(expecetdMethod8, resultList[7].GetFullName(), "The method GetAllMethodsDescriptions doesn't return the right methods order.");
            Assert.AreEqual(expecetdMethod9, resultList[8].GetFullName(), "The method GetAllMethodsDescriptions doesn't return the right methods order.");
            Assert.AreEqual(expecetdMethod10, resultList[9].GetFullName(), "The method GetAllMethodsDescriptions doesn't return the right methods order.");
            Assert.AreEqual(expecetdMethod11, resultList[10].GetFullName(), "The method GetAllMethodsDescriptions doesn't return the right methods order.");
        }