/// <summary> /// Appends <paramref name="notifiers"/> to existing <see cref="Notifier"/> making all of them used during notification. /// </summary> /// <param name="notifiers">Notifiers to append</param> /// <returns>Self</returns> /// <exception cref="ArgumentNullException">Throws when <paramref name="notifiers"/> collection or any of it's item is null.</exception> public FeatureProgressNotifierConfiguration AppendNotifiers(params IFeatureProgressNotifier[] notifiers) { ThrowIfSealed(); if (notifiers == null) { throw new ArgumentNullException(nameof(notifiers)); } Notifier = DelegatingFeatureProgressNotifier.Compose(Enumerable.Repeat(Notifier, 1).Concat(notifiers)); return(this); }
public void Compose_should_flatten_notifiers_and_return_NoProgressNotifier_if_no_specific_notifiers_are_present() { var result = DelegatingFeatureProgressNotifier.Compose(new IFeatureProgressNotifier[] { new DelegatingFeatureProgressNotifier( NoProgressNotifier.Default, NoProgressNotifier.Default, new DelegatingFeatureProgressNotifier(), new DelegatingFeatureProgressNotifier(NoProgressNotifier.Default)), NoProgressNotifier.Default, new DelegatingFeatureProgressNotifier() }); Assert.That(result, Is.TypeOf <NoProgressNotifier>()); }
public void Compose_should_flatten_notifiers_and_return_specific_one_if_only_one_is_present() { var specific = Mock.Of <IFeatureProgressNotifier>(); var result = DelegatingFeatureProgressNotifier.Compose(new IFeatureProgressNotifier[] { new DelegatingFeatureProgressNotifier( NoProgressNotifier.Default, NoProgressNotifier.Default, new DelegatingFeatureProgressNotifier(), new DelegatingFeatureProgressNotifier(NoProgressNotifier.Default, specific)), NoProgressNotifier.Default, new DelegatingFeatureProgressNotifier() }); Assert.That(result, Is.SameAs(specific)); }
public void Compose_should_flatten_notifiers() { var specific1 = Mock.Of <IFeatureProgressNotifier>(); var specific2 = Mock.Of <IFeatureProgressNotifier>(); var result = DelegatingFeatureProgressNotifier.Compose(new[] { new DelegatingFeatureProgressNotifier( NoProgressNotifier.Default, NoProgressNotifier.Default, new DelegatingFeatureProgressNotifier(), new DelegatingFeatureProgressNotifier(NoProgressNotifier.Default, specific1)), NoProgressNotifier.Default, new DelegatingFeatureProgressNotifier(), specific2 }); Assert.That(result, Is.TypeOf <DelegatingFeatureProgressNotifier>()); Assert.That( ((DelegatingFeatureProgressNotifier)result).Notifiers, Is.EqualTo(new[] { specific1, specific2 })); }
public void SetUp() { _notifiers = new[] { Mock.Of <IFeatureProgressNotifier>(), Mock.Of <IFeatureProgressNotifier>() }; _subject = new DelegatingFeatureProgressNotifier(_notifiers); }