Пример #1
0
        public async Task GetEmployeeByIdTest()
        {
            var status = await sut.Handle(new GetEmployeeByIdQuery { Id = GConst.ValidId }, CancellationToken.None);

            status.ShouldBeOfType <EmployeeViewModel>();
            status.Id.ShouldBe(GConst.ValidId);
        }
        public async Task NotFoundEmployeeIdTest()
        {
            var handler   = new GetEmployeeByIdQueryHandler(_mapper, _mockEmployeeRepository.Object);
            var exception = await Assert.ThrowsAsync <NotFoundException>(() => handler.Handle(new GetEmployeeByIdQuery(30), CancellationToken.None));

            exception.Message.ShouldBe("Employee (30) is not found");
        }
        public async Task GetValidEmployeeIdTest()
        {
            var handler = new GetEmployeeByIdQueryHandler(_mapper, _mockEmployeeRepository.Object);
            var result  = await handler.Handle(new GetEmployeeByIdQuery(3), CancellationToken.None);

            result.ShouldBeOfType <EmployeeRest>();
            result.Id.ShouldBe(3);
        }