Exemplo n.º 1
0
        public async Task Should_not_if_disabled()
        {
            options.StoreEnabled = false;

            for (var i = 0; i < 2500; i++)
            {
                await sut.LogAsync(new Request { Key = i.ToString() });
            }

            sut.Next();
            sut.Dispose();

            A.CallTo(() => requestLogRepository.InsertManyAsync(A <IEnumerable <Request> > ._))
            .MustNotHaveHappened();
        }
        public async Task Should_not_log_if_disabled()
        {
            options.StoreEnabled = false;

            for (var i = 0; i < 2500; i++)
            {
                await sut.LogAsync(new Request { Key = i.ToString(CultureInfo.InvariantCulture) }, ct);
            }

            sut.Next();
            sut.Dispose();

            // Wait for the timer to not trigger.
            await Task.Delay(500, ct);

            A.CallTo(() => requestLogRepository.InsertManyAsync(A <IEnumerable <Request> > ._, A <CancellationToken> ._))
            .MustNotHaveHappened();
        }
        public async Task Should_log_in_batches()
        {
            for (var i = 0; i < 2500; i++)
            {
                await sut.LogAsync(new Request { Key = i.ToString() });
            }

            sut.Next();
            sut.Dispose();

            A.CallTo(() => requestLogRepository.InsertManyAsync(Batch("0", "999")))
            .MustHaveHappened();

            A.CallTo(() => requestLogRepository.InsertManyAsync(Batch("1000", "1999")))
            .MustHaveHappened();

            A.CallTo(() => requestLogRepository.InsertManyAsync(Batch("2000", "2499")))
            .MustHaveHappened();
        }