public async Task SearchTopContains_NamePartLowerCase_ReturnUpperCase() { // arrange var stations = new List <Station> { new Station("TestTest", "tst"), new Station("TEST_", "tst_"), new Station("Name", "nm"), new Station("XyZ", "xyz") }; _stationsRepository.Setup(s => s.AsQueryable()).Returns(stations.AsQueryable().BuildMock().Object); _lookupStationsService = new LookupStationsService(_stationsRepository.Object); // act var foundStations = (await _lookupStationsService.GetByAnyNamePartAsync("test")).ToArray(); // assert CollectionAssert.AllItemsAreUnique(foundStations); CollectionAssert.AllItemsAreNotNull(foundStations); CollectionAssert.AllItemsAreInstancesOfType(foundStations, typeof(Station)); CollectionAssert.AreEqual(foundStations.Select(s => s.Name).ToArray(), new [] { "TEST_", "TestTest" }); Assert.IsTrue(foundStations.Length == 2); }
public async Task <IActionResult> GetByAnyNamePartAsync([Required, FromQuery] string namePart) { return(Ok(_mapper.Map <IEnumerable <Station> >( await _lookupStationsService.GetByAnyNamePartAsync(namePart)))); }