OpenQA.Selenium.WebDriverTestDecorator.Decorate C# (CSharp) Method

Decorate() public method

public Decorate ( Test test, MemberInfo member ) : Test
test Test
member System.Reflection.MemberInfo
return Test
        public Test Decorate(Test test, MemberInfo member)
        {
            NUnitTestMethod testMethod = test as NUnitTestMethod;

            if (testMethod != null && testMethod.RunState == RunState.Runnable)
            {
                Attribute[] ignoreAttr = Reflect.GetAttributes(member, IgnoreBrowserAttributeTypeFullName, true);
                if (ignoreAttr != null)
                {
                    foreach (Attribute attr in ignoreAttr)
                    {
                        IgnoreBrowserAttribute browserToIgnoreAttr = attr as IgnoreBrowserAttribute;
                        if (browserToIgnoreAttr != null && IgnoreTestForBrowser(browserToIgnoreAttr.Value))
                        {
                            string ignoreReason = "Ignoring browser " + EnvironmentManager.Instance.Browser.ToString() + ".";
                            if (!string.IsNullOrEmpty(browserToIgnoreAttr.Reason))
                            {
                                ignoreReason = ignoreReason + " " + browserToIgnoreAttr.Reason;
                            }

                            test.RunState = RunState.Ignored;
                            test.IgnoreReason = ignoreReason;
                        }
                    }
                }

                if (test.RunState == RunState.Runnable)
                {
                    NeedsFreshDriverAttribute needsDriverAttr = Reflect.GetAttribute(member, NeedsFreshDriverAttributeTypeFullName, false) as NeedsFreshDriverAttribute;
                    if (needsDriverAttr != null)
                    {
                        test = new WebDriverTestMethod(testMethod, needsDriverAttr.BeforeTest, needsDriverAttr.AfterTest);
                    }
                }
            }

            return test;
        }