Example #1
0
        public void completely_remove_document_type()
        {
            using (var container = Container.For <DevelopmentModeRegistry>())
            {
                var session = container.GetInstance <IDocumentSession>();

                session.Store(new Target {
                    Number = 1
                });
                session.Store(new Target {
                    Number = 2
                });

                session.SaveChanges();

                var schema = container.GetInstance <Marten.Schema.DocumentSchema>();
                schema.DocumentTables().Contains(DocumentMapping.TableNameFor(typeof(Target)))
                .ShouldBeTrue();

                var cleaner = container.GetInstance <DocumentCleaner>();

                cleaner.CompletelyRemove(typeof(Target));

                schema.DocumentTables().Contains(DocumentMapping.TableNameFor(typeof(Target)))
                .ShouldBeFalse();
            }
        }
Example #2
0
        public void builds_schema_objects_on_the_fly_as_needed()
        {
            _schema.StorageFor(typeof(User)).ShouldNotBeNull();
            _schema.StorageFor(typeof(Issue)).ShouldNotBeNull();
            _schema.StorageFor(typeof(Company)).ShouldNotBeNull();

            var schema = new DocumentSchema(new ConnectionSource(), new DevelopmentSchemaCreation(new ConnectionSource()));
            var tables = schema.SchemaTableNames();

            tables.ShouldContain(DocumentMapping.TableNameFor(typeof(User)).ToLower());
            tables.ShouldContain(DocumentMapping.TableNameFor(typeof(Issue)).ToLower());
            tables.ShouldContain(DocumentMapping.TableNameFor(typeof(Company)).ToLower());

            var functions = schema.SchemaFunctionNames();

            functions.ShouldContain(DocumentMapping.UpsertNameFor(typeof(User)).ToLower());
            functions.ShouldContain(DocumentMapping.UpsertNameFor(typeof(Issue)).ToLower());
            functions.ShouldContain(DocumentMapping.UpsertNameFor(typeof(Company)).ToLower());
        }
Example #3
0
 public void table_name_for_document()
 {
     DocumentMapping.TableNameFor(typeof(MySpecialDocument))
     .ShouldBe("mt_doc_myspecialdocument");
 }