public void DiscoveryOptions_PreEnumerateTheoriesSetToFalse_YieldsSingleTheoryTestCase() { discoveryOptions.SetValue(TestOptionsNames.Discovery.PreEnumerateTheories, false); var discoverer = new TheoryDiscoverer(); var testMethod = Mocks.TestMethod(typeof(MultipleDataClass), "TheoryMethod"); var factAttribute = testMethod.Method.GetCustomAttributes(typeof(FactAttribute)).Single(); var testCases = discoverer.Discover(discoveryOptions, testMethod, factAttribute); var testCase = Assert.Single(testCases); var theoryTestCase = Assert.IsType <XunitTheoryTestCase>(testCase); Assert.Equal("TheoryDiscovererTests+MultipleDataClass.TheoryMethod", theoryTestCase.DisplayName); }
public async void DiscoveryOptions_PreEnumerateTheoriesSetToFalse_YieldsSingleTestCase() { discoveryOptions.SetPreEnumerateTheories(false); var discoverer = new TheoryDiscoverer(); var testMethod = Mocks.TestMethod <MultipleDataClass>(nameof(MultipleDataClass.TheoryMethod)); var factAttribute = testMethod.Method.GetCustomAttributes(typeof(FactAttribute)).Single(); var testCases = await discoverer.Discover(discoveryOptions, testMethod, factAttribute); var testCase = Assert.Single(testCases); Assert.IsType <XunitDelayEnumeratedTheoryTestCase>(testCase); Assert.Equal($"{typeof(MultipleDataClass).FullName}.{nameof(MultipleDataClass.TheoryMethod)}", testCase.TestCaseDisplayName); }
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(discoveryOptions, testMethod, theoryAttribute); var testCase = Assert.Single(testCases); var theoryTestCase = Assert.IsType <XunitTheoryTestCase>(testCase); Assert.Equal("MockType.MockMethod", theoryTestCase.DisplayName); }
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 void NonSerializableDataYieldsSingleTheoryTestCase() { var testCollection = new XunitTestCollection(); 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(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+NonSerializableDataClass.TheoryMethod", theoryTestCase.DisplayName); }
public async void DiscoveryOptions_PreEnumerateTheoriesSetToTrue_YieldsTestCasePerDataRow() { discoveryOptions.SetPreEnumerateTheories(true); var discoverer = new TheoryDiscoverer(); var testMethod = Mocks.TestMethod <MultipleDataClass>(nameof(MultipleDataClass.TheoryMethod)); var factAttribute = testMethod.Method.GetCustomAttributes(typeof(FactAttribute)).Single(); var testCases = (await discoverer.Discover(discoveryOptions, testMethod, factAttribute)).ToList(); Assert.Collection( testCases.Select(tc => tc.TestCaseDisplayName).OrderBy(x => x), displayName => Assert.Equal($"{typeof(MultipleDataClass).FullName}.{nameof(MultipleDataClass.TheoryMethod)}(x: 2112)", displayName), displayName => Assert.Equal($"{typeof(MultipleDataClass).FullName}.{nameof(MultipleDataClass.TheoryMethod)}(x: 42)", displayName) ); }
public void DataDiscovererReturningNullYieldsSingleTheoryTestCase() { var testCollection = new XunitTestCollection(); 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(testCollection, assembly, type, method, theory); var testCase = Assert.Single(testCases); var theoryTestCase = Assert.IsType <XunitTheoryTestCase>(testCase); Assert.Equal("MockType.MockMethod", theoryTestCase.DisplayName); }
/// <nodoc /> public IEnumerable <IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) { return(_theoryDiscoverer .Discover(discoveryOptions, testMethod, factAttribute) .Select(testCase => new MtaTestCase(testCase))); }
public IEnumerable <IXunitTestCase> Discover( ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) => _discoverer.Discover(discoveryOptions, testMethod, factAttribute) .Select(testCase => new CustomTestCase(testCase));
public IEnumerable <IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) { return(_inner.Discover(discoveryOptions, testMethod, factAttribute).Select(t => new ForegroundFactTestCase(t))); }