public static void NoAttribute()
    {
        var assembly = Mocks.AssemblyInfo();

        var proxy = new TestFrameworkProxy(assembly, null);

        Assert.IsType<XunitTestFramework>(proxy.InnerTestFramework);
    }
    public static void Attribute_NoDiscoverer()
    {
        var attribute = Mocks.TestFrameworkAttribute(typeof(AttributeWithoutDiscoverer));
        var assembly = Mocks.AssemblyInfo(attributes: new[] { attribute });

        var proxy = new TestFrameworkProxy(assembly, null);

        Assert.IsType<XunitTestFramework>(proxy.InnerTestFramework);
    }
Example #3
0
    public void NoAttribute()
    {
        var assembly = Mocks.AssemblyInfo();

        var proxy = new TestFrameworkProxy(assembly, null, diagnosticSpy);

        Assert.IsType<XunitTestFramework>(proxy.InnerTestFramework);
        Assert.Empty(diagnosticMessages);
    }
Example #4
0
    public void Attribute_NoDiscoverer()
    {
        var attribute = Mocks.TestFrameworkAttribute(typeof(AttributeWithoutDiscoverer));
        var assembly = Mocks.AssemblyInfo(attributes: new[] { attribute });

        var proxy = new TestFrameworkProxy(assembly, null, diagnosticSpy);

        Assert.IsType<XunitTestFramework>(proxy.InnerTestFramework);
        AssertSingleDiagnosticMessage("Assembly-level test framework attribute was not decorated with [TestFrameworkDiscoverer]");
    }
    public void Attribute_ThrowingDiscovererMethod()
    {
        var attribute = Mocks.TestFrameworkAttribute(typeof(AttributeWithThrowingDiscovererMethod));
        var assembly = Mocks.AssemblyInfo(attributes: new[] { attribute });

        var proxy = new TestFrameworkProxy(assembly, null, diagnosticSpy);

        Assert.IsType<XunitTestFramework>(proxy.InnerTestFramework);
        AssertSingleDiagnosticMessage("Exception thrown during test framework discoverer construction: System.DivideByZeroException: Attempted to divide by zero.");
    }
    public static void Attribute_WithDiscoverer()
    {
        var attribute = Mocks.TestFrameworkAttribute(typeof(AttributeWithDiscoverer));
        var assembly = Mocks.AssemblyInfo(attributes: new[] { attribute });
        var sourceProvider = Substitute.For<ISourceInformationProvider>();

        var proxy = new TestFrameworkProxy(assembly, sourceProvider);

        var testFramework = Assert.IsType<MyTestFramework>(proxy.InnerTestFramework);
        Assert.Same(sourceProvider, testFramework.SourceInformationProvider);
    }
Example #7
0
    public void Attribute_WithDiscoverer_WithMessageSink()
    {
        var attribute = Mocks.TestFrameworkAttribute(typeof(AttributeWithDiscovererWithMessageSink));
        var assembly = Mocks.AssemblyInfo(attributes: new[] { attribute });
        var sourceProvider = Substitute.For<ISourceInformationProvider>();

        var proxy = new TestFrameworkProxy(assembly, sourceProvider, diagnosticSpy);

        var testFramework = Assert.IsType<MyTestFrameworkWithMessageSink>(proxy.InnerTestFramework);
        var wrapper = Assert.IsType<TestFrameworkProxy.MessageSinkWrapper>(testFramework.MessageSink);
        Assert.Same(diagnosticSpy, wrapper.InnerSink);
        Assert.Same(sourceProvider, testFramework.SourceInformationProvider);
        Assert.Empty(diagnosticMessages);
    }
Example #8
0
    public void Attribute_ThrowingTestFrameworkCtor()
    {
        Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;

        var attribute = Mocks.TestFrameworkAttribute(typeof(AttributeWithThrowingTestFrameworkCtor));
        var assembly = Mocks.AssemblyInfo(attributes: new[] { attribute });

        var proxy = new TestFrameworkProxy(assembly, null, diagnosticSpy);

        Assert.IsType<XunitTestFramework>(proxy.InnerTestFramework);
        AssertSingleDiagnosticMessage("Exception thrown during test framework construction: System.DivideByZeroException: Attempted to divide by zero.");
    }