public async Task GetEnumerator_WhenIterate_ShouldFoundTheSameAddedItems(int items, bool generic)
        {
            // Arrange.
            var generated = new Collection <BackgroundServiceError>();

            for (int i = 0; i < items; i++)
            {
                var error = new BackgroundServiceError(typeof(FakeBackgroundService), new Exception());

                await RunAsync(typeof(FakeBackgroundService), new Exception(), CancellationToken.None);

                generated.Add(error);
            }

            // Act.
            var enumerator = generic ? this.subject.GetEnumerator() : ((IEnumerable)this.subject).GetEnumerator();
            var collected  = new Collection <BackgroundServiceError>();

            while (enumerator.MoveNext())
            {
                collected.Add((BackgroundServiceError)enumerator.Current);
            }

            // Assert.
            collected.Should().BeEquivalentTo(generated);
        }
 public BackgroundServiceErrorTests()
 {
     this.service   = typeof(FakeBackgroundService);
     this.exception = new Exception();
     this.subject   = new BackgroundServiceError(this.service, this.exception);
 }