public static async Task <int> CreatePromotion() { try { NewPromotion promotion = TestHelper.BasePromotion(); string json = JsonConvert.SerializeObject(promotion); var content = new System.Net.Http.StringContent(json, UnicodeEncoding.UTF8, "application/json"); string urlparam = Resources.promotions; var Response = await TestHelper.Send(WebRequestType.Post, urlparam, content); var id = JsonConvert.DeserializeObject <Id>(Response); var PromotionId = id.id; if (PromotionId > 0) { return(PromotionId); } else { return(-1); } } catch (Exception) { return(-1); } }
public async void testCreatePromotion() { Console.WriteLine("------testCreatePromotion"); try { int id = await ApiClass.CreatePromotion(); //id = -1; Assert.False(id == -1, Messages.msg_object_not_created); Console.WriteLine(Messages.msg_object_created); Promotion Response = await ApiClass.GetPromotion(id); NewPromotion etalon = TestHelper.BasePromotion(); //etalon.name.en = ""; NewPromotion actual = Response as NewPromotion; Assert.AreEqual(etalon, actual, Messages.msg_objects_not_equal); Console.WriteLine(Messages.msg_objects_equal); Console.WriteLine(Messages.msg_test_pass); } catch (Exception e) { Console.WriteLine(Messages.msg_test_fail); } }