Example #1
0
        public async void EmployeeServiceShouldThrowNotFoundException()
        {
            var updatedEmployeeService = new UpdateEmployeeServiceCommand {
                EmployeeId = GConst.InvalidId, ServiceId = GConst.InvalidId, Price = GConst.ValidPrice
            };

            var status = await Record.ExceptionAsync(async() => await sut.Handle(updatedEmployeeService, CancellationToken.None));

            Assert.NotNull(status);
            Assert.Equal(string.Format(GConst.NotFoundExceptionMessage, GConst.EmployeeService, $"{GConst.InvalidId} - {GConst.InvalidId}"), status.Message);
        }
Example #2
0
        public async void EmployeeServiceShouldUpdateCorrect()
        {
            CommandArrangeHelper.AddEmployeeService(context, serviceId, employeeId);

            var updatedEmployeeService = new UpdateEmployeeServiceCommand {
                EmployeeId = employeeId, ServiceId = serviceId, Price = GConst.ValidPrice
            };

            var status = Task <Unit> .FromResult(await sut.Handle(updatedEmployeeService, CancellationToken.None));

            var employeeIdResult = context.EmployeeServices.SingleOrDefault(x => x.Price == GConst.ValidPrice).EmployeeId;
            var serviceIdResult  = context.EmployeeServices.SingleOrDefault(x => x.Price == GConst.ValidPrice).ServiceId;

            Assert.Equal(employeeId, employeeIdResult);
            Assert.Equal(serviceId, serviceIdResult);
            Assert.Equal(GConst.SuccessStatus, status.Status.ToString());
            Assert.Equal(GConst.ValidCount, context.EmployeeServices.Count());
        }
 public UpdateEmployeeServiceCommandValidatorTests()
 {
     this.updateValidator = new UpdateEmployeeServiceCommandValidator();
     this.updateCommand   = new UpdateEmployeeServiceCommand();
 }
        public async Task <ActionResult> Update([FromForm] UpdateEmployeeServiceCommand command)
        {
            await Mediator.Send(command);

            return(NoContent());
        }