public void Should_hide_document_without_status_field_from_indexing()
        {
            var offer = new Offer { Name = "Offer 1", Status = DocumentStatus.Published };
              using (var session = store.OpenSession())
              {
            session.Store(offer);
            session.SaveChanges();
              }

              using (var session = store.OpenSession())
              {
            var count = session.Query<Offer>().Customize(x => x.WaitForNonStaleResults()).Count();
            Assert.Equal(1, count);
            var revisions = session.Advanced.LoadStartingWith<Offer>(offer.Id + "/PublishedRevisions/");
            Assert.Equal(revisions.Length, 1);
              }
        }
        public void Should_create_revision_for_a_document_with_status_property()
        {
            var offer = new Offer { Name = "Offer 1", Status = DocumentStatus.Published };
              using (var session = store.OpenSession())
              {
            session.Store(offer);
            session.SaveChanges();
              }

              using (var session = store.OpenSession())
              {
            var loaded = session.Load<Offer>(offer.Id);
            var metadata = session.Advanced.GetMetadataFor(loaded);

            Assert.Equal(metadata.Value<string>(PublishedVersioningConstants.AtisDocumentRevision), metadata.Value<string>(PublishedVersioningConstants.AtisDocumentRevision));

            var revisions = session.Advanced.LoadStartingWith<Offer>(offer.Id + "/PublishedRevisions/");
            Assert.Equal(1, revisions.Length);
            Assert.Equal(loaded.Name, revisions[0].Name);
              }
        }
        public void Should_remove_revision_when_document_is_deleted()
        {
            var offer = new Offer { Name = "Offer 1", Status = DocumentStatus.Published };
              using (var session = store.OpenSession())
              {
            session.Store(offer);
            session.SaveChanges();
              }

              var key = offer.Id;
              using (var session = store.OpenSession())
              {
            offer = session.Load<Offer>(key);
            Assert.NotNull(offer);
            session.Delete(offer);
            session.SaveChanges();
              }

              using (var session = store.OpenSession())
              {
            var revision = session.Load<Offer>(key + "/PublishedRevisions/1");
            Assert.Null(revision);
              }
        }
        public void Should_not_remove_revision_when_document_is_not_deleted()
        {
            var offer = new Offer { Name = "Offer 1", Status = DocumentStatus.Published };
              using (var session = store.OpenSession())
              {
            session.Store(offer);
            session.SaveChanges();
              }

              Assert.Throws<InvalidOperationException>(() =>
              {
            var key = offer.Id;
            using (var session = store.OpenSession())
            {
              var revision = session.Load<Offer>(key + "/PublishedRevisions/1");
              Assert.NotNull(revision);
              session.Delete(revision);
              session.SaveChanges();
            }
              });
        }