public void Discarded_CreateConfigWithoutDisposingIt_ReturnsNoCalls() { var config = GetTestConfig(@"<testconfig />"); var disposer = new DiscardListener(); config.Discarded += disposer.ConfigDiscarded; Assert.AreEqual(0, disposer.NumberOfCalled); }
public void Discarded_CreateConfigDisposingItSeveralTimes_ReturnsOneCalls() { var config = GetTestConfig(@"<testconfig />"); var disposeListener = new DiscardListener(); config.Discarded += disposeListener.ConfigDiscarded; config.Discard(); config.Discard(); config.Discard(); config.Discard(); config.Discard(); config.Discard(); Assert.AreEqual(1, disposeListener.NumberOfCalled); }
public void Discarded_WathcerAttachedWhenCreated_DiscaredIsCalledWhenWathcerChanged() { XmlElement configXmlElement = GetConfigXmlDocument(@"<testconfig />"); var configSource = A.Fake <IConfigSource>(); var watcher = new FakeWatcher(); A.CallTo(() => configSource.Watcher).Returns(watcher); var config = ConfigFactory.Create("testConfig", configXmlElement, configSource); var listener = new DiscardListener(); config.Discarded += listener.ConfigDiscarded; watcher.OnWatchedFileChange(); Assert.NotNull(config.ConfigSource.Watcher != null); Assert.AreEqual(1, listener.NumberOfCalled); }
protected virtual void OnForceDiscard(DiscardListener e) { if (ForceDiscard != null) ForceDiscard(this, e); }
public void Discarded_WathcerAttachedWhenCreated_DiscaredIsCalledWhenWathcerChanged() { XmlElement configXmlElement = GetConfigXmlDocument(@"<testconfig />"); var configSource = A.Fake<IConfigSource>(); var watcher = new FakeWatcher(); A.CallTo(() => configSource.Watcher).Returns(watcher); var config = ConfigFactory.Create("testConfig", configXmlElement, configSource); var listener = new DiscardListener(); config.Discarded += listener.ConfigDiscarded; watcher.OnWatchedFileChange(); Assert.NotNull(config.ConfigSource.Watcher != null); Assert.AreEqual(1, listener.NumberOfCalled); }