예제 #1
0
        public void resolve_a_document_mapping_for_an_event_type()
        {
            var schema = new DocumentSchema(new StoreOptions(), null, null);

            schema.MappingFor(typeof(RaceStarted)).ShouldBeOfType <EventMapping>()
            .DocumentType.ShouldBe(typeof(RaceStarted));
        }
예제 #2
0
 public void cannot_use_a_doc_type_with_no_id()
 {
     Exception <InvalidDocumentException> .ShouldBeThrownBy(() =>
     {
         var schema = new DocumentSchema(new StoreOptions(), null, null);
         schema.MappingFor(typeof(BadDoc)).ShouldBeNull();
     });
 }
        public void should_get_foreign_key_from_attribute()
        {
            var schema = new DocumentSchema(new StoreOptions(), null, null);

            schema.MappingFor(typeof(Issue))
            .As <DocumentMapping>()
            .ForeignKeys
            .ShouldContain(x => x.ColumnName == "user_id");
        }
예제 #4
0
        public void can_override_with_MartenRegistry()
        {
            var storeOptions = new StoreOptions();

            storeOptions.Schema.For <Organization>().Searchable(x => x.Time2, pgType: "timestamp");

            var schema = new DocumentSchema(storeOptions, null, new NulloMartenLogger());

            schema.MappingFor(typeof(Organization)).As <DocumentMapping>().DuplicatedFields.Single(x => x.MemberName == "Time2")
            .PgType.ShouldBe("timestamp");
        }
        public void should_get_foreign_key_from_registry()
        {
            var storeOptions = new StoreOptions();

            storeOptions.Schema.For <Issue>().ForeignKey <User>(i => i.OtherUserId);

            var schema = new DocumentSchema(storeOptions, null, null);

            schema.MappingFor(typeof(Issue))
            .As <DocumentMapping>()
            .ForeignKeys
            .ShouldContain(x => x.ColumnName == "other_user_id");
        }
예제 #6
0
        public void can_resolve_mapping_for_subclass_type()
        {
            _schema.Alter(r =>
            {
                r.For <Squad>().AddSubclass <FootballTeam>().AddSubclass <BaseballTeam>();
            });

            var mapping = _schema.MappingFor(typeof(BaseballTeam)).ShouldBeOfType <SubClassMapping>();

            mapping.DocumentType.ShouldBe(typeof(BaseballTeam));

            mapping.Parent.DocumentType.ShouldBe(typeof(Squad));
        }
예제 #7
0
        public void can_override_with_MartenRegistry()
        {
            var registry = new MartenRegistry();

            registry.For <Organization>().Searchable(x => x.Time2, pgType: "timestamp");

            var schema = new DocumentSchema(new StoreOptions(), null, null);

            schema.Alter(registry);

            schema.MappingFor(typeof(Organization)).DuplicatedFields.Single(x => x.MemberName == "Time2")
            .PgType.ShouldBe("timestamp");
        }
        public when_deriving_the_table_definition_from_the_database_schema_Tests()
        {
            ConnectionSource.CleanBasicDocuments();
            _schema = _container.GetInstance <DocumentSchema>();

            theMapping = _schema.MappingFor(typeof(User)).As <DocumentMapping>();
            theMapping.DuplicateField("UserName");


            _storage = _schema.StorageFor(typeof(User));

            theDerivedTable = _schema.TableSchema(theMapping.TableName);
        }
예제 #9
0
        public void resolve_mapping_for_event_stream()
        {
            var schema = new DocumentSchema(new StoreOptions(), null, null);

            schema.MappingFor(typeof(EventStream)).ShouldBeOfType <EventGraph>();
        }