public void ShouldBeAbleToPluralizeTableNames()
		{
			var fluentMappings = new FluentMappings();
			fluentMappings
				.ForEachEntity<IEntityBase>(entity => entity
					.Table.MapTable(t => t.Name + "s")
				);

			var repos = Marr.Data.MapRepository.Instance;
			var buildingTable = repos.GetTableName(typeof(Building));
			var roomTable = repos.GetTableName(typeof(Room));

			// Check tables
			Assert.AreEqual("Buildings", buildingTable);
			Assert.AreEqual("Rooms", roomTable);
		}
示例#2
0
        public void ShouldBeAbleToPluralizeTableNames()
        {
            var fluentMappings = new FluentMappings();

            fluentMappings
            .ForEachEntity <IEntityBase>(entity => entity
                                         .Table.MapTable(t => t.Name + "s")
                                         );

            var repos         = Marr.Data.MapRepository.Instance;
            var buildingTable = repos.GetTableName(typeof(Building));
            var roomTable     = repos.GetTableName(typeof(Room));

            // Check tables
            Assert.AreEqual("Buildings", buildingTable);
            Assert.AreEqual("Rooms", roomTable);
        }
示例#3
0
        public void ForEachEntity_ShouldApplyMappingsToAllSubclassesInAssembly()
        {
            var fluentMappings = new FluentMappings();

            fluentMappings
            .ForEachEntity <IEntityBase>(entity => entity
                                         .Columns.AutoMapSimpleTypeProperties()
                                         .For(e => e.ID)
                                         .SetPrimaryKey()
                                         .SetAutoIncrement()
                                         .SetReturnValue()
                                         .Relationships.AutoMapICollectionOrComplexProperties()
                                         .Tables.AutoMapTable()
                                         );

            var repos                 = Marr.Data.MapRepository.Instance;
            var buildingColumns       = repos.GetColumns(typeof(Building));
            var buildingRelationships = repos.GetRelationships(typeof(Building));
            var buildingTable         = repos.GetTableName(typeof(Building));
            var roomColumns           = repos.GetColumns(typeof(Room));
            var roomRelationships     = repos.GetRelationships(typeof(Room));
            var roomTable             = repos.GetTableName(typeof(Room));

            // Check columns
            Assert.IsNotNull(buildingColumns);
            Assert.IsNotNull(roomColumns);

            Assert.AreEqual(2, buildingColumns.Count);
            Assert.AreEqual(3, roomColumns.Count);

            // Check PKs
            Assert.IsTrue(buildingColumns.GetByColumnName("ID").ColumnInfo.IsPrimaryKey);
            Assert.IsTrue(roomColumns.GetByColumnName("ID").ColumnInfo.IsPrimaryKey);

            // Check relationships
            Assert.AreEqual(1, buildingRelationships.Count);
            Assert.IsTrue(buildingRelationships.First().RelationshipInfo.RelationType == RelationshipTypes.Many);
            Assert.AreEqual(1, roomRelationships.Count);
            Assert.IsTrue(roomRelationships.First().RelationshipInfo.RelationType == RelationshipTypes.One);

            // Check tables
            Assert.AreEqual("Building", buildingTable);
            Assert.AreEqual("Room", roomTable);
        }
		public void ForEachEntity_ShouldApplyMappingsToAllSubclassesInAssembly()
		{
			var fluentMappings = new FluentMappings();
			fluentMappings
				.ForEachEntity<IEntityBase>(entity => entity
					.Columns.AutoMapSimpleTypeProperties()
						.For(e => e.ID)
							.SetPrimaryKey()
							.SetAutoIncrement()
							.SetReturnValue()
					.Relationships.AutoMapICollectionOrComplexProperties()
					.Tables.AutoMapTable()
				);

			var repos = Marr.Data.MapRepository.Instance;
			var buildingColumns = repos.GetColumns(typeof(Building));
			var buildingRelationships = repos.GetRelationships(typeof(Building));
			var buildingTable = repos.GetTableName(typeof(Building));
			var roomColumns = repos.GetColumns(typeof(Room));
			var roomRelationships = repos.GetRelationships(typeof(Room));
			var roomTable = repos.GetTableName(typeof(Room));

			// Check columns
			Assert.IsNotNull(buildingColumns);
			Assert.IsNotNull(roomColumns);

			Assert.AreEqual(2, buildingColumns.Count);
			Assert.AreEqual(3, roomColumns.Count);

			// Check PKs
			Assert.IsTrue(buildingColumns.GetByColumnName("ID").ColumnInfo.IsPrimaryKey);
			Assert.IsTrue(roomColumns.GetByColumnName("ID").ColumnInfo.IsPrimaryKey);

			// Check relationships
			Assert.AreEqual(1, buildingRelationships.Count);
			Assert.IsTrue(buildingRelationships.First().RelationshipInfo.RelationType == RelationshipTypes.Many);
			Assert.AreEqual(1, roomRelationships.Count);
			Assert.IsTrue(roomRelationships.First().RelationshipInfo.RelationType == RelationshipTypes.One);

			// Check tables
			Assert.AreEqual("Building", buildingTable);
			Assert.AreEqual("Room", roomTable);
		}