public async Task GetJobs_Returns_Correct_Filtered_Jobs()
        {
            // Arrange
            var jobType1 = Guid.NewGuid();

            _mockService.Setup(x => x.GetJobs(It.IsAny <string>(), It.IsAny <bool>(), null)).ReturnsAsync(
                new List <Job> {
                new Job {
                    Id = new Guid(), Title = "Test title", JobType = new JobType {
                        Id = jobType1, Description = "JobType"
                    }, IsDraft = false, MinSalary = 1234M, MaxSalary = 4321M, Description = "Test", IsActive = true, JobTitle = "JobTitle", ClosingDate = DateTime.Now.AddDays(7), CreatedDate = DateTime.Now.AddDays(-1), HolidayEntitlement = 21, HoursPerWeek = 40
                },
            });
            _mockJobTypesService.Setup(x => x.GetJobTypes()).ReturnsAsync(new List <JobType> {
                new JobType {
                    Description = "JobType", Id = jobType1, IsActive = true
                }
            });

            // Act
            var controller = new JobsController(mapper, _mockLogger.Object, _mockService.Object, _mockJobTypesService.Object, _mockJobBenefitsService.Object);

            // Assert
            var result = await controller.Index("title", false, jobType1) as ViewResult;

            Assert.IsNotNull(result);
        }
Ejemplo n.º 2
0
        public void IndexViewResultNotNull()
        {
            ILogger <JobsController> logger = Mock.Of <ILogger <JobsController> >();

            JobsController controller = new JobsController(context, logger);

            // Act
            ViewResult result = controller.Index() as ViewResult;

            // Assert
            Assert.NotNull(result);
        }
Ejemplo n.º 3
0
        public void IndexViewData()
        {
            ILogger <JobsController> logger = Mock.Of <ILogger <JobsController> >();

            JobsController controller = new JobsController(context, logger);

            // Act
            ViewResult result = controller.Index() as ViewResult;

            // Assert
            Assert.NotNull(result.ViewData["Jobs"]);
            Assert.NotNull(result.ViewData["RoomTypes"]);
        }
        public async Task UserCanGetJobsWithPaging()
        {
            var queryableJobs = Enumerable.Range(1, 10).Select(x => new Job
            {
                JobId       = x,
                Title       = $"Job {x}",
                Description = $"This is job {x}"
            }).AsQueryable();

            var mock = new Mock <IJobRepository>();

            mock.Setup(x => x.All).Returns(queryableJobs);

            var controller = new JobsController(mock.Object, _mapper);

            var actionResult = await controller.Index(2);

            var res = actionResult.Value;

            Assert.NotNull(res);
            Assert.AreEqual(10, res.TotalItemCount);
            Assert.AreEqual(2, res.PageCount);
            Assert.AreEqual(2, res.PageNumber);
        }