public async Task doc_metadata_is_mapped_for_conjoined_tenant() { StoreOptions(c => { c.Schema.For <DocWithMeta>() .MultiTenanted() .Metadata(m => { m.TenantId.MapTo(x => x.TenantId); m.LastModified.MapTo(x => x.LastModified); }); }); var doc = new DocWithMeta(); var tenant = "TENANT_A"; using (var session = theStore.OpenSession(tenant)) { doc.LastModified = DateTime.UtcNow.AddYears(-1); session.Store(doc); (await session.MetadataForAsync(doc)).ShouldBeNull(); await session.SaveChangesAsync(); } using (var session = theStore.OpenSession(tenant)) { session.Query <DocWithMeta>().Count(d => d.TenantId == tenant).ShouldBe(1); var loaded = await session.Query <DocWithMeta>().Where(d => d.Id == doc.Id).FirstOrDefaultAsync(); ShouldBeStringTestExtensions.ShouldBe(loaded.TenantId, tenant); ShouldBeTestExtensions.ShouldNotBe(loaded.LastModified, DateTimeOffset.MinValue); // it's pretty well impossible to compare timestamps } }
public void generate_drop_part_of_patch_different_schema() { StoreOptions(_ => _.DatabaseSchemaName = "other"); var patch = theStore.Schema.ToPatch(); ShouldBeStringTestExtensions.ShouldContain(patch.RollbackDDL, "drop table if exists other.mt_hilo cascade;"); }
public void doc_metadata_is_mapped_for_doc_hierarchies() { StoreOptions(c => { c.Schema.For <DocWithMeta>() .AddSubClassHierarchy(typeof(RedDocWithMeta), typeof(BlueDocWithMeta), typeof(GreenDocWithMeta), typeof(EmeraldGreenDocWithMeta)) .SoftDeleted() .Metadata(m => { m.IsSoftDeleted.MapTo(x => x.Deleted); m.SoftDeletedAt.MapTo(x => x.DeletedAt); m.DocumentType.MapTo(x => x.DocType); }); }); using (var session = theStore.OpenSession()) { var doc = new DocWithMeta { Description = "transparent" }; var red = new RedDocWithMeta { Description = "red doc" }; var green = new GreenDocWithMeta { Description = "green doc" }; var blue = new BlueDocWithMeta { Description = "blue doc" }; var emerald = new EmeraldGreenDocWithMeta { Description = "emerald doc" }; session.Store(doc, red, green, blue, emerald); session.SaveChanges(); } using (var session = theStore.OpenSession()) { session.Query <DocWithMeta>().Count(d => d.DocType == "BASE").ShouldBe(1); session.Query <DocWithMeta>().Count(d => d.DocType == "blue_doc_with_meta").ShouldBe(1); session.Query <DocWithMeta>().Count(d => d.DocType == "red_doc_with_meta").ShouldBe(1); session.Query <DocWithMeta>().Count(d => d.DocType == "green_doc_with_meta").ShouldBe(1); session.Query <DocWithMeta>().Count(d => d.DocType == "emerald_green_doc_with_meta").ShouldBe(1); var redDocs = session.Query <RedDocWithMeta>().ToList(); redDocs.Count.ShouldBe(1); ShouldBeStringTestExtensions.ShouldBe(redDocs.First().DocType, "red_doc_with_meta"); session.Delete(redDocs.First()); session.SaveChanges(); } }
public void Can_parse_address(string text, string street1, string street2, string city, string state, string country, string zip) { var sut = Address.Parse(text); ShouldBeStringTestExtensions.ShouldBe(sut.Line1, street1); ShouldBeStringTestExtensions.ShouldBe(sut.Line2, street2); ShouldBeStringTestExtensions.ShouldBe(sut.City, city); ShouldBeStringTestExtensions.ShouldBe(sut.State, state); ShouldBeStringTestExtensions.ShouldBe(sut.Country, country); ShouldBeStringTestExtensions.ShouldBe(sut.PostalCode, zip); }
public void should_have_code_on_each_chain() { withAllDefaults(); ShouldBeBooleanExtensions.ShouldBeTrue(Handlers.Chains.Any()); foreach (var chain in Handlers.Chains) { ShouldBeStringTestExtensions.ShouldContain(chain.SourceCode, chain.TypeName); // Console.WriteLine("Should be " + chain.TypeName); // Console.WriteLine("--------------------------------------"); // Console.WriteLine(chain.SourceCode); // Console.WriteLine("--------------------------------------"); } }
public async Task add_read_delete_persisted_grants_by_subjectid_and_type() { var theStore = AutofacStoreFactory.Resolve <IPersistedGrantStore>(); var grants = ModelTests.MakeNewPersistedGrantModels(10).ToPersistedGrants(); var clientId = Guid.NewGuid().ToString(); var subjectId = Guid.NewGuid().ToString(); var type = Guid.NewGuid().ToString(); int i = 0; foreach (var grant in grants) { grant.SubjectId = subjectId; grant.ClientId = clientId; if (i % 2 == 0) { grant.Type = type; } await theStore.StoreAsync(grant); ++i; } var results = await theStore.GetAllAsync(subjectId); Assert.IsNotNull(results); Assert.AreEqual(grants.Count, Enumerable.Count <PersistedGrant>(results)); foreach (var result in results) { ShouldBeStringTestExtensions.ShouldBe(result.SubjectId, subjectId); } await theStore.RemoveAllAsync(subjectId, clientId, type); results = await theStore.GetAllAsync(subjectId); foreach (var result in results) { ShouldBeStringTestExtensions.ShouldBe(result.SubjectId, subjectId); } Assert.IsTrue(Enumerable.Any <PersistedGrant>(results)); Assert.AreEqual(Enumerable.Count <PersistedGrant>(results), grants.Count / 2); }
public void generate_drop_part_of_patch() { var patch = theStore.Schema.ToPatch(); ShouldBeStringTestExtensions.ShouldContain(patch.RollbackDDL, "drop table if exists public.mt_hilo cascade;"); }
public void Can_convert_text_to_pascal_case(string text, string expected) { var result = CodeGeneration.Generators.FormatExtensions.ToPascal(text); ShouldBeStringTestExtensions.ShouldBe(result, expected); }