Exemplo n.º 1
0
        public void IndexShould_CallFactoryMethodCreateAllInformationViewModel()
        {
            var placeServiceMock    = new Mock <IPlaceService>();
            var userServiceMock     = new Mock <IUserService>();
            var reviewsServiceMock  = new Mock <IReviewsService>();
            var questionServiceMock = new Mock <IQuestionService>();
            var authProviderMock    = new Mock <IAuthenticationProvider>();
            var factoryMock         = new Mock <IViewModelFactory>();

            var controller = new Areas.Administration.Controllers.AdministrationController(placeServiceMock.Object,
                                                                                           reviewsServiceMock.Object, authProviderMock.Object, userServiceMock.Object,
                                                                                           questionServiceMock.Object, factoryMock.Object);

            var places = new List <Place>();

            placeServiceMock.Setup(s => s.GetAll()).Returns(places.AsQueryable());
            var users = new List <User>();

            userServiceMock.Setup(s => s.GetAll()).Returns(users.AsQueryable());
            var reviews = new List <Review>();

            reviewsServiceMock.Setup(s => s.GetAll()).Returns(reviews.AsQueryable());

            var placesModel    = new List <PlaceViewModel>();
            var usersModel     = new List <UserViewModel>();
            var reviewsModel   = new List <ReviewViewModel>();
            var questionsModel = new List <QuestionViewModel>();

            controller.Index();
            factoryMock.Verify(s => s.CreateAllInformationViewModel(usersModel, reviewsModel, placesModel, questionsModel), Times.Once);
        }
Exemplo n.º 2
0
        public void IndexShould_CallUserServiceMethodGetAll()
        {
            var placeServiceMock    = new Mock <IPlaceService>();
            var userServiceMock     = new Mock <IUserService>();
            var reviewsServiceMock  = new Mock <IReviewsService>();
            var questionServiceMock = new Mock <IQuestionService>();
            var authProviderMock    = new Mock <IAuthenticationProvider>();
            var factoryMock         = new Mock <IViewModelFactory>();

            var controller = new Areas.Administration.Controllers.AdministrationController(placeServiceMock.Object,
                                                                                           reviewsServiceMock.Object, authProviderMock.Object, userServiceMock.Object,
                                                                                           questionServiceMock.Object, factoryMock.Object);

            controller.Index();
            userServiceMock.Verify(s => s.GetAll(), Times.Once);
        }