Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Web.Http;
- using System.Web.Http.Results;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- using MicroserviceHashtag.Models;
- namespace MicroserviceHashtag.Tests
- {
- [TestClass]
- public class SearchControllerTest
- {
- [TestMethod]
- public void SearchNotFoundByIdTest()
- {
- Controllers.ClassController searchController = new Controllers.ClassController();
- IHttpActionResult result = searchController.GetSearch(0);
- Assert.IsInstanceOfType(result, typeof(NotFoundResult));
- }
- [TestMethod]
- public void GetSearchByIdTest()
- {
- Controllers.ClassController searchController = new Controllers.ClassController();
- IHttpActionResult result = searchController.GetSearch(11);
- Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult<Search>));
- }
- [TestMethod]
- public void AddNullSearchTest()
- {
- Controllers.ClassController searchController = new Controllers.ClassController();
- IHttpActionResult result = searchController.AddSearch(null);
- Assert.IsInstanceOfType(result, typeof(BadRequestResult));
- }
- [TestMethod]
- public void UpdateNullSearchTest()
- {
- Controllers.ClassController searchController = new Controllers.ClassController();
- IHttpActionResult result = searchController.UpdateSearch(null, 1);
- Assert.IsInstanceOfType(result, typeof(BadRequestResult));
- }
- [TestMethod]
- public void AddGoodSearchTest()
- {
- Controllers.ClassController searchController = new Controllers.ClassController();
- Search testSearch = new Search()
- {
- CommentID = 1,
- MessageID = 1,
- UserID = 1,
- Hashtag = "test"
- };
- IHttpActionResult result = searchController.AddSearch(testSearch);
- searchController.DeleteSearch(testSearch.SearchID);
- Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult<Search>));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement