-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeatherForeCastTest.cs
More file actions
55 lines (52 loc) · 1.86 KB
/
Copy pathWeatherForeCastTest.cs
File metadata and controls
55 lines (52 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using NUnit.Framework;
using System.IO;
using System;
using System.Net;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace WeatherForecastTest
{
[TestFixture]
public class WeatherForeCastTest
{
[Test, Sequential]
public void RestAPITestFor2Cities([Values("2988507", "2964574")]string cityId)
{
var apiResponse = "";
var uri = String.Format("http://api.openweathermap.org/data/2.5/forecast?id={0}&APPID=aa69195559bd4f88d79f9aadeb77a8f6", cityId);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
apiResponse = reader.ReadToEnd();
}
Assert.IsNotEmpty(apiResponse);
}
[Test]
public void CheckAccessForEnvironmentforFolderCreation()
{
string accesstoEnvironment = "";
accesstoEnvironment = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
Assert.IsNotEmpty(accesstoEnvironment);
}
[Test]
[TestCase(500, "Windy", "Rain is expected", "i20d")]
public void checkForWeatherDeserialization(int id, string main, string description, string icon)
{
string json = @"{ 'id': 500, 'main': 'Clear','description': 'Windy','icon':'01d' }";
JsonConvert.DeserializeObject<Weather>(json);
}
}
public class ListData
{
public List<Weather> weather { get; set; }
}
public class Weather
{
public int id { get; set; }
public string main { get; set; }
public string description { get; set; }
public string icon { get; set; }
}
}