public async Task NetConnector_PostDictionary_WithValidParameters_ShouldWork(string url, string name, string category, decimal price) { var connector = new NetConnector(BaseAddress); var values = new Dictionary <string, string> { { "name", name }, { "category", category }, { "price", price.ToString() } }; var response = await connector.PostAsync(url, values, Encoding.UTF8); Assert.IsNotNull(response, "Response should not be null."); Assert.IsTrue(response.Contains(name), "Response should contain the name."); Assert.IsTrue(response.Contains(category), "Response should contain the category."); Assert.IsTrue(response.Contains(price.ToString()), "Response should contain the price."); }
public async Task NetConnector_PostString_WithValidParameters_ShouldWork(string url, string name, string category, decimal price) { var product = new Product { Name = name, Category = category, Price = price }; string content = JsonConvert.SerializeObject(product); var connector = new NetConnector(BaseAddress); var response = await connector.PostAsync(url, content, "application/json", Encoding.UTF8); Assert.IsNotNull(response, "Response should not be null."); Assert.IsTrue(response.Contains(name), "Response should contain the name."); Assert.IsTrue(response.Contains(category), "Response should contain the category."); Assert.IsTrue(response.Contains(price.ToString()), "Response should contain the price."); Console.WriteLine(content); Console.WriteLine(response); }