public void Execute_ShouldThrowBusinessException_WhenEmptyLocation(string location) { var weatherService = new Mock <IMetaWeatherService>(); var useCase = new SearchLocationUseCase(weatherService.Object, Mapper.Instance); Action action = () => useCase.Execute(location).Wait(); action.Should().Throw <BusinessException>() .WithMessage("Can't search for an empty location!"); }
public async Task Execute_ShouldReturnLocations() { var weatherService = new Mock <IMetaWeatherService>(); weatherService.Setup(x => x.SearchLocation("location")) .ReturnsAsync(new List <LocationResumeDto> { new LocationResumeDto { Woeid = 1, Title = "loc" }, new LocationResumeDto { Woeid = 2, Title = "ation" } }); var useCase = new SearchLocationUseCase(weatherService.Object, Mapper.Instance); var result = await useCase.Execute("location"); result.Should().BeEquivalentTo(new List <Location> { new Location(1, "loc"), new Location(2, "ation") }); }