X10D/X10D.Tests/src/Collections/EnumerableTests.cs

27 lines
714 B
C#
Raw Normal View History

2022-04-21 21:35:06 +00:00
using Microsoft.VisualStudio.TestTools.UnitTesting;
using X10D.Collections;
namespace X10D.Tests.Collections;
[TestClass]
public class EnumerableTests
{
[TestMethod]
public void Shuffled_ShouldThrow_GivenNull()
2022-04-21 21:35:06 +00:00
{
Assert.ThrowsException<ArgumentNullException>(() => ((List<int>?)null)!.Shuffled());
2022-04-21 21:35:06 +00:00
}
[TestMethod]
public void Shuffled_ShouldReorder_GivenNotNull()
2022-04-21 21:35:06 +00:00
{
int[] array = Enumerable.Range(1, 52).ToArray(); // 52! chance of being shuffled to the same order
int[] shuffled = array[..];
CollectionAssert.AreEqual(array, shuffled);
shuffled = array.Shuffled().ToArray();
CollectionAssert.AreNotEqual(array, shuffled);
2022-04-21 21:35:06 +00:00
}
}