public async Task Execute() { IValidationErrorCache validationErrorCache = new ValidationErrorCache(); var ruleSet = new List <IRule <string> > { new RuleOne(validationErrorCache), new RuleTwo(validationErrorCache) }; var ruleSetResolutionServiceMock = new Mock <IRuleSetResolutionService <IRule <string>, string> >(); ruleSetResolutionServiceMock.Setup(rs => rs.Resolve()).Returns(ruleSet); const string one = "one"; const string two = "two"; var validationItems = new List <string> { one, two }; var cancellationToken = CancellationToken.None; var ruleSetExecutionService = new RuleSetExecutionService <IRule <string>, string>(); var service = NewService(ruleSetResolutionServiceMock.Object, ruleSetExecutionService, validationErrorCache); (await service.ExecuteAsync(validationItems, cancellationToken)).Should().HaveCount(6); }
public async Task Execute_NoValidationItems_Null() { var output = new List <string> { "1", "2", "3" }; IValidationErrorCache validationErrorCache = new ValidationErrorCache(); var ruleSetResolutionServiceMock = new Mock <IRuleSetResolutionService <IRule <string>, string> >(); ruleSetResolutionServiceMock.Setup(rs => rs.Resolve()).Returns(new List <IRule <string> >() { new RuleOne(validationErrorCache), new RuleTwo(validationErrorCache) }); var cancellationToken = CancellationToken.None; var ruleSetExecutionService = new RuleSetExecutionService <IRule <string>, string>(); var service = NewService(ruleSetResolutionServiceMock.Object, validationErrorCache: validationErrorCache, ruleSetExecutionService: ruleSetExecutionService); (await service.ExecuteAsync((IEnumerable <string>)null, cancellationToken)).Should().BeEmpty(); }