示例#1
0
        public void DeleteEmployed_Successfult_Test()
        {
            var employedRepoMock = new Mock <IEmployedRepository>();

            employedRepoMock
            .Setup(e => e.SearchMatching(It.IsAny <Expression <Func <EmployedEntity, bool> > >()))
            .Returns(new List <EmployedEntity> {
                new EmployedEntity
                {
                    EmployedId = Guid.NewGuid()
                }
            });

            employedRepoMock
            .Setup(e => e.Delete(It.IsAny <EmployedEntity>()))
            .Returns(() =>
            {
                return(true);
            });

            var service = new ServiceCollection();

            service.AddTransient(_ => employedRepoMock.Object);
            service.ConfigurePeopleManagementService(new DbSettings());
            var provider    = service.BuildServiceProvider();
            var employedSvc = provider.GetRequiredService <IEmployedService>();

            var newEmployed = new EmployedRequestDto
            {
                EmployedId = Guid.Parse("31826538-6b06-4021-95c2-27fb184ac4fe")
            };

            var responseDelete = employedSvc.DeleteEmployed(newEmployed);

            Assert.NotEqual(default, responseDelete);
示例#2
0
 public bool DeleteEmployed(EmployedRequestDto request)
 {
     if (request.EmployedId == default)
     {
         throw new IdCannotNullOrEmptyException();
     }
     ValidateEmployedIdExist(request);
     return(_repoEmployed.Delete(_mapper.Map <EmployedEntity>(request)));
 }
示例#3
0
        private void ValidateEmployedIdExist(EmployedRequestDto request)
        {
            var employedIdExist = _repoEmployed
                                  .SearchMatching <EmployedEntity>(dt => dt.EmployedId == request.EmployedId).Any();

            if (!employedIdExist)
            {
                throw new DontExistIdException();
            }
        }
示例#4
0
        public void Throw_DontExistIdException_when_id_it_isnt()
        {
            var employedRepoMock = new Mock <IEmployedRepository>();

            employedRepoMock
            .Setup(x => x.SearchMatching(It.IsAny <Expression <Func <EmployedEntity, bool> > >()))
            .Returns(new List <EmployedEntity>());
            var service = new ServiceCollection();

            service.AddTransient(_ => employedRepoMock.Object);
            service.ConfigurePeopleManagementService(new DbSettings());
            var provider    = service.BuildServiceProvider();
            var employedSvc = provider.GetRequiredService <IEmployedService>();

            var newEmployed = new EmployedRequestDto
            {
                EmployedId = Guid.NewGuid(),
            };

            Assert.Throws <DontExistIdException>(() => employedSvc.DeleteEmployed(newEmployed));
        }
示例#5
0
 public EmployedResponseDto DeleteEmployed(EmployedRequestDto request) =>
 _employedFacade.DeleteEmployed(request);