public void Without_duplicated_dependencies_it_should_not_generated_error_messages() { var validator = new CheckForMultipleTimesRegisteredDependencies(); var tasks = new[] { new RegisteredTask(typeof(ExampleTask0)) {DependsOn = new []{ nameof(ExampleTask0), nameof(ExampleTask1)}}, }; var errors = validator.Validate(tasks); Assert.IsEmpty(errors); }
public void Duplicated_dependencies_should_generate_a_error_message_for_each_duplicate() { var validator = new CheckForMultipleTimesRegisteredDependencies(); var tasks = new[] { new RegisteredTask(typeof(ExampleTask1)) {DependsOn = new []{ nameof(ExampleTask2), nameof(ExampleTask2) }}, new RegisteredTask(typeof(ExampleTask3)) {DependsOn = new []{ nameof(ExampleTask4), nameof(ExampleTask4) }}, }; var errors = validator.Validate(tasks).ToList(); Assert.AreEqual(2, errors.Count); errors.RemoveAll(x => x.Contains($"\"{nameof(ExampleTask1)}\"") && x.Contains($"\"{nameof(ExampleTask2)}\"")); Assert.AreEqual(1, errors.Count); errors.RemoveAll(x => x.Contains($"\"{nameof(ExampleTask3)}\"") && x.Contains($"\"{nameof(ExampleTask4)}\"")); Assert.AreEqual(0, errors.Count); }