public void TestDelete() { mockPostRepository.Setup(x => x.Delete(It.IsAny <string>())).Returns(true); PostService.Services.PostService _postService = new PostService.Services.PostService(mockPostRepository.Object, mockPublishToTopic.Object); bool checkDeleted = _postService.Delete("5d07d847a2c5f845707dc69x"); Assert.IsTrue(checkDeleted); }
public void TestGetById() { mockPostRepository.Setup(x => x.GetById(It.IsAny <string>())).Returns(post); PostService.Services.PostService _postService = new PostService.Services.PostService(mockPostRepository.Object, mockPublishToTopic.Object); Post postActual = _postService.GetById("5d07d847a2c5f845707dc69x"); Assert.AreEqual(postActual, post); }
public void TestUpdate() { mockPostRepository.Setup(x => x.Update(It.IsAny <Post>())).Returns(post); PostService.Services.PostService _postService = new PostService.Services.PostService(mockPostRepository.Object, mockPublishToTopic.Object); Post postActual = _postService.Update(post); Assert.AreEqual(postActual, post); }
public void TestGetAllPostStatistics() { Mock <IArticleRepository> mockArticleRepository = new Mock <IArticleRepository>(); Mock <IVirtualTripRepository> mockVirtualTripRepository = new Mock <IVirtualTripRepository>(); Mock <ICompanionPostRepository> mockCompanionPostRepository = new Mock <ICompanionPostRepository>(); mockArticleRepository.Setup(x => x.GetArticleStatistics(It.IsAny <StatisticsFilter>())).Returns(post); mockVirtualTripRepository.Setup(x => x.GetVirtualTripStatistics(It.IsAny <StatisticsFilter>())).Returns(post); mockCompanionPostRepository.Setup(x => x.GetCompanionPostStatistics(It.IsAny <StatisticsFilter>())).Returns(post); PostService.Services.PostService _postService = new PostService.Services.PostService(mockVirtualTripRepository.Object, mockArticleRepository.Object, mockCompanionPostRepository.Object); var getAllPostStatistics = _postService.GetAllPostStatistics(statisticsFilter); Assert.IsNotNull(getAllPostStatistics); }
public void TestGetPosts() { List <Post> listPost = new List <Post>(); listPost.Add(post); IEnumerable <Post> posts = listPost; mockPostRepository.Setup(x => x.GetPosts(It.IsAny <string>(), It.IsAny <int>())).Returns(posts); PostService.Services.PostService _postService = new PostService.Services.PostService(mockPostRepository.Object, mockPublishToTopic.Object); IEnumerable <Post> getPostsActual = _postService.GetPosts("Kham pha", 1); Post postActual = getPostsActual.FirstOrDefault(); Assert.AreEqual(postActual, post); }