Esempio n. 1
0
        public void Done_ShouldReturnViewResultWithAllDoneReviewsForCurrentUser()
        {
            //Arrange
            var userId          = "id";
            var expectedReviews = new List <DoneHomeReviewServiceModel>
            {
                new DoneHomeReviewServiceModel
                {
                    Evaluation         = 5,
                    AdditionalThoughts = "good",
                    HomeId             = 1,
                    OwnerId            = "ownerId",
                    OwnerName          = "owner",
                    SubmitDate         = DateTime.UtcNow,
                    Title = "good stay"
                }
            };

            var userManager = UserManagerMock.New;

            userManager
            .Setup(um => um.GetUserId(It.IsAny <ClaimsPrincipal>()))
            .Returns(userId);

            var homeReviewsService = HomeReviewServiceMock.New;

            homeReviewsService
            .Setup(hrs => hrs.Done(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>()))
            .Returns(expectedReviews);

            var controller = new ReviewsController(homeReviewsService.Object, null, userManager.Object, null);

            //Act
            var result = controller.Done(It.IsAny <int>());

            //Assert
            result
            .Should()
            .BeOfType <ViewResult>()
            .Subject
            .Model
            .Should()
            .Match(m => m.As <DoneHomeReviewsViewModel>().Reviews.Equals(expectedReviews));
        }