public void DocumentKeyGenerator() { var generator = new MultiTypeHiLoKeyGenerator(5); store.Conventions.DocumentKeyGenerator = (dbName, cmd, entity) => generator.GenerateDocumentKey(cmd, store.Conventions, entity); store.Initialize(); }
public void WhenDocumentAlreadyExists_Can_Still_Generate_Values() { using (var store = NewDocumentStore()) { var mk = new MultiTypeHiLoKeyGenerator(5); store.Conventions.DocumentKeyGenerator = (cmd, o) => mk.GenerateDocumentKey(cmd, store.Conventions, o); using (var session = store.OpenSession()) { var company = new Company(); session.Store(company); var contact = new Contact(); session.Store(contact); Assert.Equal("companies/1", company.Id); Assert.Equal("contacts/1", contact.Id); } mk = new MultiTypeHiLoKeyGenerator(5); store.Conventions.DocumentKeyGenerator = (cmd, o) => mk.GenerateDocumentKey(cmd, store.Conventions, o); using (var session = store.OpenSession()) { var company = new Company(); session.Store(company); var contact = new Contact(); session.Store(contact); Assert.Equal("companies/6", company.Id); Assert.Equal("contacts/6", contact.Id); } } }
public void DocumentKeyGenerator() { var generator = new MultiTypeHiLoKeyGenerator(store, 5); store.Conventions.DocumentKeyGenerator = entity => generator.GenerateDocumentKey(store.Conventions, entity); store.Initialize(); }
public void DoesNotLoseValuesWhenHighIsOver() { using (var store = NewDocumentStore()) { var mk = new MultiTypeHiLoKeyGenerator(5); for (int i = 0; i < 15; i++) { Assert.Equal("companies/" + (i + 1), mk.GenerateDocumentKey(store.DatabaseCommands, store.Conventions, new Company())); } } }