public async Task AddOrUpdate_callsFindAsyncAndReplaceOneAsync()
        {
            var record = new MongoRecord {
                Details = new Audit(TestCorrelationId, TestUser).Details
            };

            MongoCollectionMock.Setup(x => x.FindAsync(
                                          It.IsAny <FilterDefinition <MongoRecord> >(),
                                          It.IsAny <FindOptions <MongoRecord> >(),
                                          It.IsAny <CancellationToken>())).ReturnsAsync(new TestMongoCursor <MongoRecord>(record));
            MongoCollectionMock.Setup(x => x.ReplaceOneAsync(
                                          It.IsAny <FilterDefinition <MongoRecord> >(),
                                          It.IsAny <MongoRecord>(),
                                          It.IsAny <ReplaceOptions>(),
                                          It.IsAny <CancellationToken>())).ReturnsAsync(new ReplaceOneResult.Acknowledged(1, 0, new BsonString("")));

            await Storage.AddOrUpdate(TestKey, TestValue);

            MongoCollectionMock.Verify(x => x.FindAsync(
                                           It.IsAny <FilterDefinition <MongoRecord> >(),
                                           It.IsAny <FindOptions <MongoRecord> >(),
                                           It.IsAny <CancellationToken>()),
                                       Times.Once);
            MongoCollectionMock.Verify(x => x.InsertOneAsync(
                                           It.IsAny <MongoRecord>(),
                                           It.IsAny <InsertOneOptions>(),
                                           It.IsAny <CancellationToken>()),
                                       Times.Never);
            MongoCollectionMock.Verify(x => x.ReplaceOneAsync(
                                           It.IsAny <FilterDefinition <MongoRecord> >(),
                                           It.IsAny <MongoRecord>(),
                                           It.IsAny <ReplaceOptions>(),
                                           It.IsAny <CancellationToken>()),
                                       Times.Once);
        }
        public void GetKeys_callsAggregate()
        {
            var _ = Storage.GetKeys().ToArray();

            MongoCollectionMock.Verify(x => x.Aggregate(
                                           It.IsAny <PipelineDefinition <MongoRecord, KeyRecord> >(),
                                           It.IsAny <AggregateOptions>(),
                                           It.IsAny <CancellationToken>()),
                                       Times.Once);
        }
        public async Task TryRemove_callsFindOneAndDeleteAsync()
        {
            await Storage.TryRemove(TestKey);

            MongoCollectionMock.Verify(x => x.FindOneAndDeleteAsync(
                                           It.IsAny <FilterDefinition <MongoRecord> >(),
                                           It.IsAny <FindOneAndDeleteOptions <MongoRecord> >(),
                                           It.IsAny <CancellationToken>()),
                                       Times.Once);
        }
        public async Task AddOrGet_callsFindAsyncAndInsertOneAsync()
        {
            await Storage.AddOrGet(TestKey, TestValue);

            MongoCollectionMock.Verify(x => x.FindAsync(
                                           It.IsAny <FilterDefinition <MongoRecord> >(),
                                           It.IsAny <FindOptions <MongoRecord> >(),
                                           It.IsAny <CancellationToken>()),
                                       Times.Once);
            MongoCollectionMock.Verify(x => x.InsertOneAsync(
                                           It.IsAny <MongoRecord>(),
                                           It.IsAny <InsertOneOptions>(),
                                           It.IsAny <CancellationToken>()),
                                       Times.Once);
        }
        public async Task AddOrGet_callsFindAsync()
        {
            MongoCollectionMock.Setup(x => x.FindAsync(
                                          It.IsAny <FilterDefinition <MongoRecord> >(),
                                          It.IsAny <FindOptions <MongoRecord> >(),
                                          It.IsAny <CancellationToken>())).ReturnsAsync(new TestMongoCursor <MongoRecord>(new MongoRecord()));

            await Storage.AddOrGet(TestKey, TestValue);

            MongoCollectionMock.Verify(x => x.FindAsync(
                                           It.IsAny <FilterDefinition <MongoRecord> >(),
                                           It.IsAny <FindOptions <MongoRecord> >(),
                                           It.IsAny <CancellationToken>()),
                                       Times.Once);
            MongoCollectionMock.Verify(x => x.InsertOneAsync(
                                           It.IsAny <IClientSessionHandle>(),
                                           It.IsAny <MongoRecord>(),
                                           It.IsAny <InsertOneOptions>(),
                                           It.IsAny <CancellationToken>()),
                                       Times.Never);
        }