public void WriteFluentNHibernateMappingForeignKeyTest()
        {
            //arrange
            var schema = ArrangeSchema();
            var table = schema.FindTableByName("Address");

            var cw = new FluentMappingWriter(table, new CodeWriterSettings(), new MappingNamer());

            //act
            var txt = cw.Write();

            //assert
            var hasBillingAddress = txt.Contains("HasMany(x => x.BillingAddressCollection).KeyColumn(\"BillingAddress\").Inverse()");
            var hasDeliveryAddress = txt.Contains("HasMany(x => x.DeliveryAddressCollection).KeyColumn(\"DeliveryAddress\").Inverse()");

            Assert.IsTrue(hasBillingAddress);
            Assert.IsTrue(hasDeliveryAddress);
        }
Example #2
0
 private string WriteFluentMapping(DatabaseTable table)
 {
     var fluentMapping = new FluentMappingWriter(table, _codeWriterSettings, _mappingNamer);
     var txt = fluentMapping.Write();
     var fileName = fluentMapping.MappingClassName + ".cs";
     var path = Path.Combine(_mappingPath, fileName);
     File.WriteAllText(path, txt);
     return fileName;
 }