コード例 #1
0
ファイル: FactDiscovererTests.cs プロジェクト: zabulus/xunit
    public async void FactWithoutParameters_ReturnsTestCaseThatRunsFact()
    {
        var discoverer = TestableFactDiscoverer.Create();
        var testMethod = Mocks.TestMethod(typeof(ClassUnderTest), "FactWithNoParameters");

        var testCases = discoverer.Discover(options, testMethod, factAttribute);

        var testCase = Assert.Single(testCases);
        await testCase.RunAsync(SpyMessageSink.Create(), messageBus, new object[0], aggregator, cancellationTokenSource);

        Assert.Single(messageBus.Messages.OfType <ITestPassed>());
    }
コード例 #2
0
ファイル: FactDiscovererTests.cs プロジェクト: zabulus/xunit
    public async void FactWithParameters_ReturnsTestCaseWhichThrows()
    {
        var discoverer = TestableFactDiscoverer.Create();
        var testMethod = Mocks.TestMethod(typeof(ClassUnderTest), "FactWithParameters");

        var testCases = discoverer.Discover(options, testMethod, factAttribute);

        var testCase = Assert.Single(testCases);
        await testCase.RunAsync(SpyMessageSink.Create(), messageBus, new object[0], aggregator, cancellationTokenSource);

        var failed = Assert.Single(messageBus.Messages.OfType <ITestFailed>());

        Assert.Equal(typeof(InvalidOperationException).FullName, failed.ExceptionTypes.Single());
        Assert.Equal("[Fact] methods are not allowed to have parameters. Did you mean to use [Theory]?", failed.Messages.Single());
    }
コード例 #3
0
    public async void GenericFact_ReturnsTestCaseWhichThrows()
    {
        var discoverer = TestableFactDiscoverer.Create();
        var testMethod = Mocks.TestMethod <ClassUnderTest>("GenericFact");

        var testCases = discoverer.Discover(options, testMethod, factAttribute);

        var testCase = Assert.Single(testCases);
        await testCase.RunAsync(SpyMessageSink.Create(), messageBus, new object[0], aggregator, cancellationTokenSource);

        var failed = Assert.Single(messageBus.Messages.OfType <_TestFailed>());

        Assert.Equal(typeof(InvalidOperationException).FullName, failed.ExceptionTypes.Single());
        Assert.Equal("[Fact] methods are not allowed to be generic.", failed.Messages.Single());
    }