コード例 #1
0
        public void QueueExtensions_DequeuePattern_ShouldDequeueTwoElementPatternWithCounts()
        {
            // Arrange
            var input = new Queue<string>(new[]
            {
                "a",
                "a",
                "a",
                "b",
                "b",
                "c"
            });

            // Act
            var result = input.DequeuePattern(new[]
            {
                new PatternSegment<string>(s => s == "a", 3),
                new PatternSegment<string>(s => s == "b", 2)
            });

            // Assert
            CollectionAssert.AreEqual(
                new[] { "a", "a", "a", "b", "b" },
                result.ToArray());
            Assert.AreEqual(1, input.Count());
        }
コード例 #2
0
        public void QueueExtensions_DequeuePattern_ShouldReturnEmptyEnumerableWhenPatternFails()
        {
            // Arrange
            var input = new Queue<string>(new[]
            {
                "a",
                "a",
                "b",
                "b",
                "c"
            });

            // Act
            var result = input.DequeuePattern(new[]
            {
                new PatternSegment<string>(s => s == "a", 2),
                new PatternSegment<string>(s => s == "c")
            });

            // Assert
            Assert.AreEqual(0, result.Count());
            Assert.AreEqual(5, input.Count());
        }