コード例 #1
0
        public void FisherYatesShuffleBag_TwoItems()
        {
            // Arrange
            var random = new Mock<Random>(MockBehavior.Strict);
            random.SetupSequence(x => x.Next(It.IsAny<int>()))
                  .Returns(0)
                  .Returns(0);

            var service = new FisherYatesShuffleBag<int>(
                new[] { 0, 1 },
                random.Object);

            // Act
            var firstResult = service.Next();
            var secondResult = service.Next();

            // Assert
            Assert.AreEqual(0, firstResult);
            Assert.AreEqual(1, secondResult);
        }
コード例 #2
0
        public void FisherYatesShuffleBag_SingleItem()
        {
            // Arrange
            var service = new FisherYatesShuffleBag<int>(new[] { 0 });

            // Act
            var result = service.Next();

            // Assert
            Assert.AreEqual(0, result);
        }