/// <summary>
        /// Draws the given errors.
        /// </summary>
        /// <param name="errors">The errors.</param>
        /// <param name="unityInterface">The unity interface.</param>
        public void Errors(List <UnityTestBDDError> errors, IUnityInterfaceWrapper unityInterface)
        {
            BDDExtensionRunner bddExtensionRunner = this.component.gameObject.GetComponent <BDDExtensionRunner>();
            string             openComponentButtonTextureFullPath = Utilities.GetAssetFullPath(bddExtensionRunner, this.OpenComponentButtonTextureFileName);
            string             errorTextureFullPath = Utilities.GetAssetFullPath(bddExtensionRunner, this.ErrorTextureFileName);

            foreach (UnityTestBDDError error in errors)
            {
                unityInterface.EditorGUILayoutBeginHorizontal();
                unityInterface.EditorGUILayoutSeparator();
                unityInterface.EditorGUILayoutSeparator();
                unityInterface.EditorGUILayoutEndHorizontal();
                unityInterface.EditorGUILayoutBeginHorizontal();
                float             currentViewWidth    = unityInterface.EditorGUIUtilityCurrentViewWidth();
                Texture2D         errorTexture        = unityInterface.AssetDatabaseLoadAssetAtPath(errorTextureFullPath, typeof(Texture2D));
                GUILayoutOption[] errorTextureOptions = new GUILayoutOption[2] {
                    unityInterface.GUILayoutWidth(24), unityInterface.GUILayoutHeight(24)
                };
                unityInterface.EditorGUILayoutLabelField(errorTexture, errorTextureOptions);
                float labelWidth = currentViewWidth - 100;
                unityInterface.EditorGUILayoutLabelField(error.Message, labelWidth);

                Texture2D         openComponentButtonTexture = unityInterface.AssetDatabaseLoadAssetAtPath(openComponentButtonTextureFullPath, typeof(Texture2D));
                GUILayoutOption[] options = new GUILayoutOption[2] {
                    unityInterface.GUILayoutWidth(24), unityInterface.GUILayoutHeight(24)
                };
                if (unityInterface.GUILayoutButton(openComponentButtonTexture, EditorStyles.label, options))
                {
                    if (error.MethodMethodInfo != null)
                    {
                        SourcesManagement.OpenMethodSourceCode(error.MethodMethodInfo, unityInterface);
                    }
                    else if (error.Component != null)
                    {
                        SourcesManagement.OpenSourceCode(error.Component, unityInterface);
                    }
                    else
                    {
                        MethodInfo[] methods = this.component.GetType().GetMethods();
                        foreach (MethodInfo method in methods)
                        {
                            if (method.DeclaringType.Name.Equals(this.component.GetType().Name))
                            {
                                SourcesManagement.OpenSourceCode(method, unityInterface);
                            }
                        }
                    }
                }

                unityInterface.EditorGUILayoutEndHorizontal();
            }
        }
        /// <summary>
        /// Draws the cog button.
        /// </summary>
        /// <param name="unityInterface">The unity interface.</param>
        /// <param name="methodDescription">The method description.</param>
        /// <param name="bddExtensionRunner">The BDD extension runner.</param>
        internal void DrawCogButton(IUnityInterfaceWrapper unityInterface, MethodDescription methodDescription, BDDExtensionRunner bddExtensionRunner)
        {
            string cogTexture = @"cog.png";

            string    cogTextureFullPath = Utilities.GetAssetFullPath(bddExtensionRunner, cogTexture);
            Texture2D inputTexture       = unityInterface.AssetDatabaseLoadAssetAtPath(cogTextureFullPath, typeof(Texture2D));

            GUILayoutOption[] options = new GUILayoutOption[2] {
                unityInterface.GUILayoutWidth(16), unityInterface.GUILayoutHeight(16)
            };

            if (unityInterface.GUILayoutButton(inputTexture, EditorStyles.label, options))
            {
                GenericMenu menu    = new GenericMenu();
                GUIContent  content = new GUIContent("Open method source");
                bool        on      = false;
                MethodInfo  method  = null;
                if (methodDescription != null)
                {
                    on     = true;
                    method = methodDescription.Method;
                    menu.AddItem(content, on, () => { SourcesManagement.OpenMethodSourceCode(method, unityInterface); });
                }
                else
                {
                    menu.AddDisabledItem(content);
                }

                menu.ShowAsContext();
            }
        }
        /// <summary>
        /// Draws the given errors.
        /// </summary>
        /// <param name="errors">The errors.</param>
        /// <param name="unityInterface">The unity interface.</param>
        /// <param name="bddExtensionRunner">The BDD extension runner.</param>
        public void Errors(List <UnityTestBDDError> errors, IUnityInterfaceWrapper unityInterface, BDDExtensionRunner bddExtensionRunner)
        {
            string openComponentButtonTextureFullPath = Utilities.GetAssetFullPath(bddExtensionRunner, this.OpenComponentButtonTextureFileName);
            string errorTextureFullPath = Utilities.GetAssetFullPath(bddExtensionRunner, this.ErrorTextureFileName);

            foreach (UnityTestBDDError error in errors)
            {
                unityInterface.EditorGUILayoutBeginHorizontal();
                unityInterface.EditorGUILayoutSeparator();
                unityInterface.EditorGUILayoutSeparator();
                unityInterface.EditorGUILayoutEndHorizontal();
                unityInterface.EditorGUILayoutBeginHorizontal();
                float currentViewWidth = unityInterface.EditorGUIUtilityCurrentViewWidth();
                if (error.ShowRedExclamationMark)
                {
                    Texture2D         errorTexture        = unityInterface.AssetDatabaseLoadAssetAtPath(errorTextureFullPath, typeof(Texture2D));
                    GUILayoutOption[] errorTextureOptions = new GUILayoutOption[2] {
                        unityInterface.GUILayoutWidth(24), unityInterface.GUILayoutHeight(24)
                    };
                    unityInterface.EditorGUILayoutLabelField(errorTexture, errorTextureOptions);
                }

                float labelWidth = currentViewWidth - 100;
                unityInterface.EditorGUILayoutLabelField(error.Message, labelWidth);

                Texture2D         openComponentButtonTexture = unityInterface.AssetDatabaseLoadAssetAtPath(openComponentButtonTextureFullPath, typeof(Texture2D));
                GUILayoutOption[] options = new GUILayoutOption[2] {
                    unityInterface.GUILayoutWidth(24), unityInterface.GUILayoutHeight(24)
                };
                if (error.ShowButton)
                {
                    if (unityInterface.GUILayoutButton(openComponentButtonTexture, EditorStyles.label, options))
                    {
                        if (error.MethodMethodInfo != null)
                        {
                            SourcesManagement.OpenMethodSourceCode(error.MethodMethodInfo, unityInterface);
                        }
                        else if (error.Component != null)
                        {
                            SourcesManagement.OpenSourceCode(error.Component, unityInterface);
                        }
                    }
                }

                unityInterface.EditorGUILayoutEndHorizontal();
            }
        }
        /// <summary>
        /// Draws the add row button.
        /// </summary>
        /// <param name="unityInterface">The unity interface.</param>
        /// <param name="currentIndex">Index of the current.</param>
        /// <param name="chosenMethods">The chosen methods.</param>
        /// <param name="target">The target.</param>
        /// <param name="undoText">The undo text.</param>
        /// <param name="newChosenMethods">The new chosen methods.</param>
        /// <param name="newUndoText">The new undo text.</param>
        /// <returns>Returns true if the inspector needs to be redrawn.</returns>
        public bool DrawAddRowButton(IUnityInterfaceWrapper unityInterface, int currentIndex, ChosenMethods chosenMethods, UnityEngine.Object target, string undoText, out ChosenMethods newChosenMethods, out string newUndoText)
        {
            newUndoText = undoText;
            bool dirty = false;

            newChosenMethods = new ChosenMethods();
            newChosenMethods.ChosenMethodsNames           = chosenMethods.ChosenMethodsNames;
            newChosenMethods.ChosenMethodsParametersIndex = chosenMethods.ChosenMethodsParametersIndex;

            if (unityInterface.GUILayoutButton("+", EditorStyles.miniButton, unityInterface.GUILayoutWidth(20)))
            {
                newUndoText = "Add Step Method row";
                string[] newArrayMethodsNames           = new string[newChosenMethods.ChosenMethodsNames.Length + 1];
                string[] newArrayMethodsParametersIndex = new string[newChosenMethods.ChosenMethodsParametersIndex.Length + 1];
                int      newIndex = 0;
                for (int tempIndex = 0; tempIndex < chosenMethods.ChosenMethodsNames.Length; tempIndex++)
                {
                    if (tempIndex == currentIndex + 1)
                    {
                        newArrayMethodsNames[newIndex]           = string.Empty;
                        newArrayMethodsParametersIndex[newIndex] = string.Empty;
                        newIndex++;
                    }

                    newArrayMethodsNames[newIndex]           = newChosenMethods.ChosenMethodsNames[tempIndex];
                    newArrayMethodsParametersIndex[newIndex] = newChosenMethods.ChosenMethodsParametersIndex[tempIndex];
                    newIndex++;
                }

                if (newArrayMethodsNames[newArrayMethodsNames.Length - 1] == null)
                {
                    newArrayMethodsNames[newArrayMethodsNames.Length - 1]           = string.Empty;
                    newArrayMethodsParametersIndex[newArrayMethodsNames.Length - 1] = string.Empty;
                }

                newChosenMethods.ChosenMethodsNames           = newArrayMethodsNames;
                newChosenMethods.ChosenMethodsParametersIndex = newArrayMethodsParametersIndex;
                unityInterface.EditorUtilitySetDirty(target);
                dirty = true;
            }

            return(dirty);
        }
        public void Errors_Should_CallTheExpectedUnityEditorStatements_Given_OneErrorOnAComponent()
        {
            UnityTestBDDComponentBaseEditorBusinessLogicTestFirstDynamicComponent component = UnitTestUtility.CreateComponent <UnityTestBDDComponentBaseEditorBusinessLogicTestFirstDynamicComponent>();
            BDDExtensionRunner runner = UnitTestUtility.CreateComponent <BDDExtensionRunner>(component.gameObject);

            BaseBDDComponentEditorBusinessLogic unityTestBDDComponentBaseEditorBusinessLogic = new BaseBDDComponentEditorBusinessLogic(component);
            string expectedMessage          = "Message";
            List <UnityTestBDDError> errors = new List <UnityTestBDDError>();
            UnityTestBDDError        error  = new UnityTestBDDError();

            error.Message          = expectedMessage;
            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(expectedMessage, 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();
            });
        }