public WeatherPredictionController( WeatherForecastClient weatherForecastClient, CityClient cityClient, IconClient iconClient, IOptions <ApiEndpoints> options) { _weatherForecastClient = weatherForecastClient; _cityClient = cityClient; _apiEndpoints = options.Value; }
static async Task Main(string[] args) { var baseUrl = @"http://localhost:5000"; var client = new WeatherForecastClient(baseUrl, new HttpClient()); var listado = await client.GetAsync(); Debug.WriteLine(listado); Console.ReadLine(); }
public async Task should_be_able_to_get_forecast_for_today() { //Arrange using var applicationFactory = new WebApplicationFactory <Program>(); var httpClient = applicationFactory.CreateClient(); var weatherForecastClient = new WeatherForecastClient(httpClient); //Act var result = await weatherForecastClient.GetForTodayAsync(); //Assert Assert.AreEqual(1, result?.Count); Assert.AreEqual(DateTime.Today, result ![0].Date.Date);
public async Task should_be_able_to_get_forecast_for_week() { //Arrange using var applicationFactory = new WebApplicationFactory <Program>(); var httpClient = applicationFactory.CreateClient(); var weatherForecastClient = new WeatherForecastClient(httpClient); //Act var result = await weatherForecastClient.GetForNextWeekAsync(); //Assert Assert.AreEqual(7, result?.Count); }
static void Main(string[] args) { Console.WriteLine("This is just a sample Console Client for OpenAPI."); WeatherForecastClient client = new WeatherForecastClient("https://localhost:44390", new System.Net.Http.HttpClient( )); Console.WriteLine($"The client will get forcasts form {client.BaseUrl} server."); var request = client.GetAsync( ); request.Wait( ); foreach (var forcast in request.Result) { Console.WriteLine(forcast.Summary); } }
// Start is called before the first frame update void Start() { Debug.Log("This is just a sample Unity Client for OpenAPI."); WeatherForecastClient client = new WeatherForecastClient("https://localhost:44390", new System.Net.Http.HttpClient( )); Debug.Log($"The client will get forcasts form {client.BaseUrl} server."); var request = client.GetAsync( ); request.Wait( ); foreach (var forcast in request.Result) { Debug.Log(forcast.Summary); } }
protected void Button1_Click(object sender, EventArgs e) { ziperror.Text = ""; Label2.Text = ""; if (String.IsNullOrEmpty(zip.Text)) { ziperror.Text = "please enter the zip code"; } else { Session["startDate"] = pick.Text; Session["endDate"] = drop.Text; Session["cityName"] = hotelcity.Text; if (!String.IsNullOrEmpty(un.Text)) Session["name"] = un.Text; CarRentalClient client = new CarRentalClient(); String picktime = "10:00"; String dropTime = "23:00"; if (Convert.ToInt32(h1.Text) > 24 || Convert.ToInt32(h2.Text) > 24 ) { Label2.Text = "hour should be less than 24"; } else { if ((Convert.ToInt32(m1.Text) == 30 || Convert.ToInt32(m1.Text) == 00) && (Convert.ToInt32(m2.Text) == 30 || Convert.ToInt32(m2.Text) == 00)) { picktime = h1.Text + ":" + m1.Text; dropTime = h2.Text + ":" + m2.Text; String[] carArray = client.carFinder(zip.Text, pick.Text, drop.Text, picktime, dropTime); ListBox1.Items.Clear(); for (int i = 0; i < carArray.Length; i++) ListBox1.Items.Add(carArray[i]); WeatherForecastClient client2 = new WeatherForecastClient(); String[] weatherArray = client2.getForecast(zip.Text); ListBox4.Items.Clear(); for (int i = 0; i < weatherArray.Length; i++) { ListBox4.Items.Add(weatherArray[i]); } } else Label2.Text = "Minutes should be 30 or 00 only"; } } }
public WeatherForecastContractTests(WeatherForecastApiPact data) { _mockProviderService = data.MockProviderService; _mockProviderService.ClearInteractions(); _client = new WeatherForecastClient(data.MockProviderServiceBaseUri); }