public void ClearBatch_should_clear_batch() { var subject = new BatchableSource <int>(new[] { 1, 2 }); subject.Batch.Should().NotBeNull(); subject.ClearBatch(); subject.Batch.Should().BeNull(); }
public void StartBatch_should_return_and_clear_any_overflow() { var subject = new BatchableSource <int>(Enumerable.Empty <int>().GetEnumerator()); var batch = new int[0]; var overflow = new BatchableSource <int> .Overflow { Item = 1, State = null }; subject.EndBatch(batch, overflow); subject.ClearBatch(); subject.StartBatch().Should().BeSameAs(overflow); subject.StartBatch().Should().BeNull(); }
public void ClearBatch_should_clear_batch() { var items = new List <int> { 1, 2 }; var subject = new BatchableSource <int>(items.GetEnumerator()); subject.StartBatch(); subject.MoveNext(); var batch = new[] { subject.Current }; subject.EndBatch(batch); subject.Batch.Should().NotBeNull(); subject.ClearBatch(); subject.Batch.Should().BeNull(); }
public void EndBatch_with_overflow_should_set_batch_and_set_HashMore_to_true() { var subject = new BatchableSource <int>(Enumerable.Empty <int>().GetEnumerator()); subject.Batch.Should().BeNull(); subject.HasMore.Should().BeTrue(); var batch = new int[] { 1, 2 }; var overflow = new BatchableSource <int> .Overflow { Item = 3, State = 4 }; subject.EndBatch(batch, overflow); subject.Batch.Should().BeSameAs(batch); subject.HasMore.Should().BeTrue(); subject.ClearBatch(); subject.StartBatch().Should().BeSameAs(overflow); }