public void TaxaValidationServiceTests_ValidateOfThreeItemsWithOneInvalid_SchouldReturnThreeValidatedItems() { string[] taxa = { "Coleoptera", "Zospeum", "John Smith" }; var items = taxa.ToArray(); var service = new TaxaValidationService(this.cacheService, this.requester); var result = service.Validate(items).Result.ToList(); const int ExpectedNumberOfItems = 3; Assert.AreEqual(ExpectedNumberOfItems, result.Count, "The number of returned items should be 3."); foreach (var taxon in taxa) { var matchingResults = result.Where(r => r.ValidatedObject == taxon); Assert.AreEqual( 1, matchingResults.Count(), $"Result should contain ‘{taxon}’ only once."); var matchingResult = matchingResults.First(); if (taxon == taxa[2]) { Assert.IsTrue(matchingResult.ValidationStatus == ValidationStatus.Invalid, $"‘{taxon}’ should be valid."); } else { Assert.IsTrue(matchingResult.ValidationStatus == ValidationStatus.Valid, $"‘{taxon}’ should be valid."); } Assert.IsNull(matchingResult.ValidationException, $"‘{taxon}’ should have null exception."); } }
public void TaxaValidationServiceTests_ValidateOfThreeItems_SchouldReturnThreeValidatedItems() { string[] taxa = { "Coleoptera", "Zospeum", "H**o sapiens" }; var items = taxa.ToArray(); var service = new TaxaValidationService(this.cacheService, this.requester); var result = service.Validate(items).Result.ToList(); const int ExpectedNumberOfItems = 3; Assert.AreEqual(ExpectedNumberOfItems, result.Count, "The number of returned items should be 3."); for (int i = 0; i < ExpectedNumberOfItems; ++i) { Assert.AreEqual( 1, result.Where(r => r.ValidatedObject == items[i]).Count(), $"Result should contain Item #{i} only once."); Assert.IsTrue(result[i].ValidationStatus == ValidationStatus.Valid, $"Item #{i} should be valid."); Assert.IsNull(result[i].ValidationException, $"Item #{i} should have null exception."); } }