You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
919 B
C#
29 lines
919 B
C#
|
2 years ago
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Diagnostics;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Text;
|
||
|
|
using Xunit.Abstractions;
|
||
|
|
using Xunit.Sdk;
|
||
|
|
|
||
|
|
// ReSharper disable once CheckNamespace
|
||
|
|
namespace EntityFrameworkCore.Jet.FunctionalTests.TestUtilities.Xunit;
|
||
|
|
|
||
|
|
public class RandomTestCaseOrderer : ITestCaseOrderer
|
||
|
|
{
|
||
|
|
public IEnumerable<TTestCase> OrderTestCases<TTestCase>(IEnumerable<TTestCase> testCases)
|
||
|
|
where TTestCase : ITestCase
|
||
|
|
{
|
||
|
|
var random = new Random();
|
||
|
|
var orderedTestCases = testCases.OrderBy(c => random.NextDouble()).ToList();
|
||
|
|
|
||
|
|
var builder = new StringBuilder()
|
||
|
|
.AppendLine("Test Case Order:")
|
||
|
|
.AppendLine(string.Join(Environment.NewLine, orderedTestCases.Select(c => c.TestMethod.Method.Name)));
|
||
|
|
|
||
|
|
Debug.WriteLine(builder);
|
||
|
|
Console.WriteLine(builder);
|
||
|
|
|
||
|
|
return orderedTestCases;
|
||
|
|
}
|
||
|
|
}
|