public void AddNewPost_Test() { // Arrange var mock = new Mock <IAdminsPostService>(); var notificationMock = new Mock <IPushNotificationsService>(); mock.Setup(serv => serv.AddNewPost(newPost)); var controller = new AdminsPostController(mock.Object, notificationMock.Object); // Act var result = controller.AddNewAdminsPost(newPost).Result as ObjectResult; // Assert Assert.Equal(StatusCodes.Status201Created, result.StatusCode); Assert.Equal(newPost, result.Value); }
public void GetAllPublicPosts_Test() { // Arrange var mock = new Mock <IAdminsPostService>(); var notificationMock = new Mock <IPushNotificationsService>(); mock.Setup(serv => serv.GetAllPublicPosts()).Returns(publicPosts); var controller = new AdminsPostController(mock.Object, notificationMock.Object); // Act var result = controller.GetAllPublicPosts().Result as ObjectResult; // Assert Assert.Equal(StatusCodes.Status200OK, result.StatusCode); Assert.Equal(publicPosts, result.Value); }
public void GetAllPrivatePosts_Test(int id) { // Arrange var mock = new Mock <IAdminsPostService>(); var notificationMock = new Mock <IPushNotificationsService>(); var filteredPosts = privatePosts.Where(post => post.ToUserId == id); mock.Setup(serv => serv.GetAllPersonalPosts(id)).Returns(filteredPosts); var controller = new AdminsPostController(mock.Object, notificationMock.Object); // Act var result = controller.GetAllPersonalPosts(id).Result as ObjectResult; // Assert Assert.Equal(StatusCodes.Status200OK, result.StatusCode); Assert.Equal(filteredPosts, result.Value); }