Esempio n. 1
0
    public async Task StoreAndCleanup()
    {
        using (var connection = await dbConnection.OpenConnection().ConfigureAwait(false))
        {
            for (var i = 0; i < 13; i++)
            {
                await Store(i, connection).ConfigureAwait(false);
            }
        }

        await Task.Delay(1000).ConfigureAwait(false);

        var dateTime = DateTime.UtcNow;
        await Task.Delay(1000).ConfigureAwait(false);

        using (var connection = await dbConnection.OpenConnection().ConfigureAwait(false))
        {
            await Store(13, connection).ConfigureAwait(false);
        }

        await persister.RemoveEntriesOlderThan(dateTime, CancellationToken.None).ConfigureAwait(false);

        Assert.IsNull(await persister.Get("MessageId1", null).ConfigureAwait(false));
        Assert.IsNull(await persister.Get("MessageId12", null).ConfigureAwait(false));
        Assert.IsNotNull(await persister.Get("MessageId13", null).ConfigureAwait(false));
    }