public void GetEnumerator_WithNonNullInstance_ShouldReturnEnumeratorWithCorrectOrder(int length) { // Arrange. var data = new byte[length]; using (var random = RandomNumberGenerator.Create()) { random.GetBytes(data); } var subject = new BinaryString(data); // Assert. Assert(subject.GetEnumerator()); Assert(((IEnumerable)subject).GetEnumerator()); void Assert(IEnumerator enumerator) { foreach (var b in data) { enumerator.MoveNext().Should().BeTrue(); enumerator.Current.Should().Be(b); } enumerator.MoveNext().Should().BeFalse(); } }