public async Task last_modified_is_updated_on_the_document_when_it_is_saved()
        {
            var original = Guid.NewGuid();
            var doc      = new MetadataTarget {
                Version = original
            };

            theSession.Store(doc);
            await theSession.SaveChangesAsync();
        }
        public async Task can_insert_and_load()
        {
            var doc = new MetadataTarget();

            theSession.Insert(doc);
            await theSession.SaveChangesAsync();

            using var session = theStore.LightweightSession();
            var doc2 = session.LoadAsync <MetadataTarget>(doc.Id);

            doc2.ShouldNotBeNull();
        }
        public async Task can_save_and_load()
        {
            var doc = new MetadataTarget();

            theSession.Store(doc);
            await theSession.SaveChangesAsync();

            using var session = theStore.LightweightSession();
            var doc2 = session.LoadAsync <MetadataTarget>(doc.Id);

            SpecificationExtensions.ShouldNotBeNull(doc2);
        }
        public async Task version_is_available_on_query_only()
        {
            var doc = new MetadataTarget();

            theSession.Store(doc);
            await theSession.SaveChangesAsync();

            using var query = theStore.QuerySession();

            var doc2 = await query.LoadAsync <MetadataTarget>(doc.Id);

            doc2.Version.ShouldNotBe(Guid.Empty);
        }
        public void can_bulk_insert()
        {
            var docs = new MetadataTarget[]
            {
                new MetadataTarget(),
                new MetadataTarget(),
                new MetadataTarget(),
                new MetadataTarget(),
                new MetadataTarget(),
                new MetadataTarget()
            };

            theStore.BulkInsert(docs);
        }
        public async Task can_bulk_insert_async()
        {
            var docs = new MetadataTarget[]
            {
                new MetadataTarget(),
                new MetadataTarget(),
                new MetadataTarget(),
                new MetadataTarget(),
                new MetadataTarget(),
                new MetadataTarget()
            };

            await theStore.BulkInsertAsync(docs);
        }
        public async Task can_save_update_and_load_queryonly()
        {
            var doc = new MetadataTarget();

            theSession.Store(doc);
            await theSession.SaveChangesAsync();

            doc.Name = "different";
            theSession.Update(doc);
            await theSession.SaveChangesAsync();

            using var session = theStore.QuerySession();
            var doc2 = await session.LoadAsync <MetadataTarget>(doc.Id);

            doc2.Name.ShouldBe("different");
        }
        public async Task save_and_load_and_see_header_values()
        {
            theSession.SetHeader("name", "Jeremy");
            theSession.SetHeader("hour", 5);

            var doc = new MetadataTarget();

            theSession.Store(doc);
            await theSession.SaveChangesAsync();

            using var session = theStore.QuerySession();

            var doc2 = await session.LoadAsync <MetadataTarget>(doc.Id);

            doc2.Headers["name"].ShouldBe("Jeremy");
            doc2.Headers["hour"].ShouldBe(5);
        }
        public async Task can_save_update_and_load_with_dirty_session()
        {
            var doc = new MetadataTarget();

            using var session = theStore.DirtyTrackedSession();
            session.Store(doc);
            await session.SaveChangesAsync();

            doc.Name = "different";
            theSession.Update(doc);
            await theSession.SaveChangesAsync();

            using var session2 = theStore.DirtyTrackedSession();
            var doc2 = await session2.LoadAsync <MetadataTarget>(doc.Id);

            doc2.Name.ShouldBe("different");
        }
        public async Task save_and_load_metadata_last_modified_by()
        {
            var doc = new MetadataTarget();

            theSession.Store(doc);
            await theSession.SaveChangesAsync();

            var metadata = await theSession.MetadataForAsync(doc);

            metadata.LastModifiedBy.ShouldBe(theSession.LastModifiedBy);

            using (var session2 = theStore.QuerySession())
            {
                var doc2 = await session2.LoadAsync <MetadataTarget>(doc.Id);

                doc2.LastModifiedBy.ShouldBe(theSession.LastModifiedBy);
            }
        }
        public async Task save_and_load_metadata_correlation()
        {
            var doc = new MetadataTarget();

            theSession.Store(doc);
            await theSession.SaveChangesAsync();

            var metadata = await theSession.MetadataForAsync(doc);

            metadata.CorrelationId.ShouldBe(theSession.CorrelationId);

            using (var session2 = theStore.QuerySession())
            {
                var doc2 = await session2.LoadAsync <MetadataTarget>(doc.Id);

                doc2.CorrelationId.ShouldBe(theSession.CorrelationId);
            }
        }