public void SecurePostEndPointTestusingPostHelper() { string postUrl = "http://localhost:8080/laptop-bag/webapi/secure/add"; int id = random.Next(1001); string jsonData = "{" + "\"BrandName\": \"Animalware\"," + "\"Features\": {" + "\"Feature\": [" + "\"8th Generation Intel® Core™ i5-8300H\"," + "\"Windows 10 Home 64-bit English\"," + "\"NVIDIA® GeForce® GTX 1660 Ti 6GB GDDR6\"," + "\"8GB, 2x4GB, DDR4, 2666MHz\"" + "]" + "}," + "\"Id\":" + id + "," + "\"LaptopName\": \"Alienware M17\"" + "}"; string authHeader = "Basic " + Base64AuthenticationHelper.GetBase64String("admin", "welcome"); Dictionary <string, string> httpHeader = new Dictionary <string, string>(); httpHeader.Add("Accept", "application/json"); httpHeader.Add("Authorization", authHeader); HttpContent httpContent = new StringContent(jsonData, Encoding.UTF8, jsonMediaType); RestResponse restResponse = HttpClientHelper.PerformPostRequest(postUrl, httpContent, httpHeader); Console.WriteLine(restResponse.ToString()); JsonRootObject jsonRootObject = JsonConvert.DeserializeObject <JsonRootObject>(restResponse.ResponseData); Assert.AreEqual("ware M17", jsonRootObject.LaptopName); }
public void TestSecureGetAllEndPointusingGetHelper() { var getUrl = "http://localhost:8080/laptop-bag/webapi/delay/all"; string authHeader = "Basic " + Base64AuthenticationHelper.GetBase64String("admin", "welcome"); Dictionary <string, string> httpHeader = new Dictionary <string, string>(); httpHeader.Add("Accept", "application/json"); //httpHeader.Add("Authorization", "Basic YWRtaW46d2VsY29tZQ=="); // httpHeader.Add("Authorization", authHeader); RestResponse restResponse = HttpClientHelper.PerformGetRequest(getUrl, httpHeader); Console.WriteLine(restResponse.ToString()); List <JsonRootObject> JsonData = JsonConvert.DeserializeObject <List <JsonRootObject> >(restResponse.ResponseData); Assert.AreEqual("Alienware", JsonData[0].BrandName); }