public void GetProviderShouldReturnTheProviderWithTheHighestPriorityValue([Frozen] IGetsMessageProviderInfoFactory providerFactoryFactory, FailureMessageProviderSelector sut, IGetsMessageProviderInfo providerFactory, SampleProvider provider1, SampleProvider provider2, SampleProvider provider3, [RuleResult] ValidationRuleResult ruleResult) { var info1 = new TestingMessageProviderInfo(provider1, 4); var info2 = new TestingMessageProviderInfo(provider2, 10); var info3 = new TestingMessageProviderInfo(provider3, 3); Mock.Get(providerFactoryFactory).Setup(x => x.GetProviderInfoFactory()).Returns(providerFactory); Mock.Get(providerFactory).Setup(x => x.GetMessageProviderInfo(ruleResult)).Returns(new[] { info1, info2, info3 }); Assert.That(() => sut.GetProvider(ruleResult), Is.SameAs(provider2)); }
/// <summary> /// Initialises a new instance of <see cref="FailureMessageProviderSelector"/>. /// </summary> /// <param name="providerInfoFactoryFactory">A factory service that gets the message provider info factory.</param> /// <exception cref="System.ArgumentNullException">If <paramref name="providerInfoFactoryFactory"/> is <see langword="null" />.</exception> public FailureMessageProviderSelector(IGetsMessageProviderInfoFactory providerInfoFactoryFactory) { this.providerInfoFactoryFactory = providerInfoFactoryFactory ?? throw new System.ArgumentNullException(nameof(providerInfoFactoryFactory)); }