public void Contributor_gets_called() { var contributor = new MockContributor(true); ActiveRecordStarter.AddContributor(contributor); ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Post), typeof(Blog)); Assert.IsTrue(contributor.Called); }
public void Appliability_is_tested() { var contributor = new MockContributor(true); ActiveRecordStarter.AddContributor(contributor); ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Post), typeof(Blog)); Assert.IsTrue(contributor.Tested); }
public void Contributor_that_doesnt_apply_is_not_called() { var contributor = new MockContributor(false); ActiveRecordStarter.AddContributor(contributor); ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Post), typeof(Blog)); Assert.IsTrue(contributor.Tested); Assert.IsFalse(contributor.Called); }
public void Listener_is_added_to_config() { var contributor = new NHEventListeners(); var listener = new MockListener(); contributor.Add(listener); ActiveRecordStarter.AddContributor(contributor); ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Post), typeof(Blog)); Recreate(); Blog.FindAll(); var listeners = Blog.Holder.GetConfiguration(typeof(ActiveRecordBase)).EventListeners.PostInsertEventListeners; Assert.Greater(Array.IndexOf(listeners, listener), -1); }
public void Listener_is_called() { var contributor = new NHEventListeners(); var listener = new MockListener(); contributor.Add(listener); ActiveRecordStarter.AddContributor(contributor); ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Post), typeof(Blog)); Recreate(); Blog.FindAll(); new Blog() { Name = "Foo", Author = "Bar" }.SaveAndFlush(); Assert.IsTrue(listener.Called); }