Esempio n. 1
0
        public void HasEventListenerExtensionPoint()
        {
            IExtensionPoint ep = host.GetExtensionPoint("EventListeners");

            Assert.IsNotNull(ep);
            Assert.AreEqual("EventListeners", ep.Name);
            Assert.AreEqual(typeof(EventListenerCollection), ep.GetType());
        }
Esempio n. 2
0
        public void HasTestDecoratorsExtensionPoint()
        {
            IExtensionPoint ep = host.GetExtensionPoint("TestDecorators");

            Assert.IsNotNull(ep);
            Assert.AreEqual("TestDecorators", ep.Name);
            Assert.AreEqual(typeof(TestDecoratorCollection), ep.GetType());
        }
Esempio n. 3
0
        public void HasSuiteBuildersExtensionPoint()
        {
            IExtensionPoint ep = host.GetExtensionPoint("SuiteBuilders");

            Assert.IsNotNull(ep);
            Assert.AreEqual("SuiteBuilders", ep.Name);
            Assert.AreEqual(typeof(SuiteBuilderCollection), ep.GetType());
        }
Esempio n. 4
0
        public void HasTestFrameworkRegistry()
        {
            IExtensionPoint ep = host.GetExtensionPoint("FrameworkRegistry");

            Assert.IsNotNull(ep);
            Assert.AreEqual("FrameworkRegistry", ep.Name);
            Assert.AreEqual(typeof(FrameworkRegistry), ep.GetType());
        }
    static void ReplaceTestCaseProvidersWithWrapper(IExtensionPoint testCaseProviders)
    {
        // This may break in future versions of NUnit 2.6. It will definitely fail in NUnit 3.0
        var extensionsField = testCaseProviders
                              .GetType()
                              .GetProperty("Extensions", BindingFlags.NonPublic | BindingFlags.Instance);

        if (extensionsField == null)
        {
            throw new Exception(
                      string.Format(
                          "'{0}' does not have a property called 'Extensions'. Incompatible NUnit version, please update your add-in.",
                          testCaseProviders.GetType().FullName));
        }
        var extensions = (ExtensionsCollection)extensionsField.GetValue(testCaseProviders);
        var testCaseParameterProvider = extensions.OfType <TestCaseParameterProvider>().FirstOrDefault();
        var testCaseSourceProvider    = extensions.OfType <TestCaseSourceProvider>().FirstOrDefault();

        if (testCaseParameterProvider == null)
        {
            throw new Exception(
                      string.Format(
                          "Could not find an instance of '{0}' in the test case providers lists. Incompatible NUnit version, please update your add-in.",
                          typeof(TestCaseParameterProvider).FullName));
        }
        if (testCaseSourceProvider == null)
        {
            throw new Exception(
                      string.Format(
                          "Could not find an instance of '{0}' in the test case providers lists. Incompatible NUnit version, please update your add-in.",
                          typeof(TestCaseSourceProvider).FullName));
        }
        extensions.Remove(testCaseParameterProvider);
        extensions.Remove(testCaseSourceProvider);
        extensions.Add(
            new TestCaseProviderAutoMoqDataFilterWrapper(
                testCaseParameterProvider,
                typeof(TestCaseAttribute)));
        extensions.Add(
            new TestCaseProviderAutoMoqDataFilterWrapper(testCaseSourceProvider,
                                                         typeof(TestCaseSourceAttribute)));
    }
Esempio n. 6
0
        private IList GetSuiteBuildersList(IExtensionPoint extensionPoint)
        {
            Type type = extensionPoint.GetType();

            if (type.IsInterface)
            {
                type = type.UnderlyingSystemType;
            }

            FieldInfo[] fields = type.GetFields(
                BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            foreach (FieldInfo field in fields)
            {
                if (typeof(IList).IsAssignableFrom(field.FieldType))
                {
                    return((IList)field.GetValue(_extensionPoint));
                }
            }

            return(null);
        }