// Returns a list of strings of trace records we did not expect.
        // If you experience failures from this list, it means someone added new traces
        // or changed the contents of the traces.
        // Update the ExpectedTraceRecords property to reflect what is expected.
        private static IList <string> UnexpectedTraces(IList <ExpectedTraceRecord> expectedRecords, IList <TraceRecord> actualRecords)
        {
            List <string> unexpected = new List <string>();

            foreach (TraceRecord actualRecord in actualRecords)
            {
                // Ignore record of a ReflectionTypeLoadException to allow test to succeed in Visual Studio. The record is an
                // artifact specific to testing in VS. (Attempting to load all types from xunit.runner.visualstudio.testadapter.dll
                // fails with recent xUnit.net packages. The assembly references Microsoft.VisualStudio.TestPlatform.ObjectModel.dll
                // which is not available with xUnit.net 2.0.x.)
                if (actualRecord.Operation == null &&
                    actualRecord.Exception is ReflectionTypeLoadException &&
                    actualRecord.Message != null &&
                    actualRecord.Message.StartsWith(
                        "Exception thrown while getting types from 'xunit.runner.visualstudio.testadapter, ",
                        StringComparison.Ordinal))
                {
                    continue;
                }

                ExpectedTraceRecord expectedTrace = expectedRecords.FirstOrDefault(r =>
                                                                                   String.Equals(r.Category, actualRecord.Category, StringComparison.OrdinalIgnoreCase) &&
                                                                                   String.Equals(r.OperatorName, actualRecord.Operator, StringComparison.OrdinalIgnoreCase) &&
                                                                                   String.Equals(r.OperationName, actualRecord.Operation, StringComparison.OrdinalIgnoreCase));

                if (expectedTrace == null)
                {
                    unexpected.Add(string.Format("kind={0} category={1}, operator={2}, operation={3}",
                                                 actualRecord.Kind, actualRecord.Category, actualRecord.Operator, actualRecord.Operation));
                }
            }

            return(unexpected);
        }
Exemple #2
0
        // Returns a list of strings of trace records we did not expect.
        // If you experience failures from this list, it means someone added new traces
        // or changed the contents of the traces.
        // Update the ExpectedTraceRecords property to reflect what is expected.
        private static IList <string> UnexpectedTraces(IList <ExpectedTraceRecord> expectedRecords, IList <TraceRecord> actualRecords)
        {
            List <string> unexpected = new List <string>();

            foreach (TraceRecord actualRecord in actualRecords)
            {
                ExpectedTraceRecord expectedTrace = expectedRecords.FirstOrDefault(r =>
                                                                                   String.Equals(r.Category, actualRecord.Category, StringComparison.OrdinalIgnoreCase) &&
                                                                                   String.Equals(r.OperatorName, actualRecord.Operator, StringComparison.OrdinalIgnoreCase) &&
                                                                                   String.Equals(r.OperationName, actualRecord.Operation, StringComparison.OrdinalIgnoreCase));

                if (expectedTrace == null)
                {
                    unexpected.Add(string.Format("kind={0} category={1}, operator={2}, operation={3}",
                                                 actualRecord.Kind, actualRecord.Category, actualRecord.Operator, actualRecord.Operation));
                }
            }

            return(unexpected);
        }