public void RegisterExtensionNoExecutedTest() { var ext = new TestExtension(); ext.BeforeCompileMappingsDelegate = (types) => { Assert.Fail(); }; ext.AfterCompileMappingsDelegate = (types, mapping) => { Assert.Fail(); }; ext.BeforeBuildMappingsDelegate = (mapping) => { Assert.Fail(); }; ext.AfterBuildMappingsDelegate = (mapping) => { Assert.Fail(); }; var entities = new List<Type>() { typeof(City), typeof(State), typeof(ZipCode) }; Firehawk.Init() .Configure() .RegisterExtension(ext) .ConfigureEntities() .AddBaseEntity<Entity>() .AddEntities(entities) .EndConfig() .ConfigureMappings() .SearchForMappingsOnThisAssembly(Assembly.GetExecutingAssembly()) .EndConfig() .EndConfiguration(); }
public void RegisterExtensionCompileConfigTest() { var ext = new TestExtension(); ext.BeforeCompileMappingsDelegate = (types) => { Assert.IsNotNull(types); Assert.AreEqual(3, types.Count); Assert.IsTrue(types.Contains(typeof(City))); Assert.IsTrue(types.Contains(typeof(State))); Assert.IsTrue(types.Contains(typeof(ZipCode))); }; ext.AfterCompileMappingsDelegate = (types, mapping) => { Assert.IsNotNull(types); Assert.AreEqual(3, types.Count); Assert.IsTrue(types.Contains(typeof(City))); Assert.IsTrue(types.Contains(typeof(State))); Assert.IsTrue(types.Contains(typeof(ZipCode))); Assert.IsNotNull(mapping); Assert.AreEqual(3, mapping.Items.Count()); Assert.IsTrue(mapping.Items.OfType<HbmClass>().Any(c => c.name == typeof(City).Name)); Assert.IsTrue(mapping.Items.OfType<HbmClass>().Any(c => c.name == typeof(State).Name)); Assert.IsTrue(mapping.Items.OfType<HbmClass>().Any(c => c.name == typeof(ZipCode).Name)); }; ext.BeforeBuildMappingsDelegate = (mapping) => { Assert.Fail(); }; ext.AfterBuildMappingsDelegate = (mapping) => { Assert.Fail(); }; var entities = new List<Type>() { typeof(City), typeof(State), typeof(ZipCode) }; Firehawk.Init() .Configure() .RegisterExtension(ext) .ConfigureEntities() .AddBaseEntity<Entity>() .AddEntities(entities) .EndConfig() .ConfigureMappings() .SearchForMappingsOnThisAssembly(Assembly.GetExecutingAssembly()) .EndConfig() .EndConfiguration() .CompileMappings(NHConfig); }