public void ReturnGetUserRatings_WhenUserExists_OnCallToGetUserRatings() { var userId = 1; var ratingRepository = A.Fake <IRatingRepository>(); var userRepository = A.Fake <IUserRepository>(); A.CallTo(() => userRepository.UserExists(userId)).Returns(true); var controller = new RatingsController(ratingRepository, userRepository, null, null); var response = controller.GetUserRatings(userId); A.CallTo(() => ratingRepository.GetUserRatings(userId)).MustHaveHappened(); }
public void ReturnBadRequest_WhenUserDoesNotExist_OnCallToGetUserRatings() { var userId = 1; var ratingRepository = A.Fake <IRatingRepository>(); var userRepository = A.Fake <IUserRepository>(); A.CallTo(() => userRepository.UserExists(userId)).Returns(false); var controller = new RatingsController(ratingRepository, userRepository, null, null); var response = controller.GetUserRatings(userId); Assert.AreEqual((int)HttpStatusCode.BadRequest, ((BadRequestObjectResult)response.Result).StatusCode); Assert.AreEqual($"User with Id {userId} does not exist.", ((BadRequestObjectResult)response.Result).Value); }