public void GetEnumerator_EnumerateFull_EnumeratesOnlyOnce() { // arrange var enumerable = new NonRepeatableEnumerable <int>(Enumerable.Range(1, 5)); // act var list = enumerable.ToList(); // assert list.Should().BeEquivalentTo(new[] { 1, 2, 3, 4, 5 }); enumerable.Should().BeEmpty(); }
public void GetEnumerator_EnumerateParital_EnumeratesInParts() { // arrange var enumerable = new NonRepeatableEnumerable <int>(Enumerable.Range(1, 5)); // act var list = enumerable.Take(3).ToList(); // assert list.Should().BeEquivalentTo(new[] { 1, 2, 3 }); enumerable.Should().BeEquivalentTo(new[] { 4, 5 }); }
public void Chunk_WithPartialConsuming_ShouldWork() { // arrange var values = new NonRepeatableEnumerable <int>(Enumerable.Range(1, 10)); // act var result = values.Chunk(4).Take(2).ToList(); // assert result.Should().HaveCount(2); result.First().Should().BeEquivalentTo(new[] { 1, 2, 3, 4 }); result.Second().Should().BeEquivalentTo(new[] { 5, 6, 7, 8 }); values.Should().BeEquivalentTo(new[] { 9, 10 }); }
public void IsNullOrEmpty_ConsumingEnumerableGiven_BehavesCorrectly() { // arrange var empty = new NonRepeatableEnumerable <string>(new List <string>()); var filled = new NonRepeatableEnumerable <string>(new List <string> { "abc", "def" }); // act var resultEmpty = empty.IsNullOrEmpty(); var resultFilled = filled.IsNullOrEmpty(); // assert resultEmpty.Should().BeTrue(); resultFilled.Should().BeFalse(); }
public void ContainAll_ConsumingEnumerableGiven_BehavesCorrectly() { // arrange var matching = new NonRepeatableEnumerable <string>(new List <string> { "abc", "dev", "ghi" }); var notMatching = new NonRepeatableEnumerable <string>(new List <string> { "abc", "ghi" }); // act var matchingResult = matching.ContainAll("ghi", "dev"); var notMatchingResult = notMatching.ContainAll("ghi", "dev"); // assert matchingResult.Should().BeTrue(); notMatchingResult.Should().BeFalse(); }