|
| 1 | +using System.Collections.Concurrent; |
| 2 | + |
| 3 | +namespace MSTestCombinatorial.Tests; |
| 4 | + |
| 5 | +[TestClass] |
| 6 | +public class SampleUseTests |
| 7 | +{ |
| 8 | + private static ConcurrentDictionary<(string, string), byte> s_test1Inputs = null!; |
| 9 | + private static ConcurrentDictionary<(bool, bool?), byte> s_test2Inputs = null!; |
| 10 | + private static ConcurrentDictionary<int, byte> s_test3Inputs = null!; |
| 11 | + private static ConcurrentDictionary<int, byte> s_test4Inputs = null!; |
| 12 | + |
| 13 | + [ClassInitialize] |
| 14 | + public static void ClassInit(TestContext _) |
| 15 | + { |
| 16 | + s_test1Inputs = new(); |
| 17 | + s_test2Inputs = new(); |
| 18 | + s_test3Inputs = new(); |
| 19 | + s_test4Inputs = new(); |
| 20 | + } |
| 21 | + |
| 22 | + [TestMethod] |
| 23 | + [CombinatorialData] |
| 24 | + public void Test1( |
| 25 | + [CombinatorialValues("1", "2", "3")] string x, |
| 26 | + [CombinatorialValues("A", "B", "C", "D")] string y) |
| 27 | + { |
| 28 | + s_test1Inputs.TryAdd((x, y), 0); |
| 29 | + } |
| 30 | + |
| 31 | + [TestMethod] |
| 32 | + [CombinatorialData] |
| 33 | + public void Test2( |
| 34 | + bool x, |
| 35 | + bool? y) |
| 36 | + { |
| 37 | + s_test2Inputs.TryAdd((x, y), 0); |
| 38 | + } |
| 39 | + |
| 40 | + [TestMethod] |
| 41 | + [CombinatorialData] |
| 42 | + public void Test3([CombinatorialRange(from: 0, count: 6)] int x) |
| 43 | + { |
| 44 | + s_test3Inputs.TryAdd(x, 0); |
| 45 | + } |
| 46 | + |
| 47 | + [TestMethod] |
| 48 | + [CombinatorialData] |
| 49 | + public void Test4([CombinatorialRandomData(Count = 8)] int x) |
| 50 | + { |
| 51 | + s_test4Inputs.TryAdd(x, 0); |
| 52 | + } |
| 53 | + |
| 54 | + [ClassCleanup(ClassCleanupBehavior.EndOfClass)] |
| 55 | + public static void ClassCleanup() |
| 56 | + { |
| 57 | + Assert.AreEqual(12, s_test1Inputs.Count); |
| 58 | + Assert.AreEqual(6, s_test2Inputs.Count); |
| 59 | + Assert.AreEqual(6, s_test3Inputs.Count); |
| 60 | + Assert.AreEqual(8, s_test4Inputs.Count); |
| 61 | + } |
| 62 | +} |
0 commit comments