Beispiel #1
0
        public async void EmployeeShouldUpdateCorrect()
        {
            var updatedEmployee = new UpdateEmployeeCommand {
                Id = employeeId, FirstName = GConst.ValidName, LocationId = locationId
            };

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

            var resultId = context.Employees.SingleOrDefault(x => x.FirstName == GConst.ValidName).Id;

            Assert.Equal(employeeId, resultId);
            Assert.Equal(GConst.SuccessStatus, status.Status.ToString());
            Assert.Equal(GConst.ValidCount, context.Employees.Count());
        }
Beispiel #2
0
        public async Task HandleValidEmployeUpdatedToEmployeeRepo()
        {
            var handler = new UpdateEmployeeCommandHandler(_mapper, _mockEmployeeRepository.Object);

            var employee = new EmployeeRest
            {
                Id         = 5,
                FirstName  = "FirstName11",
                MiddleName = "MiddleName11",
                LastName   = "LastName11"
            };
            await handler.Handle(new UpdateEmployeeCommand(employee), CancellationToken.None);

            var allEmployees = await _mockEmployeeRepository.Object.GetAllAsync();

            allEmployees.Count.ShouldBe(9);
            var updatedEmployee = await _mockEmployeeRepository.Object.GetByIdAsync(5);

            updatedEmployee.FirstName.ShouldBe("FirstName11");
            updatedEmployee.MiddleName.ShouldBe("MiddleName11");
            updatedEmployee.LastName.ShouldBe("LastName11");
        }