Esempio n. 1
0
        public void ReturnsCorrectlyWhenJobIdIsInvalid()
        {
            Mock <IApplyForJobService> mockedService =
                new Mock <IApplyForJobService>();
            ApplyForJobBindModel applyForJobBindModel = new ApplyForJobBindModel()
            {
                Id = 0,
                JobApplicationMessage = "asdfasdfasdf"
            };

            mockedService.Setup(a => a.JobExists(applyForJobBindModel.Id)).Returns(false);
            mockedService.Setup(a => a.IsWorker()).Returns(true);
            ApplyForJobController applyForJobController =
                new ApplyForJobController(mockedService.Object);
            IActionResult result = applyForJobController.Apply(applyForJobBindModel);

            Assert.That(result is RedirectResult);
        }
Esempio n. 2
0
        public void ReturnsCorrectlyWhenApplicationMessageIsInvalid()
        {
            Mock <IApplyForJobService> mockedService =
                new Mock <IApplyForJobService>();
            ApplyForJobBindModel applyForJobBindModel = new ApplyForJobBindModel()
            {
                Id = 4,
                JobApplicationMessage = ""
            };

            mockedService.Setup(a => a.JobExists(applyForJobBindModel.Id)).Returns(true);
            mockedService.Setup(a => a.IsWorker()).Returns(true);
            mockedService.Setup(a => a.AlreadyAppliedForJob(applyForJobBindModel.Id)).Returns(false);
            ApplyForJobController applyForJobController =
                new ApplyForJobController(mockedService.Object);
            ViewResult result = (ViewResult)applyForJobController.Apply(applyForJobBindModel);

            Assert.That(result.ViewData["error"].ToString() == "Job Application must be at least 5 symbols!");
        }
Esempio n. 3
0
        public void ReturnsCorrectlyWhenWorkerHasAlreadySignedUpForJob()
        {
            Mock <IApplyForJobService> mockedService =
                new Mock <IApplyForJobService>();
            ApplyForJobBindModel applyForJobBindModel = new ApplyForJobBindModel()
            {
                Id = 4,
                JobApplicationMessage = "asdfasdfasdf"
            };

            mockedService.Setup(a => a.JobExists(applyForJobBindModel.Id)).Returns(true);
            mockedService.Setup(a => a.IsWorker()).Returns(true);
            mockedService.Setup(a => a.AlreadyAppliedForJob(applyForJobBindModel.Id)).Returns(true);
            ApplyForJobController applyForJobController =
                new ApplyForJobController(mockedService.Object);
            ViewResult result = (ViewResult)applyForJobController.Apply(applyForJobBindModel);

            Assert.That(result.ViewData["error"].ToString() == "You have already applied for this job!");
        }
Esempio n. 4
0
        public void ReturnsCorrectlyWhenJobIsValidTriesToSignUpForJobButNotAWorker()
        {
            Mock <IApplyForJobService> mockedService =
                new Mock <IApplyForJobService>();
            ApplyForJobBindModel applyForJobBindModel = new ApplyForJobBindModel()
            {
                Id = 4,
                JobApplicationMessage = "hello. Please accept my application"
            };

            mockedService.Setup(a => a.JobExists(applyForJobBindModel.Id)).Returns(true);
            mockedService.Setup(a => a.IsWorker()).Returns(false);

            ApplyForJobController applyForJobController =
                new ApplyForJobController(mockedService.Object);
            IActionResult result = applyForJobController.Apply(applyForJobBindModel);

            Assert.That(result is RedirectResult);
        }