Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. using System;
  2. using System.Web.Http;
  3. using System.Web.Http.Results;
  4. using Microsoft.VisualStudio.TestTools.UnitTesting;
  5. using MicroserviceHashtag.Models;
  6.  
  7.  
  8.  
  9. namespace MicroserviceHashtag.Tests
  10. {
  11. [TestClass]
  12. public class SearchControllerTest
  13. {
  14.  
  15. [TestMethod]
  16. public void SearchNotFoundByIdTest()
  17. {
  18. Controllers.ClassController searchController = new Controllers.ClassController();
  19.  
  20. IHttpActionResult result = searchController.GetSearch(0);
  21.  
  22. Assert.IsInstanceOfType(result, typeof(NotFoundResult));
  23. }
  24.  
  25. [TestMethod]
  26. public void GetSearchByIdTest()
  27. {
  28. Controllers.ClassController searchController = new Controllers.ClassController();
  29.  
  30. IHttpActionResult result = searchController.GetSearch(11);
  31. Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult<Search>));
  32. }
  33.  
  34.  
  35. [TestMethod]
  36. public void AddNullSearchTest()
  37. {
  38. Controllers.ClassController searchController = new Controllers.ClassController();
  39.  
  40. IHttpActionResult result = searchController.AddSearch(null);
  41. Assert.IsInstanceOfType(result, typeof(BadRequestResult));
  42.  
  43. }
  44.  
  45. [TestMethod]
  46. public void UpdateNullSearchTest()
  47. {
  48. Controllers.ClassController searchController = new Controllers.ClassController();
  49.  
  50. IHttpActionResult result = searchController.UpdateSearch(null, 1);
  51.  
  52. Assert.IsInstanceOfType(result, typeof(BadRequestResult));
  53.  
  54. }
  55.  
  56.  
  57. [TestMethod]
  58. public void AddGoodSearchTest()
  59. {
  60. Controllers.ClassController searchController = new Controllers.ClassController();
  61. Search testSearch = new Search()
  62. {
  63. CommentID = 1,
  64. MessageID = 1,
  65. UserID = 1,
  66. Hashtag = "test"
  67. };
  68.  
  69. IHttpActionResult result = searchController.AddSearch(testSearch);
  70. searchController.DeleteSearch(testSearch.SearchID);
  71.  
  72. Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult<Search>));
  73. }
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement