Beispiel #1
0
        public void ReturnRating_OnCallToAddRating()
        {
            var newRating = new Rating
            {
                Description = "Test",
                Code        = "Test"
            };

            var result = new Rating
            {
                UserId = newRating.UserId
            };

            var userHelper       = A.Fake <IUserHelper>();
            var ratingRepository = A.Fake <IRatingRepository>();

            A.CallTo(() => ratingRepository.GetRating(A <int> .Ignored)).Returns(result);

            var validator  = new RatingValidator();
            var controller = new RatingsController(ratingRepository, null, userHelper, validator);

            var response = controller.AddRating(newRating);

            A.CallTo(() => ratingRepository.Add(newRating)).MustHaveHappened();
            Assert.AreEqual(result.UserId, response.Value.UserId);
        }