internal void Sets_current_to_first_element_of_source( [Frozen] IEnumerable <int> source, [Frozen] InfiniteLoopingEnumerator <int> enumerator) { enumerator.MoveNext(); enumerator.Current.Should().Be(source.First()); }
internal void Enumerates_the_source_n_times( [Frozen] IEnumerable <int> source, [Frozen] InfiniteLoopingEnumerator <int> enumerator, int n) { var result = enumerator.AsEnumerable() .Take(source.Count() * n); result.Should().BeEquivalentTo( source.Multiply(times: n)); }
public int GetFirstFrequencyReachedTwice(string frequencyChangesAsString) { var frequencyChanges = Split(frequencyChangesAsString); var parsed = frequencyChanges.Select(ParseFrequencyChange); using (var infiniteLoopingEnumerator = new InfiniteLoopingEnumerator <int>(parsed)) { var looping = infiniteLoopingEnumerator.AsEnumerable(); var reached = GetReachedFrequencies(looping); return(GetFirstReachedTwice(reached)); } }
internal void Enumerates_the_source( [Frozen] IEnumerable <int> source, [Frozen] InfiniteLoopingEnumerator <int> enumerator) { var result = Enumerable .Range(0, source.Count()) .Select(_ => { enumerator.MoveNext(); return(enumerator.Current); }); result.Should().BeEquivalentTo(source); }
internal void Returns_true_for_some_source( [Frozen] InfiniteLoopingEnumerator <int> enumerator) { enumerator.MoveNext().Should().BeTrue(); }