Esempio n. 1
0
        public async Task Handler_ThrowsNotFoundException_JobDoesNotExist()
        {
            var query = new GetJobDetailQuery {
                Id = 1
            };
            var handler = new GetJobDetailQueryHandler(mockRepo.Object);

            await Assert.ThrowsAsync <NotFoundException>(() => handler.Handle(query, CancellationToken.None));
        }
Esempio n. 2
0
        public async Task Handler_ReturnsNullCoordinator_WhenCoordinatorIsNull()
        {
            var expectedJob = new Job();
            var query       = new GetJobDetailQuery {
                Id = 1
            };

            mockRepo.Setup(x => x.GetJobDetail(query.Id)).ReturnsAsync(expectedJob);
            var handler = new GetJobDetailQueryHandler(mockRepo.Object);

            var vm = await handler.Handle(query, CancellationToken.None);

            mockRepo.Verify(x => x.GetJobDetail(query.Id), Times.Once());
            Assert.Null(vm.Coordinator);
        }
Esempio n. 3
0
        public async Task Handler_ReturnsCorrectViewModel()
        {
            var expectedJob = GetJob();
            var query       = new GetJobDetailQuery {
                Id = 1
            };

            mockRepo.Setup(x => x.GetJobDetail(query.Id)).ReturnsAsync(expectedJob);
            var handler = new GetJobDetailQueryHandler(mockRepo.Object);

            var vm = await handler.Handle(query, CancellationToken.None);

            mockRepo.Verify(x => x.GetJobDetail(query.Id), Times.Once());
            Assert.Equal(expectedJob.Coordinator.Name, vm.Coordinator.Name);
            Assert.Equal(expectedJob.JobTasks.Count(), vm.JobTasks.Count());
        }