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

28 lines
725 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 EnumerableShuffledShouldBeDifferentOrder()
{
var list = new List<int>(Enumerable.Range(1, 52)); // 52! chance of being shuffled to the same order
2022-04-21 21:35:06 +00:00
var shuffled = new List<int>(list);
CollectionAssert.AreEqual(list, shuffled);
shuffled = new List<int>(list.Shuffled());
CollectionAssert.AreNotEqual(list, shuffled);
}
[TestMethod]
public void NullShuffledShouldThrow()
{
Assert.ThrowsException<ArgumentNullException>(() => ((List<int>?)null)!.Shuffled());
}
}