public void ThrowingData()
    {
        var discoverer = new TheoryDiscoverer();
        var testMethod = Mocks.TestMethod(typeof(ThrowingDataClass), "TheoryWithMisbehavingData");
        var factAttribute = testMethod.Method.GetCustomAttributes(typeof(FactAttribute)).Single();

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

        var testCase = Assert.Single(testCases);
        var theoryTestCase = Assert.IsType<XunitTheoryTestCase>(testCase);
        Assert.Equal("TheoryDiscovererTests+ThrowingDataClass.TheoryWithMisbehavingData", theoryTestCase.DisplayName);
    }
Example #2
0
    public void NonSerializableDataYieldsSingleTheoryTestCase()
    {
        var discoverer = new TheoryDiscoverer();
        var type = typeof(NonSerializableDataClass);
        var method = type.GetMethod("TheoryMethod");
        var theory = CustomAttributeData.GetCustomAttributes(method).Single(cad => cad.AttributeType == typeof(TheoryAttribute));

        var testCases = discoverer.Discover(Reflector.Wrap(type.Assembly), Reflector.Wrap(type), Reflector.Wrap(method), Reflector.Wrap(theory));

        var testCase = Assert.Single(testCases);
        var theoryTestCase = Assert.IsType<XunitTheoryTestCase>(testCase);
        Assert.Equal("TheoryDiscovererTests+NonSerializableDataClass.TheoryMethod", theoryTestCase.DisplayName);
    }
Example #3
0
    public void DataDiscovererReturningNullYieldsSingleTheoryTestCase()
    {
        var discoverer = new TheoryDiscoverer();
        var assembly = Mocks.AssemblyInfo();
        var type = Mocks.TypeInfo();
        var theory = Mocks.TheoryAttribute();
        var data = Substitute.For<IAttributeInfo>();
        var method = Mocks.MethodInfo();
        method.GetCustomAttributes(typeof(DataAttribute).AssemblyQualifiedName).Returns(new[] { data });
        method.GetCustomAttributes(typeof(TheoryAttribute).AssemblyQualifiedName).Returns(new[] { theory });

        var testCases = discoverer.Discover(assembly, type, method, theory);

        var testCase = Assert.Single(testCases);
        var theoryTestCase = Assert.IsType<XunitTheoryTestCase>(testCase);
        Assert.Equal("MockType.MockMethod", theoryTestCase.DisplayName);
    }
Example #4
0
    public void ThrowingData()
    {
        var testCollection = new XunitTestCollection();
        var discoverer = new TheoryDiscoverer();
        var type = typeof(ThrowingDataClass);
        var method = type.GetMethod("TheoryWithMisbehavingData");
        var theory = CustomAttributeData.GetCustomAttributes(method).Single(cad => cad.AttributeType == typeof(TheoryAttribute));

        var testCases = discoverer.Discover(testCollection, Reflector.Wrap(type.Assembly), Reflector.Wrap(type), Reflector.Wrap(method), Reflector.Wrap(theory));

        var testCase = Assert.Single(testCases);
        var theoryTestCase = Assert.IsType<XunitTheoryTestCase>(testCase);
        Assert.Equal("TheoryDiscovererTests+ThrowingDataClass.TheoryWithMisbehavingData", theoryTestCase.DisplayName);
    }
    public static void MixedDiscoveryEnumerationDataYieldSingleTheoryTestCase()
    {
        var discoverer = new TheoryDiscoverer();
        var testMethod = Mocks.TestMethod(typeof(MixedDiscoveryEnumeratedData), "TheoryMethod");
        var factAttribute = testMethod.Method.GetCustomAttributes(typeof(FactAttribute)).Single();

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

        var testCase = Assert.Single(testCases);
        var theoryTestCase = Assert.IsType<XunitTheoryTestCase>(testCase);
        Assert.Equal("TheoryDiscovererTests+MixedDiscoveryEnumeratedData.TheoryMethod", theoryTestCase.DisplayName);
    }
    public void NonSerializableDataYieldsSingleTheoryTestCase()
    {
        var discoverer = new TheoryDiscoverer();
        var testMethod = Mocks.TestMethod(typeof(NonSerializableDataClass), "TheoryMethod");
        var factAttribute = testMethod.Method.GetCustomAttributes(typeof(FactAttribute)).Single();

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

        var testCase = Assert.Single(testCases);
        var theoryTestCase = Assert.IsType<XunitTheoryTestCase>(testCase);
        Assert.Equal("TheoryDiscovererTests+NonSerializableDataClass.TheoryMethod", theoryTestCase.DisplayName);
    }
    public void DataDiscovererReturningNullYieldsSingleTheoryTestCase()
    {
        var discoverer = new TheoryDiscoverer();
        var theoryAttribute = Mocks.TheoryAttribute();
        var dataAttribute = Mocks.DataAttribute();
        var testMethod = Mocks.TestMethod(methodAttributes: new[] { theoryAttribute, dataAttribute });

        var testCases = discoverer.Discover(testMethod, theoryAttribute);

        var testCase = Assert.Single(testCases);
        var theoryTestCase = Assert.IsType<XunitTheoryTestCase>(testCase);
        Assert.Equal("MockType.MockMethod", theoryTestCase.DisplayName);
    }