Ejemplo n.º 1
0
		public void WhenDocumentAlreadyExists_Can_Still_Generate_Values()
		{
			using (var store = NewDocumentStore())
			{
				var mk = new MultiTypeHiLoKeyGenerator(store, 5);
				store.Conventions.DocumentKeyGenerator = o => mk.GenerateDocumentKey(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(store, 5);
				store.Conventions.DocumentKeyGenerator = o => mk.GenerateDocumentKey(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);
				}
			}
		}
Ejemplo n.º 2
0
        public void DifferentTypesWillHaveDifferentIdGenerators()
        {
            using (var store = NewDocumentStore())
            {
                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);
                }
            }
        }