WebClientHelperTests.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using Utils;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Text;
  6. using System.Collections.Specialized;
  7. using Newtonsoft.Json;
  8. namespace Utils.Tests
  9. {
  10. [TestClass()]
  11. public class WebClientHelperTests
  12. {
  13. [TestMethod()]
  14. public void ClientPostTest()
  15. {
  16. var thisDate = DateTime.Now;
  17. var date = thisDate.ToString("yyyy年MM月dd日");
  18. var closingDate = "2021年05月至2021年06月";
  19. var type = "1";
  20. var phone = "13488868166";
  21. var outingDate = "2021年07月12日";
  22. string url = AppSettingsHelper.Configuration["kunshanUrl"];
  23. var postvalues = new NameValueCollection();
  24. postvalues.Add("telephone", phone);
  25. postvalues.Add("type", type);
  26. postvalues.Add("closingDate", closingDate);
  27. postvalues.Add("outingDate", outingDate);
  28. var res = WebClientHelper.ClientPost(url, postvalues);
  29. var outData=JsonConvert.DeserializeObject<OutData>(res);
  30. Assert.Fail();
  31. }
  32. }
  33. public class OutData
  34. {
  35. public string status { get; set; }
  36. public string msg { get; set; }
  37. public string contents { get; set; }
  38. }
  39. }