Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. string thesearchtext, thecitytype;
  2. thesearchtext = HttpContext.Current.Request.QueryString["s"].ToString();
  3. thecitytype = HttpContext.Current.Request.QueryString["bt"].ToString();
  4.  
  5. cannot implicitly convert type 'string' to 'bool'
  6.  
  7. int listingsToSearch;
  8. if (thecitytype = "City1")
  9. {
  10. listingsToSearch = Convert.ToInt32(1);
  11. }
  12. else
  13. {
  14. listingsToSearch = Convert.ToInt32(2);
  15. }
  16.  
  17. if (thecitytype == "City1")
  18.  
  19. listingsToSearch = 1;
  20.  
  21. [Test]
  22. public void testGetCityToSearch()
  23. {
  24.  
  25. // if thecitytype = "City1", listingToSearch = 1
  26. // if thecitytype = "City2", listingToSearch = 2
  27.  
  28. doParseCity(1, "City1");
  29. doParseCity(2, "City2");
  30. doParseCity(20, "City20");
  31. }
  32.  
  33. public void doParseCity(int expected, string input )
  34. {
  35. int listingsToSearch;
  36. string cityNum = input.Substring(4);
  37. bool parseResult = Int32.TryParse(cityNum, out listingsToSearch);
  38. Assert.IsTrue(parseResult);
  39. Assert.AreEqual(expected, listingsToSearch);
  40. }
  41.  
  42. string thecitytype20 = "City20";
  43. string cityNum20 = thecitytype20.Substring(4);
  44. bool parseResult20 = Int32.TryParse(cityNum20, out listingsToSearch);
  45. // parseResult20 tells you whether parse succeeded, listingsToSearch will give you 20
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement