public override IActiveRecordConfiguration GetConfigSource() { var contributor = new NHEventListeners(); var listener = new MockListener(); contributor.Add(listener); return base.GetConfigSource() .GetConfiguration(string.Empty) .AddContributor(contributor) .Source; }
public override IActiveRecordConfiguration GetConfigSource() { var contributor = new NHEventListeners(); var listener = new MockListener(); contributor.Add(listener); return(base.GetConfigSource() .GetConfiguration(string.Empty) .AddContributor(contributor) .Source); }
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); }
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_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); }
public void NhEventListenersServesCollectionSemanticsForEventListeners() { var sut = new NHEventListeners(); var listener1 = new StubEventListener(); var listener2 = new StubEventListener(); sut.Add(listener1); Assert.AreEqual(1, (new List <IPreUpdateEventListener>(sut.Enumerate <IPreUpdateEventListener>())).Count); Assert.IsTrue(sut.Contains(listener1)); Assert.IsFalse(sut.Contains(listener2)); sut.Remove(listener2); Assert.AreEqual(1, (new List <IPreUpdateEventListener>(sut.Enumerate <IPreUpdateEventListener>())).Count); Assert.IsTrue(sut.Contains(listener1)); sut.Remove(listener1); Assert.AreEqual(0, (new List <IPreUpdateEventListener>(sut.Enumerate <IPreUpdateEventListener>())).Count); Assert.IsFalse(sut.Contains(listener1)); }
public void NHEventListeners_serves_collection_semantics_for_event_listeners() { var sut = new NHEventListeners(); var listener1 = new StubEventListener(); var listener2 = new StubEventListener(); sut.Add(listener1); Assert.AreEqual(1, (new List<IPreUpdateEventListener>(sut.Enumerate<IPreUpdateEventListener>())).Count); Assert.IsTrue(sut.Contains(listener1)); Assert.IsFalse(sut.Contains(listener2)); sut.Remove(listener2); Assert.AreEqual(1, (new List<IPreUpdateEventListener>(sut.Enumerate<IPreUpdateEventListener>())).Count); Assert.IsTrue(sut.Contains(listener1)); sut.Remove(listener1); Assert.AreEqual(0, (new List<IPreUpdateEventListener>(sut.Enumerate<IPreUpdateEventListener>())).Count); Assert.IsFalse(sut.Contains(listener1)); }