public void Filter_Should_ReturnTrue_Given_AStaticComponentForAGivenMethodFilteringGivenMethods()
        {
            MethodsFilterByExecutionOrderTestStaticComponent component = UnitTestUtility.CreateComponent <MethodsFilterByExecutionOrderTestStaticComponent>();
            MethodInfo methodInfo = component.GetType().GetMethod("GivenMethod");
            MethodsFilterByExecutionOrder methodsFilterByExecutionOrder = new MethodsFilterByExecutionOrder();
            bool result = methodsFilterByExecutionOrder.Filter <GivenBaseAttribute>(methodInfo);

            Assert.AreEqual(true, result, "The method MethodsFilterByStepType.Filter does not return the right answer");
        }
Esempio n. 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 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();
            });
        }
Esempio n. 4
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);
        }