public void CallToggleLikeMethod_WhenParamsAreValid() { // Arrange var storyServiceMock = new Mock <IStoryService>(); var mappingServiceMock = new Mock <IMappingService>(); var userServiceMock = new Mock <IUserService>(); var utilsMock = new Mock <IUtilitiesService>(); var controller = new StoriesController(storyServiceMock.Object, mappingServiceMock.Object, userServiceMock.Object, utilsMock.Object); var controllerContext = new Mock <ControllerContext>(); var user = new Mock <IPrincipal>(); user.Setup(p => p.IsInRole("admin")).Returns(true); user.SetupGet(x => x.Identity.Name).Returns("username"); controllerContext.SetupGet(x => x.HttpContext.User).Returns(user.Object); controller.ControllerContext = controllerContext.Object; storyServiceMock.Setup(x => x.ToggleLike(It.IsAny <Guid>(), It.IsAny <string>())); var story = new Story(); storyServiceMock.Setup(x => x.GetById(It.IsAny <Guid>())).Returns(story); var model = new StoryDetailsViewModel(); mappingServiceMock.Setup(x => x.Map <StoryDetailsViewModel>(story)).Returns(model); // Act controller.LikeStory(Guid.NewGuid()); // Assert storyServiceMock.Verify(x => x.ToggleLike(It.IsAny <Guid>(), It.IsAny <string>()), Times.Once); }