Пример #1
0
        public void can_create_patch_for_a_single_document_type()
        {
            StoreOptions(_ =>
            {
                // This is enough to tell Marten that the User
                // document is persisted and needs schema objects
                _.Schema.For <User>();
            });

            var patch = theStore.Schema.ToPatch(typeof(User));

            SpecificationExtensions.ShouldContain(patch.UpdateDDL, "CREATE OR REPLACE FUNCTION public.mt_upsert_user");
            SpecificationExtensions.ShouldContain(patch.UpdateDDL, "CREATE TABLE public.mt_doc_user");
            SpecificationExtensions.ShouldContain(patch.RollbackDDL, "drop table if exists public.mt_doc_user cascade;");

            var file = AppContext.BaseDirectory.AppendPath("bin", "update_users.sql");

            patch.WriteUpdateFile(file);

            var text = new FileSystem().ReadStringFromFile(file);

            SpecificationExtensions.ShouldContain(text, "DO LANGUAGE plpgsql $tran$");
            SpecificationExtensions.ShouldContain(text, "$tran$;");
        }
Пример #2
0
 public void then_the_user_table_should_be_generated_in_the_default_schema()
 {
     SpecificationExtensions.ShouldContain(_sql, "CREATE TABLE yet_another.mt_doc_user");
 }
Пример #3
0
 public void do_write_the_event_sql_if_the_event_graph_is_active()
 {
     theStore.Events.IsActive(null).ShouldBeTrue();
     SpecificationExtensions.ShouldContain(_schema.ToDDL(), "other.mt_streams");
 }
Пример #4
0
 public void then_company_table_should_be_generated_in_the_default()
 {
     SpecificationExtensions.ShouldContain(_sql, "CREATE TABLE public.mt_doc_company");
 }
Пример #5
0
 public void then_the_issue_table_should_be_generated_in_the_overriden_schema()
 {
     SpecificationExtensions.ShouldContain(_sql, "CREATE TABLE overriden.mt_doc_issue");
 }
Пример #6
0
 public void then_the_company_function_should_be_generated_in_the_default_schema()
 {
     SpecificationExtensions.ShouldContain(_sql, "CREATE OR REPLACE FUNCTION public.mt_upsert_company");
 }
Пример #7
0
 public void then_the_issue_function_should_be_generated_in_the_overriden_schema()
 {
     SpecificationExtensions.ShouldContain(_sql, "CREATE OR REPLACE FUNCTION overriden.mt_upsert_issue");
 }
Пример #8
0
 public void then_the_hilo_function_should_be_generated_in_the_default_schema()
 {
     SpecificationExtensions.ShouldContain(_sql, "CREATE OR REPLACE FUNCTION public.mt_get_next_hi");
 }
Пример #9
0
 public void do_not_write_event_sql_if_the_event_graph_is_not_active()
 {
     theStore.Events.IsActive(null).ShouldBeFalse();
     SpecificationExtensions.ShouldNotContain(_sql, "public.mt_streams");
 }
Пример #10
0
 public void include_the_hilo_table_by_default()
 {
     SpecificationExtensions.ShouldContain(_sql, "public.mt_hilo");
 }
Пример #11
0
        public void can_create_a_new_storage_for_a_document_type_without_subclasses()
        {
            var storage = theStore.Tenancy.Default.StorageFor(typeof(User));

            SpecificationExtensions.ShouldNotBeNull(storage);
        }
Пример #12
0
 public void default_modifier_is_null()
 {
     SpecificationExtensions.ShouldBeNull(new IndexDefinition(mapping, "foo").Modifier);
 }