예제 #1
0
        public void ReturnsCorrectlyWhenJobPaymentIsZero()
        {
            Mock <IUserAndContextRepository> mockedService =
                new Mock <IUserAndContextRepository>();
            CreateJobBindModel createJobBindModel = new CreateJobBindModel()
            {
                Description = "asdfasdf",
                JobName     = "hello",
                Payment     = 0
            };

            mockedService.Setup(a => a.IsWorker()).Returns(false);
            CreateJobController createJobController =
                new CreateJobController(mockedService.Object);
            ViewResult result = (ViewResult)createJobController.Index(createJobBindModel);

            Assert.That(result.ViewData["Error"].ToString() == "Invalid payment!");
        }
예제 #2
0
        public void ReturnsCorrectlyWhenViewerIsAWorker()
        {
            Mock <IUserAndContextRepository> mockedService =
                new Mock <IUserAndContextRepository>();
            CreateJobBindModel createJobBindModel = new CreateJobBindModel()
            {
                Description = "asdfasdf",
                JobName     = "hello",
                Payment     = 123
            };

            mockedService.Setup(a => a.IsWorker()).Returns(true);
            CreateJobController createJobController =
                new CreateJobController(mockedService.Object);
            IActionResult result = createJobController.Index(createJobBindModel);

            Assert.That(result is RedirectResult);
        }