-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathLINQShufflerTests.cs
More file actions
60 lines (51 loc) · 1.7 KB
/
LINQShufflerTests.cs
File metadata and controls
60 lines (51 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using Algorithms.Shufflers;
using Algorithms.Tests.Helpers;
using FluentAssertions;
using NUnit.Framework;
using System;
namespace Algorithms.Tests.Shufflers
{
public static class LINQShufflerTests
{
[Test]
public static void ArrayShuffled_NewArraySameSize(
[Random(10, 1000, 100, Distinct = true)]
int n)
{
// Arrange
var shuffler = new LINQShuffler<int>();
var (correctArray, testArray) = RandomHelper.GetArrays(n);
// Act
shuffler.Shuffle(testArray);
// Assert
testArray.Length.Should().Be(correctArray.Length);
}
[Test]
public static void ArrayShuffled_NewArraySameValues(
[Random(10, 1000, 100, Distinct = true)]
int n)
{
// Arrange
var shuffler = new LINQShuffler<int>();
var (correctArray, testArray) = RandomHelper.GetArrays(n);
// Act
shuffler.Shuffle(testArray);
// Assert
testArray.Should().BeEquivalentTo(correctArray);
}
[Test]
public static void ArrayShuffled_NewArraySameShuffle(
[Random(0, 1000, 2, Distinct = true)] int n,
[Random(1000, 10000, 5, Distinct = true)] int seed)
{
// Arrange
var shuffle = new LINQShuffler<int>();
var (correctArray, testArray) = RandomHelper.GetArrays(n);
// Act
shuffle.Shuffle(testArray, seed);
shuffle.Shuffle(correctArray, seed);
// Assert
correctArray.Should().BeEquivalentTo(testArray, options => options.WithStrictOrdering());
}
}
}