public void GetTag_GetNotFoundIfTagIsNone() { //Arrange Mock <ITagRepository> mockTagRepository = new Mock <ITagRepository>(); mockTagRepository.Setup(tag => tag.GetTag(It.IsAny <int>(), It.IsAny <int>())).Returns((int userId, int movieId) => tags.Where(x => x.userId == userId && x.movieId == movieId).SingleOrDefault()); var controller = new TagsController(mockTagRepository.Object); //Act var result = controller.GetTag(1, 1324).Result; //Assert Assert.IsInstanceOf <NotFoundResult>(result); }
public void GetTag_GetTagByUserAndMovie() { //Arrange Mock <ITagRepository> mockTagRepository = new Mock <ITagRepository>(); mockTagRepository.Setup(tag => tag.GetTag(It.IsAny <int>(), It.IsAny <int>())).Returns((int userId, int movieId) => tags.Where(x => x.userId == userId && x.movieId == movieId).SingleOrDefault()); var controller = new TagsController(mockTagRepository.Object); //Act Tag tag = controller.GetTag(1, 1).Value; //Assert Assert.IsNotNull(tag); Assert.AreEqual(tag, tags[0]); }
public void ApiTagsController_Details() { //Arrange var tagsRepo = new FakeRepository <Tag>(e => e.TagID); tagsRepo.Create(new Tag() { TagID = 1, TagLabel = "testing" }); //Act var controller = new TagsController(tagsRepo); var result = controller.GetTag(1) as OkNegotiatedContentResult <TagApi>; //Assert Assert.IsNotNull(result); }