コード例 #1
0
        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());
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
            }
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 internal void Returns_true_for_some_source(
     [Frozen] InfiniteLoopingEnumerator <int> enumerator)
 {
     enumerator.MoveNext().Should().BeTrue();
 }