Exemplo n.º 1
0
        public void ReturnJsonResult_WhenProjectsCollectionIsEmpty()
        {
            // Arrange
            var regularUserServiceMock = new Mock <IRegularUserService>();
            var projectServiceMock     = new Mock <IProjectService>();
            var projectsController     = new WebClient.Controllers.ProjectsController(projectServiceMock.Object, regularUserServiceMock.Object);
            var projectMock            = new Mock <Project>();

            //Act & Assert
            projectsController
            .WithCallTo(c => c.LoadPage(3))
            .ShouldReturnJson();

            projectServiceMock.Verify(m => m.Get(3, Constants.InitialEntitiesPerPage), Times.Once);
        }
Exemplo n.º 2
0
        public void ReturnDefaultViewAndCallProjectService()
        {
            // Arrange
            var regularUserServiceMock = new Mock <IRegularUserService>();
            var projectServiceMock     = new Mock <IProjectService>();
            var projectsController     = new WebClient.Controllers.ProjectsController(projectServiceMock.Object, regularUserServiceMock.Object);

            //Act & Assert
            projectsController
            .WithCallTo(c => c.Index())
            .ShouldRenderDefaultView()
            .WithModel <IEnumerable <ProjectShortViewModel> >();

            projectServiceMock.Verify(m => m.Get(0, Constants.InitialEntitiesPerPage), Times.Once);
        }
Exemplo n.º 3
0
        public void ReturnHttpNotFound_WhenUserFromRepoIsNull()
        {
            // Arrange
            var     regularUserServiceMock = new Mock <IRegularUserService>();
            var     projectServiceMock     = new Mock <IProjectService>();
            var     projectsController     = new WebClient.Controllers.ProjectsController(projectServiceMock.Object, regularUserServiceMock.Object);
            Project projectFromService     = null;
            var     projectId = Guid.NewGuid();

            projectServiceMock.Setup(m => m.GetById(projectId)).Returns(projectFromService);

            //Act & Assert
            projectsController
            .WithCallTo(c => c.Details(projectId))
            .ShouldGiveHttpStatus(404);
        }