public void UpdateNotifierProvider_should_update_configuration() { var notifier = Mock.Of <IScenarioProgressNotifier>(); var configuration = new ScenarioProgressNotifierConfiguration().UpdateNotifierProvider(() => notifier); Assert.That(configuration.NotifierProvider(null), Is.SameAs(notifier)); }
public void Should_initialize_object_with_default_values() { var configuration = new ScenarioProgressNotifierConfiguration(); Assert.That(configuration.NotifierProvider, Is.Not.Null); Assert.That(configuration.NotifierProvider(null), Is.InstanceOf <NoProgressNotifier>()); }
public void Configured_provider_should_throw_meaningful_exception_if_fixture_type_does_not_match() { var configuration = new ScenarioProgressNotifierConfiguration().UpdateNotifierProvider <ScenarioProgressNotifierConfiguration_tests>(fixture => NoProgressNotifier.Default); var ex = Assert.Throws <InvalidOperationException>(() => configuration.NotifierProvider(new object())); Assert.That(ex.Message, Is.EqualTo($"Unable to create {nameof(IScenarioProgressNotifier)}. Expected fixture of type '{GetType()}' while got '{typeof(object)}'.")); }
public void ClearNotifierProviders_should_reset_it_to_NoProgressNotifier() { var configuration = new ScenarioProgressNotifierConfiguration() .UpdateNotifierProvider(Mock.Of <IScenarioProgressNotifier>) .ClearNotifierProviders(); Assert.That(configuration.NotifierProvider(null), Is.InstanceOf <NoProgressNotifier>()); }
public void It_should_update_configuration_with_fixture_object() { object capturedFixture = null; var configuration = new ScenarioProgressNotifierConfiguration().UpdateNotifierProvider <object>(fixture => { capturedFixture = fixture; return(new DelegatingScenarioProgressNotifier()); }); var expectedFixture = new object(); Assert.That(configuration.NotifierProvider(expectedFixture), Is.InstanceOf <DelegatingScenarioProgressNotifier>()); Assert.That(capturedFixture, Is.SameAs(expectedFixture)); }
public void UpdateNotifierProvider_should_update_configuration_with_fixture_object() { var notifier = Mock.Of <IScenarioProgressNotifier>(); object capturedFixture = null; var configuration = new ScenarioProgressNotifierConfiguration().UpdateNotifierProvider <object>(fixture => { capturedFixture = fixture; return(notifier); }); var expectedFixture = new object(); Assert.That(configuration.NotifierProvider(expectedFixture), Is.SameAs(notifier)); Assert.That(capturedFixture, Is.SameAs(expectedFixture)); }
public void AppendNotifierProviders_should_append_notifiers_to_existing_ones() { var notifier1 = Mock.Of <IScenarioProgressNotifier>(); var notifier2 = Mock.Of <IScenarioProgressNotifier>(); var notifier3 = Mock.Of <IScenarioProgressNotifier>(); var notifier4 = Mock.Of <IScenarioProgressNotifier>(); var configuration = new ScenarioProgressNotifierConfiguration() .AppendNotifierProviders(() => notifier1, () => notifier2) .AppendNotifierProviders <object>(fixture => notifier3, fixture => notifier4); var notifier = configuration.NotifierProvider(new object()); Assert.That(notifier, Is.InstanceOf <DelegatingScenarioProgressNotifier>()); Assert.That(((DelegatingScenarioProgressNotifier)notifier).Notifiers, Is.EqualTo(new[] { notifier1, notifier2, notifier3, notifier4 })); }
public void AppendNotifierProvider_should_not_throw_StackOverflowException_when_added_self() { var notifier1 = Mock.Of <IScenarioProgressNotifier>(); var configuration = new ScenarioProgressNotifierConfiguration(); configuration.UpdateNotifierProvider(() => notifier1); configuration .AppendNotifierProviders(configuration.NotifierProvider); var notifier = configuration.NotifierProvider(new object()); notifier.NotifyScenarioStart(Mock.Of <IScenarioInfo>()); Mock.Get(notifier1).Verify(x => x.NotifyScenarioStart(It.IsAny <IScenarioInfo>()), Times.Exactly(2)); }
public void UpdateNotifierProvider_should_not_throw_StackOverflowException_when_added_self() { var notifier1 = Mock.Of <IScenarioProgressNotifier>(); var notifier2 = Mock.Of <IScenarioProgressNotifier>(); var configuration = new ScenarioProgressNotifierConfiguration(); configuration.UpdateNotifierProvider(() => notifier1); var previous = configuration.NotifierProvider; configuration .UpdateNotifierProvider <object>(feature => new DelegatingScenarioProgressNotifier(previous(feature), notifier2)); var notifier = configuration.NotifierProvider(new object()); notifier.NotifyScenarioStart(Mock.Of <IScenarioInfo>()); Mock.Get(notifier1).Verify(x => x.NotifyScenarioStart(It.IsAny <IScenarioInfo>()), Times.Once); Mock.Get(notifier2).Verify(x => x.NotifyScenarioStart(It.IsAny <IScenarioInfo>()), Times.Once); }
public void Configured_provider_should_throw_exception_if_fixture_is_null() { var configuration = new ScenarioProgressNotifierConfiguration().UpdateNotifierProvider <ScenarioProgressNotifierConfiguration_tests>(fixture => NoProgressNotifier.Default); Assert.Throws <ArgumentNullException>(() => configuration.NotifierProvider(null)); }
public void It_should_update_configuration() { var configuration = new ScenarioProgressNotifierConfiguration().UpdateNotifierProvider(() => new DelegatingScenarioProgressNotifier()); Assert.That(configuration.NotifierProvider(null), Is.InstanceOf <DelegatingScenarioProgressNotifier>()); }