public async Task CreateUserService_ShouldAddUser_WhenUserIsValid() { var name = "mockName"; var password = "******"; var crm = "mockCrm"; var login = "******"; var dto = new DtoCreateDoctorInput { CompleteName = name, Password = password, ConfirmPassword = password, Crm = crm, Login = login }; var user = dto.ToUser(); _userRepositoryMock.Setup(x => x.GetAll()).ReturnsAsync(Enumerable.Empty <User>().AsQueryable()); _userRepositoryMock.Setup(x => x.Insert(user)).ReturnsAsync(new User()); var response = await _service.Execute(dto); Console.WriteLine(response); Assert.Equal(HttpStatusCode.Created, response.Status); }
public ActionResult <CreateUserService> Post(UserRequest request) { CreateUserService _service = new CreateUserService(_unitOfWork); CreateUserResponse response = _service.Execute(request); return(Ok(response)); }
public void CrearDocenteConIdRepetida() { var requestUser = new UserRequest { Name = "cjhair", Password = "******" }; CreateUserService _service = new CreateUserService(new UnitOfWork(_context)); var responseUser = _service.Execute(requestUser); User user = _service.Consult(requestUser.Name); var requestTeacher = new TeacherRequest { Name = "Cristian", Category = "Planta", DedicationTime = "12h", DocumentType = "CC", DocumentId = "1035", Email = "*****@*****.**", InvestigationGroup = "Gisco", Phone = "12345", User = user }; CreateTeacherService _teacherService = new CreateTeacherService(new UnitOfWork(_context)); var responseTeacher = _teacherService.Execute(requestTeacher); Assert.AreEqual("Ya existe un docente registrado con esa id", responseTeacher.Menssage); }
void CreeateUser_No_Service(User pUserBe) { String strErrorResut = String.Empty; CreateUserReq req = new CreateUserReq(); CreateUserRes res = new CreateUserRes(); CreateUserService svc = new CreateUserService(); req.SecurityProviderName = SecurityProviderName; try { RolList roles = FwkMembership.GetAllRoles(SecurityProviderName); if (roles.Count >= 2) { pUserBe.Roles = new String[2]; pUserBe.Roles[0] = roles[0].RolName; pUserBe.Roles[1] = roles[1].RolName; } req.BusinessData.User = pUserBe; res = svc.Execute(req); } catch (Exception ex) { strErrorResut = Fwk.Exceptions.ExceptionHelper.GetAllMessageException(ex); } Assert.AreEqual <String>(strErrorResut, string.Empty, strErrorResut); pUserBe.UserId = res.BusinessData.UserId; }
public void CrearUsuarioConNombreExistente() { var requestUser = new UserRequest { Name = "cjhair", Password = "******" }; CreateUserService _service = new CreateUserService(new UnitOfWork(_context)); var responseUser = _service.Execute(requestUser); Assert.AreEqual("Ya existe un usuario con ese nombre", responseUser.Menssage); }
Post([FromServices] CreateUserService _create, [FromBody] User data) { try { var createdUser = await _create.Execute(data); return(new UserView(createdUser)); } catch (Exception e) { return(BadRequest(e.Message)); } }
void CreeateUser_No_Service(User pUserBe) { String strErrorResut = String.Empty; CreateUserReq req = new CreateUserReq(); CreateUserRes res = new CreateUserRes(); CreateUserService svc = new CreateUserService(); req.SecurityProviderName = SecurityProviderName; try { RolList roles = FwkMembership.GetAllRoles(SecurityProviderName); if (roles.Count >= 2) { pUserBe.Roles = new String[2]; pUserBe.Roles[0] = roles[0].RolName; pUserBe.Roles[1] = roles[1].RolName; } req.BusinessData.User = pUserBe; res = svc.Execute(req); } catch (Exception ex) { strErrorResut = Fwk.Exceptions.ExceptionHelper.GetAllMessageException(ex); } Assert.AreEqual<String>(strErrorResut, string.Empty, strErrorResut); pUserBe.UserId = res.BusinessData.UserId; }