Beispiel #1
0
 public LoggedTheoryTestCase(
     IMessageSink diagnosticMessageSink,
     TestMethodDisplay defaultMethodDisplay,
     ITestMethod testMethod)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod)
 {
 }
 public KuduXunitTheoryTestCase(IMessageSink diagnosticMessageSink,
                                TestMethodDisplay defaultMethodDisplay,
                                ITestMethod testMethod,
                                IAttributeInfo testAttribute)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod)
 {
 }
Beispiel #3
0
 // ReSharper disable once UnusedMember.Global
 public TheoryTestCase(
     IMessageSink diagnosticMessageSink,
     TestMethodDisplay defaultMethodDisplay,
     ITestMethod testMethod)
     : this(diagnosticMessageSink, defaultMethodDisplay, TestMethodDisplayOptions.None, testMethod)
 {
 }
        /// <inheritdoc />
        public virtual IEnumerable <IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
        {
            Requires.NotNull(factAttribute, nameof(factAttribute));
            string[]          skippingExceptionNames = SkippableFactDiscoverer.GetSkippableExceptionNames(factAttribute);
            TestMethodDisplay defaultMethodDisplay   = discoveryOptions.MethodDisplayOrDefault();

            IEnumerable <IXunitTestCase>?basis = this.theoryDiscoverer.Discover(discoveryOptions, testMethod, factAttribute);

            foreach (IXunitTestCase?testCase in basis)
            {
                if (testCase is XunitTheoryTestCase)
                {
#if NET45
                    yield return(new SkippableTheoryTestCase(skippingExceptionNames, this.diagnosticMessageSink, defaultMethodDisplay, testCase.TestMethod));
#else
                    yield return(new SkippableTheoryTestCase(skippingExceptionNames, this.diagnosticMessageSink, defaultMethodDisplay, discoveryOptions.MethodDisplayOptionsOrDefault(), testCase.TestMethod));
#endif
                }
                else
                {
#if NET45
                    yield return(new SkippableFactTestCase(skippingExceptionNames, this.diagnosticMessageSink, defaultMethodDisplay, testCase.TestMethod, testCase.TestMethodArguments));
#else
                    yield return(new SkippableFactTestCase(skippingExceptionNames, this.diagnosticMessageSink, defaultMethodDisplay, discoveryOptions.MethodDisplayOptionsOrDefault(), testCase.TestMethod, testCase.TestMethodArguments));
#endif
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="XunitTheoryTestCase"/> class.
 /// </summary>
 /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages</param>
 /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param>
 /// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param>
 /// <param name="testMethod">The method under test.</param>
 public XunitTheoryTestCase(IMessageSink diagnosticMessageSink,
                            TestMethodDisplay defaultMethodDisplay,
                            TestMethodDisplayOptions defaultMethodDisplayOptions,
                            ITestMethod testMethod)
     : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod)
 {
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="DisplayNameFormatter"/> class.
        /// </summary>
        /// <param name="display">The <see cref="TestMethodDisplay"/> used by the formatter.</param>
        /// <param name="displayOptions">The <see cref="TestMethodDisplayOptions"/> used by the formatter.</param>
        public DisplayNameFormatter(TestMethodDisplay display, TestMethodDisplayOptions displayOptions)
        {
            rule = new CharacterRule();

            if ((displayOptions & UseEscapeSequences) == UseEscapeSequences)
            {
                rule = new ReplaceEscapeSequenceRule() { Next = rule };
            }

            if ((displayOptions & ReplaceUnderscoreWithSpace) == ReplaceUnderscoreWithSpace)
            {
                rule = new ReplaceUnderscoreRule() { Next = rule };
            }

            if ((displayOptions & UseOperatorMonikers) == UseOperatorMonikers)
            {
                rule = new ReplaceOperatorMonikerRule() { Next = rule };
            }

            if (display == ClassAndMethod)
            {
                if ((displayOptions & ReplacePeriodWithComma) == ReplacePeriodWithComma)
                {
                    rule = new ReplacePeriodRule() { Next = rule };
                }
                else
                {
                    rule = new KeepPeriodRule() { Next = rule };
                }
            }
        }
 public ExecutionErrorTestCase(IMessageSink diagnosticMessageSink,
                               TestMethodDisplay defaultMethodDisplay,
                               ITestMethod testMethod,
                               string errorMessage)
     : this(diagnosticMessageSink, defaultMethodDisplay, TestMethodDisplayOptions.None, testMethod, errorMessage)
 {
 }
Beispiel #8
0
 public KuduXunitTheoryTestCase(IMessageSink diagnosticMessageSink,
                                TestMethodDisplay defaultMethodDisplay,
                                ITestMethod testMethod,
                                IAttributeInfo testAttribute)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod)
 {
 }
Beispiel #9
0
 public RetryTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod,
                      int maxRetries, int timeSleep)
     : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments: null)
 {
     mMaxRetries = maxRetries;
     mTimeSleep  = timeSleep;
 }
Beispiel #10
0
 public AutofacTestCase(IMessageSink diagnosticMessageSink,
                        TestMethodDisplay defaultMethodDisplay,
                        ITestMethod testMethod,
                        object[] testMethodArguments = null)
     : base(diagnosticMessageSink, defaultMethodDisplay, TestMethodDisplayOptions.All, testMethod, testMethodArguments)
 {
 }
Beispiel #11
0
 public SkippedTestCase(
     string skipReason, IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay,
     TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, object[] testMethodArguments = null)
     : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments)
 {
     _skipReason = skipReason;
 }
Beispiel #12
0
 public XunitTestCase(IMessageSink diagnosticMessageSink,
                      TestMethodDisplay defaultMethodDisplay,
                      ITestMethod testMethod,
                      object[] testMethodArguments = null)
     : this(diagnosticMessageSink, defaultMethodDisplay, TestMethodDisplayOptions.None, testMethod, testMethodArguments)
 {
 }
Beispiel #13
0
        bool FindTestsForMethod(ITestMethod testMethod,
                                TestMethodDisplay defaultMethodDisplay,
                                bool includeSourceInformation,
                                IMessageBus messageBus)
        {
            var observationAttribute = testMethod.Method.GetCustomAttributes(typeof(FactAttribute)).FirstOrDefault();

            if (observationAttribute == null)
            {
                return(true);
            }

            var testCase = new ObservationTestCase(defaultMethodDisplay, testMethod);

            var skipReason = GetSkipReason(observationAttribute);

            if (!string.IsNullOrWhiteSpace(skipReason))
            {
                var skipTestCase = new SkippedTestCase(defaultMethodDisplay, testMethod);
                skipTestCase.SetSkipReason(skipReason);
                testCase = skipTestCase;
            }

            if (!ReportDiscoveredTestCase(testCase, includeSourceInformation, messageBus))
            {
                return(false);
            }

            return(true);
        }
Beispiel #14
0
 public FlakySystemTestCases(IMessageSink diagnosticMessageSink, TestMethodDisplay testMethodDisplay,
                             ITestMethod testMethod, int maxRetries, Type exceptionToIgnoreTest)
     : base(diagnosticMessageSink, testMethodDisplay, TestMethodDisplayOptions.None, testMethod, testMethodArguments: null)
 {
     this._maxRetries       = maxRetries;
     _exceptionToIgnoreTest = exceptionToIgnoreTest;
 }
Beispiel #15
0
        /// <inheritdoc/>
        public IEnumerable <IXunitTestCase> Discover(TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod, IAttributeInfo factAttribute)
        {
            // Special case Skip, because we want a single Skip (not one per data item), and a skipped test may
            // not actually have any data (which is quasi-legal, since it's skipped).
            if (factAttribute.GetNamedArgument <string>("Skip") != null)
            {
                return new[] { new XunitTestCase(defaultMethodDisplay, testMethod) }
            }
            ;

            var dataAttributes = testMethod.Method.GetCustomAttributes(typeof(DataAttribute));

            try
            {
                using (var memoryStream = new MemoryStream())
                {
                    var results = new List <XunitTestCase>();

                    foreach (var dataAttribute in dataAttributes)
                    {
                        var discovererAttribute = dataAttribute.GetCustomAttributes(typeof(DataDiscovererAttribute)).First();
                        var discoverer          = ExtensibilityPointFactory.GetDataDiscoverer(discovererAttribute);
                        if (!discoverer.SupportsDiscoveryEnumeration(dataAttribute, testMethod.Method))
                        {
                            return new XunitTestCase[] { new XunitTheoryTestCase(defaultMethodDisplay, testMethod) }
                        }
                        ;

                        // GetData may return null, but that's okay; we'll let the NullRef happen and then catch it
                        // down below so that we get the composite test case.
                        foreach (var dataRow in discoverer.GetData(dataAttribute, testMethod.Method))
                        {
                            // Attempt to serialize the test case, since we need a way to uniquely identify a test
                            // and serialization is the best way to do that. If it's not serializable, this will
                            // throw and we will fall back to a single theory test case that gets its data
                            // at runtime.
                            var testCase = new XunitTestCase(defaultMethodDisplay, testMethod, dataRow);

                            SerializationHelper.Serialize(testCase);
                            results.Add(testCase);
                        }
                    }

                    // REVIEW: Could we re-write LambdaTestCase to just be for exceptions?
                    if (results.Count == 0)
                    {
                        results.Add(new LambdaTestCase(defaultMethodDisplay, testMethod,
                                                       () => { throw new InvalidOperationException(String.Format("No data found for {0}.{1}", testMethod.TestClass.Class.Name, testMethod.Method.Name)); }));
                    }

                    return(results);
                }
            }
            catch
            {
                return(new XunitTestCase[] { new XunitTheoryTestCase(defaultMethodDisplay, testMethod) });
            }
        }
    }
 public KuduXunitTestCase(IMessageSink diagnosticMessageSink,
                          TestMethodDisplay testMethodDisplay,
                          ITestMethod testMethod,
                          object[] testMethodArguments,
                          IAttributeInfo testAttribute)
     : base(diagnosticMessageSink, testMethodDisplay, testMethod, testMethodArguments)
 {
 }
Beispiel #17
0
 public KuduXunitTheoryTestCase(IMessageSink diagnosticMessageSink,
                                TestMethodDisplay defaultMethodDisplay,
                                ITestMethod testMethod,
                                IAttributeInfo testAttribute)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod)
 {
     DisableRetry = testAttribute == null ? true : testAttribute.GetNamedArgument<bool>("DisableRetry");
 }
Beispiel #18
0
 public ParallelTestCase(
     IMessageSink diagnosticMessageSink,
     TestMethodDisplay defaultMethodDisplay,
     ITestMethod testMethod,
     object[] testMethodArguments = null)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod, testMethodArguments)
 {
 }
#pragma warning restore 618

    public FusonicTestCase(
        IMessageSink diagnosticMessageSink,
        TestMethodDisplay defaultMethodDisplay,
        TestMethodDisplayOptions defaultMethodDisplayOptions,
        ITestMethod testMethod,
        object[]?testMethodArguments = null) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments)
    {
    }
Beispiel #20
0
 public DataCompatibilityRangeTestCase(
     IMessageSink diagnosticMessageSink,
     TestMethodDisplay defaultMethodDisplay,
     ITestMethod testMethod,
     object[] testMethodArguments)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod, testMethodArguments)
 {
 }
Beispiel #21
0
 public KuduXunitTestCase(IMessageSink diagnosticMessageSink,
                          TestMethodDisplay testMethodDisplay,
                          ITestMethod testMethod,
                          object[] testMethodArguments,
                          IAttributeInfo testAttribute)
     : base(diagnosticMessageSink, testMethodDisplay, testMethod, testMethodArguments)
 {
 }
Beispiel #22
0
 public GeneratorDoubleCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod,
                            int dataNumber, double maxValue, double minValue)
     : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments: null)
 {
     mDataNumber = dataNumber;
     mMaxValue   = maxValue;
     mMinValue   = minValue;
 }
Beispiel #23
0
 public ExecutionErrorScenarioTestCase(IMessageSink diagnosticMessageSink,
                                       TestMethodDisplay methodDisplayOrDefault, TestMethodDisplayOptions methodDisplayOptionsOrDefault,
                                       ITestMethod testMethod, IScenarioIdentifier scenarioIdentifier, string errorMessage)
     : base(diagnosticMessageSink, methodDisplayOrDefault, methodDisplayOptionsOrDefault, testMethod,
            errorMessage)
 {
     _scenarioIdentifier = scenarioIdentifier ?? throw new ArgumentNullException(nameof(scenarioIdentifier));
 }
Beispiel #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XunitTestCase"/> class.
 /// </summary>
 /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages</param>
 /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param>
 /// <param name="testMethod">The test method this test case belongs to.</param>
 /// <param name="testMethodArguments">The arguments for the test method.</param>
 public XunitTestCase(IMessageSink diagnosticMessageSink,
                      TestMethodDisplay defaultMethodDisplay,
                      ITestMethod testMethod,
                      object[] testMethodArguments = null)
     : base(defaultMethodDisplay, testMethod, testMethodArguments)
 {
     this.diagnosticMessageSink = diagnosticMessageSink;
 }
Beispiel #25
0
 public InterpreterTestCase(
     IMessageSink diagnosticMessageSink,
     TestMethodDisplay defaultMethodDisplay,
     ITestMethod testMethod,
     object[] testMethodArguments
     ) : base(diagnosticMessageSink, defaultMethodDisplay, testMethod, testMethodArguments)
 {
 }
 public WORKAROUND_SkippedDataRowTestCase(IMessageSink diagnosticMessageSink,
                                          TestMethodDisplay defaultMethodDisplay,
                                          ITestMethod testMethod,
                                          string skipReason,
                                          object[] testMethodArguments = null)
     : this(diagnosticMessageSink, defaultMethodDisplay, TestMethodDisplayOptions.None, testMethod, skipReason, testMethodArguments)
 {
 }
Beispiel #27
0
 public MigrationsTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, DatabaseProvider provider, ProgrammingLanguage language)
     : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod)
 {
     _provider   = provider;
     _language   = language;
     DisplayName = string.Format(
         "{0} - DatabaseProvider: {1}, ProgrammingLanguage: {2}", DisplayName, _provider, _language);
 }
 public ScenarioReportingXunitTestCase(
     IMessageSink diagnosticMessageSink,
     TestMethodDisplay defaultMethodDisplay,
     ITestMethod testMethod,
     object[] testMethodArguments = null)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod, testMethodArguments)
 {
 }
Beispiel #29
0
 public DataCompatibilityRangeTheoryTestCase(
     CompatibilityLevel compatibilityLevel,
     IMessageSink diagnosticMessageSink,
     TestMethodDisplay defaultMethodDisplay,
     ITestMethod testMethod)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod, new object[] { compatibilityLevel })
 {
 }
 public KuduXunitTheoryTestCase(IMessageSink diagnosticMessageSink,
                                TestMethodDisplay defaultMethodDisplay,
                                ITestMethod testMethod,
                                IAttributeInfo testAttribute)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod)
 {
     DisableRetry = testAttribute == null ? true : testAttribute.GetNamedArgument <bool>("DisableRetry");
 }
Beispiel #31
0
 public GeneratorStringCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod,
                            int dataNumber, int maxSize, int minSize)
     : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments: null)
 {
     mDataNumber = dataNumber;
     mMaxSize    = maxSize;
     mMinSize    = minSize;
 }
 public BrowserTestCase(
     IMessageSink diagnosticMessageSink,
     TestMethodDisplay defaultMethodDisplay,
     ITestMethod testMethod,
     object[] testMethodArguments = null)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod, testMethodArguments)
 {
 }
Beispiel #33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XunitTestCase"/> class.
 /// </summary>
 /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages</param>
 /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param>
 /// <param name="testMethod">The test method this test case belongs to.</param>
 /// <param name="testMethodArguments">The arguments for the test method.</param>
 public XunitTestCase(IMessageSink diagnosticMessageSink,
                      TestMethodDisplay defaultMethodDisplay,
                      ITestMethod testMethod,
                      object[] testMethodArguments = null)
     : base(defaultMethodDisplay, testMethod, testMethodArguments)
 {
     this.diagnosticMessageSink = diagnosticMessageSink;
 }
Beispiel #34
0
 public MettleTestCase(IMessageSink diagnosticMessageSink,
                       TestMethodDisplay defaultMethodDisplay,
                       ITestMethod testMethod,
                       IServiceProvider serviceProvider,
                       object[] testMethodArguments = null)
     : this(diagnosticMessageSink, defaultMethodDisplay, TestMethodDisplayOptions.None, testMethod, serviceProvider, testMethodArguments)
 {
 }
 public MultipleScenariosTestCase(IMessageSink diagnosticMessageSink,
                                  TestMethodDisplay defaultMethodDisplay,
                                  TestMethodDisplayOptions defaultMethodDisplayOptions,
                                  ITestMethod testMethod,
                                  object[] testMethodArguments = null) : base(diagnosticMessageSink, defaultMethodDisplay,
                                                                              defaultMethodDisplayOptions, testMethod,
                                                                              testMethodArguments)
 {
 }
Beispiel #36
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="UITestCase" /> class.
 /// </summary>
 /// <param name="synchronizationContextType">The type of <see cref="SynchronizationContext" /> to use.</param>
 /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages</param>
 /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param>
 /// <param name="testMethod">The test method this test case belongs to.</param>
 /// <param name="testMethodArguments">The arguments for the test method.</param>
 public UITestCase(
     SyncContextType synchronizationContextType,
     IMessageSink diagnosticMessageSink,
     TestMethodDisplay defaultMethodDisplay,
     ITestMethod testMethod,
     object[] testMethodArguments = null)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod, testMethodArguments) {
     this.synchronizationContextType = synchronizationContextType;
 }
Beispiel #37
0
 public RetryTestCase(
     IMessageSink diagnosticMessageSink, 
     TestMethodDisplay testMethodDisplay, 
     ITestMethod testMethod, 
     int maxRetries)
     : base(diagnosticMessageSink, testMethodDisplay, testMethod, testMethodArguments: null)
 {
     this.maxRetries = maxRetries;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CulturedXunitTheoryTestCase"/> class.
 /// </summary>
 /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages</param>
 /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param>
 /// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param>
 /// <param name="testMethod">The method under test.</param>
 public CulturedXunitTheoryTestCase(IMessageSink diagnosticMessageSink,
                                    TestMethodDisplay defaultMethodDisplay,
                                    TestMethodDisplayOptions defaultMethodDisplayOptions,
                                    ITestMethod testMethod,
                                    string culture)
     : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod)
 {
     Initialize(culture);
 }
Beispiel #39
0
 public KuduXunitTestCase(IMessageSink diagnosticMessageSink,
                          TestMethodDisplay testMethodDisplay,
                          ITestMethod testMethod,
                          object[] testMethodArguments,
                          IAttributeInfo testAttribute)
     : base(diagnosticMessageSink, testMethodDisplay, testMethod, testMethodArguments)
 {
     DisableRetry = testAttribute == null ? true : testAttribute.GetNamedArgument<bool>("DisableRetry");
 }
 public FarmDependentTestCase(
     IMessageSink diagnosticMessageSink,
     TestMethodDisplay defaultMethodDisplay,
     ITestMethod testMethod,
     Object[] testMethodArguments = null
 )
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod, testMethodArguments)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ExecutionErrorTestCase"/> class.
 /// </summary>
 /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages</param>
 /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param>
 /// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param>
 /// <param name="testMethod">The test method.</param>
 /// <param name="errorMessage">The error message to report for the test.</param>
 public ExecutionErrorTestCase(
     IMessageSink diagnosticMessageSink,
     TestMethodDisplay defaultMethodDisplay,
     TestMethodDisplayOptions defaultMethodDisplayOptions,
     ITestMethod testMethod,
     string errorMessage)
     : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod)
 {
     ErrorMessage = errorMessage;
 }
 public CulturedXunitTestCase(
     IMessageSink diagnosticMessageSink,
     TestMethodDisplay defaultMethodDisplay,
     TestMethodDisplayOptions defaultMethodDisplayOptions,
     ITestMethod testMethod,
     string culture)
     : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod)
 {
     Initialize(culture);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="XunitSkippedDataRowTestCase"/> class.
 /// </summary>
 /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages</param>
 /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param>
 /// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param>
 /// <param name="testMethod">The test method this test case belongs to.</param>
 /// <param name="skipReason">The reason that this test case will be skipped</param>
 /// <param name="testMethodArguments">The arguments for the test method.</param>
 public XunitSkippedDataRowTestCase(
     IMessageSink diagnosticMessageSink,
     TestMethodDisplay defaultMethodDisplay,
     TestMethodDisplayOptions defaultMethodDisplayOptions,
     ITestMethod testMethod,
     string skipReason,
     object[] testMethodArguments = null) : 
     base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments)
 {
     this.skipReason = skipReason;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TestMethodTestCase"/> class.
 /// </summary>
 /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param>
 /// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param>
 /// <param name="testMethod">The test method this test case belongs to.</param>
 /// <param name="testMethodArguments">The arguments for the test method.</param>
 protected TestMethodTestCase(
     TestMethodDisplay defaultMethodDisplay,
     TestMethodDisplayOptions defaultMethodDisplayOptions,
     ITestMethod testMethod,
     object[] testMethodArguments = null)
 {
     DefaultMethodDisplay = defaultMethodDisplay;
     DefaultMethodDisplayOptions = defaultMethodDisplayOptions;
     formatter = new DisplayNameFormatter(defaultMethodDisplay, defaultMethodDisplayOptions);
     TestMethod = testMethod;
     TestMethodArguments = testMethodArguments;
 }
        bool FindTestsForMethod(ITestMethod testMethod,
                                TestMethodDisplay defaultMethodDisplay,
                                bool includeSourceInformation,
                                IMessageBus messageBus)
        {
            var observationAttribute = testMethod.Method.GetCustomAttributes(typeof(ObservationAttribute)).FirstOrDefault();
            if (observationAttribute == null)
                return true;

            var testCase = new ObservationTestCase(defaultMethodDisplay, testMethod);
            if (!ReportDiscoveredTestCase(testCase, includeSourceInformation, messageBus))
                return false;

            return true;
        }
 public InvariantTestCase
   ( IMessageSink diagnosticMessageSink
   , TestMethodDisplay defaultMethodDisplay
   , ITestMethod testMethod
   , Invariant inv
   , object[] testMethodArguments = null
   )
     : base
     ( diagnosticMessageSink
     , defaultMethodDisplay
     , testMethod
     , testMethodArguments
     )
 {
     Inv = inv;
 }
        bool FindTestsForMethod(ITestMethod testMethod,
                                TestMethodDisplay defaultMethodDisplay,
                                bool includeSourceInformation,
                                IMessageBus messageBus)
        {
            var observationAttribute = testMethod.Method.GetCustomAttributes(typeof(FactAttribute)).FirstOrDefault(); 
            if (observationAttribute == null)
                return true;

            var testCase = new ObservationTestCase(defaultMethodDisplay, testMethod);

            var skipReason = GetSkipReason(observationAttribute);
            if (!string.IsNullOrWhiteSpace(skipReason))
            {
                var skipTestCase = new SkippedTestCase(defaultMethodDisplay, testMethod);
                skipTestCase.SetSkipReason(skipReason);
                testCase = skipTestCase;
            }
            
            if (!ReportDiscoveredTestCase(testCase, includeSourceInformation, messageBus))
                return false;

            return true;
        }
Beispiel #48
0
 public WpfTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod, SemaphoreSlim wpfTestSerializationGate, object[] testMethodArguments = null)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod, testMethodArguments)
 {
     _wpfTestSerializationGate = wpfTestSerializationGate;
 }
 public ObservationTestCase(TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod)
     : base(defaultMethodDisplay, testMethod) { }
 public ScenarioTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod, null)
 {
 }
 public SkipXunitTheoryTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod)
 {
 }
 public TestForTypesXunitTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod, Type testMethodArgumentType)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod, new object[] { testMethodArgumentType })
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SkippableFactTestCase"/> class.
 /// </summary>
 /// <param name="skippingExceptionNames">An array of the full names of the exception types which should be interpreted as a skipped test-.</param>
 /// <param name="diagnosticMessageSink">The diagnostic message sink.</param>
 /// <param name="defaultMethodDisplay">The preferred test name derivation.</param>
 /// <param name="testMethod">The test method.</param>
 /// <param name="testMethodArguments">The test method arguments.</param>
 public SkippableFactTestCase(string[] skippingExceptionNames, IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod, object[] testMethodArguments = null)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod, testMethodArguments)
 {
     Requires.NotNull(skippingExceptionNames, nameof(skippingExceptionNames));
     this.SkippingExceptionNames = skippingExceptionNames;
 }
Beispiel #54
0
 public PerformanceTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay testMethodDisplay, ITestMethod testMethod)
     : base(diagnosticMessageSink, testMethodDisplay, testMethod)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SkippableTheoryTestCase"/> class.
 /// </summary>
 /// <param name="skippingExceptionNames">An array of the full names of the exception types which should be interpreted as a skipped test-.</param>
 /// <param name="diagnosticMessageSink">The diagnostic message sink.</param>
 /// <param name="defaultMethodDisplay">The preferred test name derivation.</param>
 /// <param name="testMethod">The test method.</param>
 public SkippableTheoryTestCase(string[] skippingExceptionNames, IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod)
 {
     Requires.NotNull(skippingExceptionNames, nameof(skippingExceptionNames));
     this.SkippingExceptionNames = skippingExceptionNames;
 }
 public WritePerformanceTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay testMethodDisplay, ITestMethod testMethod, bool forceDelimit)
     : base(diagnosticMessageSink, testMethodDisplay, testMethod)
 {
     this.forceDelimit = forceDelimit;
     this.TestMethodArguments = new object[] { this.forceDelimit };
 }
 public ReadPerformanceTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay testMethodDisplay, ITestMethod testMethod, WhiteSpacePreservation whiteSpacePreservation)
     : base(diagnosticMessageSink, testMethodDisplay, testMethod)
 {
     this.whiteSpacePreservation = whiteSpacePreservation;
     this.TestMethodArguments = new object[] { this.whiteSpacePreservation };
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="XunitTheoryTestCase"/> class.
 /// </summary>
 /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages</param>
 /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param>
 /// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param>
 /// <param name="testMethod">The method under test.</param>
 public XunitTheoryTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod)
     : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) { }
 /// <summary>
 /// Sets a flag that determines the default display name format for test methods.
 /// </summary>
 public static void SetMethodDisplay(this ITestFrameworkDiscoveryOptions discoveryOptions, TestMethodDisplay? value)
 {
     discoveryOptions.SetValue(TestOptionsNames.Discovery.MethodDisplay, value.HasValue ? value.GetValueOrDefault().ToString() : null);
 }
 public SkippedTestCase(TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod)
     : base(defaultMethodDisplay, testMethod)
 { }