//[Test] //[Ignore("Only used for test the TestCase Attribute")] //[TestCase("liucheng", "Password")] public void TestCurentUser(string username, string password) { var url = baseUrl + TestConstants.Apis.CurentUser; var user = new User(username, password); CookieContainer cc = Cookies.GetCookieContainer(user); //Web request HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "GET"; request.ContentType = "application/json"; request.CookieContainer = cc; // use containaer by current user var response = (HttpWebResponse)request.GetResponse(); Assert.AreEqual("OK", response.StatusCode.ToString()); Stream responseStream = response.GetResponseStream(); StreamReader reader = new StreamReader(responseStream); string readerContent = reader.ReadToEnd(); JObject jObject = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(readerContent); Assert.AreEqual(this.userName.ToUpper(), jObject["key"].ToString().ToUpper()); }
public void Init() { var user = new User(this.userName, this.password); this.cookieContainer = Cookies.GetCookieContainer(user); }