private void SetExclude(ErrorPolicyBase errorPolicy, IConfigurationSection configSection) { foreach (var typeName in configSection.GetChildren().Select(c => c.Value)) { errorPolicy.Exclude(Type.GetType(typeName)); } }
private void SetMaxFailedAttempts(ErrorPolicyBase errorPolicy, IConfigurationSection configSection) { if (string.IsNullOrEmpty(configSection.Value)) { return; } errorPolicy.MaxFailedAttempts(int.Parse(configSection.Value)); }
public void HandleError_MultiplePoliciesWithSetMaxFailedAttempts_CorrectPolicyApplied(int failedAttempts, int expectedAppliedPolicy) { var policies = new ErrorPolicyBase[] { new TestErrorPolicy().MaxFailedAttempts(2), new TestErrorPolicy().MaxFailedAttempts(2), new TestErrorPolicy().MaxFailedAttempts(2) }; var chain = _errorPolicyBuilder.Chain(policies); chain.HandleError(new InboundMessage { Message = new TestEventOne(), FailedAttempts = failedAttempts }, new Exception("test")); for (int i = 0; i < policies.Length; i++) { policies[i].As <TestErrorPolicy>().Applied.Should().Be(i == expectedAppliedPolicy); } }