public void multi_tenancy_test_to_excercise_the_service_arguments() { var tenantA = Guid.NewGuid(); var tenantB = Guid.NewGuid(); var trackedA1 = new TrackedEntity(); var trackedA2 = new TrackedEntity(); var trackedB1 = new TrackedEntity(); var trackedB2 = new TrackedEntity(); var trackedB3 = new TrackedEntity(); var repo = theUnitOfWork.Start(tenantA); repo.Update(trackedA1); repo.Update(trackedA2); theUnitOfWork.Commit(); repo = theUnitOfWork.Start(tenantB); repo.Update(trackedB1); repo.Update(trackedB2); repo.Update(trackedB3); theUnitOfWork.Commit(); theUnitOfWork.Start(tenantA) .All<TrackedEntity>().ShouldHaveTheSameElementsAs(trackedA1, trackedA2); theUnitOfWork.Reject(); theUnitOfWork.Start(tenantB) .All<TrackedEntity>().ShouldHaveTheSameElementsAs(trackedB1, trackedB2, trackedB3); theUnitOfWork.Reject(); }
public void all_only_returns_values_where_the_tenant_id_matches() { var e1 = new TrackedEntity { TenantId = theContext.CurrentTenant }; var e2 = new TrackedEntity { TenantId = theContext.CurrentTenant }; var e3 = new TrackedEntity { TenantId = Guid.NewGuid() }; var e4 = new TrackedEntity { TenantId = theContext.CurrentTenant }; var e5 = new TrackedEntity { TenantId = theContext.CurrentTenant }; var e6 = new TrackedEntity { TenantId = Guid.NewGuid() }; var e7 = new TrackedEntity { TenantId = theContext.CurrentTenant }; inner.Update(e1); inner.Update(e2); inner.Update(e3); inner.Update(e4); inner.Update(e5); inner.Update(e6); inner.Update(e7); theStorage.All().ShouldHaveTheSameElementsAs(e1, e2, e4, e5, e7); }
public void find_when_the_entity_does_not_match_the_tenant() { var entity = new TrackedEntity { TenantId = Guid.NewGuid(), Id = Guid.NewGuid() }; inner.Update(entity); theStorage.Find(entity.Id).ShouldBeNull(); }
public void find_when_the_tenant_id_matches() { var entity = new TrackedEntity { TenantId = theContext.CurrentTenant, Id = Guid.NewGuid() }; inner.Update(entity); theStorage.Find(entity.Id).ShouldBeTheSameAs(entity); }
public void update_should_set_the_tenant_id_before_updating_to_the_inner() { var entity = new TrackedEntity { Id = Guid.NewGuid() }; theStorage.Update(entity); entity.TenantId.ShouldEqual(theContext.CurrentTenant); inner.Find(entity.Id).ShouldBeTheSameAs(entity); }
public void find_single_does_not_find_anything_from_the_same_tenant() { var original = new TrackedEntity { Id = Guid.NewGuid(), TenantId = Guid.NewGuid(), Name = "Jeremy" }; inner.Update(original); theStorage.FindSingle(x => x.Name == "Jeremy") .ShouldBeNull(); }
public void find_single_does_not_find_anything_from_the_same_tenant() { var original = new TrackedEntity { Id = Guid.NewGuid(), TenantId = Guid.NewGuid(), Name = "Jeremy" }; inner.Update(original); theStorage.FindSingle(x => x.Name == "Jeremy") .ShouldBeNull(); }
public void remove_happy_path() { var original = new TrackedEntity { Id = Guid.NewGuid(), TenantId = theContext.CurrentTenant }; inner.Update(original); var newEntity = new TrackedEntity { Id = original.Id }; theStorage.Remove(newEntity); inner.All().Any().ShouldBeFalse(); }
public void update_will_throw_an_exception_if_you_try_to_update_an_entity_that_is_not_owned_by_the_current_tenant() { var original = new TrackedEntity { Id = Guid.NewGuid(), TenantId = Guid.NewGuid() }; inner.Update(original); var newEntity = new TrackedEntity { Id = original.Id }; Exception <ArgumentOutOfRangeException> .ShouldBeThrownBy(() => { theStorage.Update(newEntity); }); }
public void find_single_happy_path() { var original = new TrackedEntity { Id = Guid.NewGuid(), TenantId = theContext.CurrentTenant, Name = "Jeremy" }; inner.Update(original); inner.Update(new TrackedEntity { Name = original.Name, TenantId = Guid.NewGuid() }); theStorage.FindSingle(x => x.Name == "Jeremy").ShouldBeTheSameAs(original); }
public void find_single_happy_path() { var original = new TrackedEntity { Id = Guid.NewGuid(), TenantId = theContext.CurrentTenant, Name = "Jeremy" }; inner.Update(original); inner.Update(new TrackedEntity { Name = original.Name, TenantId = Guid.NewGuid() }); theStorage.FindSingle(x => x.Name == "Jeremy").ShouldBeTheSameAs(original); }
public void remove_throws_exception_if_the_entity_is_owned_by_a_different_tenant() { var original = new TrackedEntity { Id = Guid.NewGuid(), TenantId = Guid.NewGuid() }; inner.Update(original); var newEntity = new TrackedEntity { Id = original.Id }; Exception <ArgumentOutOfRangeException> .ShouldBeThrownBy(() => { theStorage.Remove(newEntity); }); }
public void all_only_returns_values_where_the_tenant_id_matches() { var e1 = new TrackedEntity {TenantId = theContext.CurrentTenant}; var e2 = new TrackedEntity {TenantId = theContext.CurrentTenant}; var e3 = new TrackedEntity {TenantId = Guid.NewGuid()}; var e4 = new TrackedEntity {TenantId = theContext.CurrentTenant}; var e5 = new TrackedEntity {TenantId = theContext.CurrentTenant}; var e6 = new TrackedEntity { TenantId = Guid.NewGuid() }; var e7 = new TrackedEntity {TenantId = theContext.CurrentTenant}; inner.Update(e1); inner.Update(e2); inner.Update(e3); inner.Update(e4); inner.Update(e5); inner.Update(e6); inner.Update(e7); theStorage.All().ShouldHaveTheSameElementsAs(e1, e2, e4, e5, e7); }
public void multi_tenancy_test_to_excercise_the_service_arguments() { var tenantA = Guid.NewGuid(); var tenantB = Guid.NewGuid(); var trackedA1 = new TrackedEntity(); var trackedA2 = new TrackedEntity(); var trackedB1 = new TrackedEntity(); var trackedB2 = new TrackedEntity(); var trackedB3 = new TrackedEntity(); transaction.WithRepository(tenantA, repo => { repo.Update(trackedA1); repo.Update(trackedA2); }); transaction.WithRepository(tenantB, repo => { repo.Update(trackedB1); repo.Update(trackedB2); repo.Update(trackedB3); }); transaction.Execute<IDocumentSession>(session => session.Query<TrackedEntity>().Customize(x => x.WaitForNonStaleResults()).Any().ShouldBeTrue()); transaction.WithRepository(tenantA, repo => { repo.All<TrackedEntity>().ShouldHaveTheSameElementsAs(trackedA1, trackedA2); }); bool wasCalled = false; transaction.WithRepository(tenantB, repo => { wasCalled = true; repo.All<TrackedEntity>().ShouldHaveTheSameElementsAs(trackedB1, trackedB2, trackedB3); }); wasCalled.ShouldBeTrue(); }
public void find_when_the_entity_does_not_match_the_tenant() { var entity = new TrackedEntity { TenantId = Guid.NewGuid(), Id = Guid.NewGuid() }; inner.Update(entity); theStorage.Find(entity.Id).ShouldBeNull(); }
public void update_will_throw_an_exception_if_you_try_to_update_an_entity_that_is_not_owned_by_the_current_tenant() { var original = new TrackedEntity { Id = Guid.NewGuid(), TenantId = Guid.NewGuid() }; inner.Update(original); var newEntity = new TrackedEntity { Id = original.Id }; Exception<ArgumentOutOfRangeException>.ShouldBeThrownBy(() => { theStorage.Update(newEntity); }); }
public void update_should_set_the_tenant_id_before_updating_to_the_inner() { var entity = new TrackedEntity { Id = Guid.NewGuid() }; theStorage.Update(entity); entity.TenantId.ShouldEqual(theContext.CurrentTenant); inner.Find(entity.Id).ShouldBeTheSameAs(entity); }
public void remove_throws_exception_if_the_entity_is_owned_by_a_different_tenant() { var original = new TrackedEntity { Id = Guid.NewGuid(), TenantId = Guid.NewGuid() }; inner.Update(original); var newEntity = new TrackedEntity { Id = original.Id }; Exception<ArgumentOutOfRangeException>.ShouldBeThrownBy(() => { theStorage.Remove(newEntity); }); }
public void remove_happy_path() { var original = new TrackedEntity { Id = Guid.NewGuid(), TenantId = theContext.CurrentTenant }; inner.Update(original); var newEntity = new TrackedEntity { Id = original.Id }; theStorage.Remove(newEntity); inner.All().Any().ShouldBeFalse(); }
public void find_when_the_tenant_id_matches() { var entity = new TrackedEntity { TenantId = theContext.CurrentTenant, Id = Guid.NewGuid() }; inner.Update(entity); theStorage.Find(entity.Id).ShouldBeTheSameAs(entity); }