Ejemplo n.º 1
0
 public IEnumerable <GenderSelect> GetSelect()
 {
     using (GenderService genderService = new GenderService(new DataContext()))
     {
         return(genderService.GetSelect());
     }
 }
Ejemplo n.º 2
0
 // GET: api/Genders/5
 public Gender Get(int id)
 {
     using (GenderService genderService = new GenderService(new DataContext()))
     {
         return(genderService.Get(id));
     }
 }
Ejemplo n.º 3
0
 public HomeController()
 {
     _empService           = new EmployeeService();
     _countryService       = new CountryService();
     _stateService         = new StateService();
     _genderService        = new GenderService();
     _MaritalStatusService = new MaritalStatusService();
     _DepartmentService    = new DepartmentService();
 }
Ejemplo n.º 4
0
        private void LoadComboBoxGender()
        {
            GenderService = new GenderService();
            var genders = GenderService.All();

            foreach (var Gender in genders)
            {
                CBGenero.Items.Add(Gender.Name);
            }
        }
Ejemplo n.º 5
0
        public void ShouldBeInvalidName()
        {
            PetFinderContext context       = dbContextFactory.CreateContext();
            GenderService    genderService = new GenderService(context);

            string invalidName = "asdasdasdasdasdasdasd";
            bool   isValid     = genderService.IsValidName(invalidName);

            // Deberia ser falso ya que la cadena tiene 21 caracteres, siendo el maximo 20
            Assert.False(isValid);
        }
Ejemplo n.º 6
0
        public async void ShouldBeNotRepeated()
        {
            PetFinderContext context       = dbContextFactory.CreateContext();
            GenderService    genderService = new GenderService(context);

            string notRepeatedName = "Masculino";
            bool   isValid         = await genderService.IsRepeated(notRepeatedName);

            // Deberia ser falso ya que la cadena tiene 21 caracteres, siendo el maximo 20
            Assert.False(isValid);
        }
Ejemplo n.º 7
0
        public async Task ShouldInsertAsync()
        {
            PetFinderContext context       = dbContextFactory.CreateContext();
            Gender           gender        = CreateGender("Masculino");
            GenderService    genderService = new GenderService(context);

            await genderService.Save(gender);

            // Deberia insertarse
            Assert.Equal <Gender>(gender, context.Genders.Find(gender.Id));
        }
Ejemplo n.º 8
0
        public async Task ShouldNotInsertAsync()
        {
            PetFinderContext context       = dbContextFactory.CreateContext();
            Gender           gender        = new Gender();
            GenderService    genderService = new GenderService(context);

            // No deberia insertarse ya que no tiene nombre
            await Assert.ThrowsAsync <DbUpdateException>(async() =>
            {
                await genderService.Save(gender);
            });
        }
Ejemplo n.º 9
0
        // PUT: api/Genders/5
        public HttpResponseMessage Put(int id, Gender body)
        {
            using (GenderService genderService = new GenderService(new DataContext()))
            {
                if (!ModelState.IsValid)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                }

                genderService.Update(id, body);
                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
        }
Ejemplo n.º 10
0
        public async Task GetAllTest()
        {
            _repoWrapper.Setup(r => r.Gender.GetAllAsync(null, null)).ReturnsAsync(new List <Gender>().AsQueryable());

            var service = new GenderService(_repoWrapper.Object, _mapper.Object);

            _mapper.Setup(x => x.Map <Gender, GenderDTO>(It.IsAny <Gender>())).Returns(new GenderDTO());
            // Act
            var result = await service.GetAllAsync();

            // Assert
            Assert.NotNull(result);
            Assert.IsAssignableFrom <IEnumerable <GenderDTO> >(result);
        }
Ejemplo n.º 11
0
        public static IEnumerable <SelectListItem> FillddlGender()
        {
            var service   = new GenderService();
            var genders   = service.GetAll();
            var listitems = genders.Select(x =>

                                           new SelectListItem
            {
                Text  = x.GenderName,
                Value = x.Id.ToString()
            });

            return(listitems);
        }
Ejemplo n.º 12
0
        public void GetAll_Test()
        {
            // Arrange
            TestKolgraphEntities context = new TestKolgraphEntities();
            var repository = new GenderRepository(context);
            var service    = new GenderService(repository);

            // Act
            IEnumerable <GenderModel> result = service.GetAll();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(context.gender.Count(), result.Count());
        }
Ejemplo n.º 13
0
        public void GetById_Test()
        {
            // Arrange
            TestKolgraphEntities context = new TestKolgraphEntities();
            var repository = new GenderRepository(context);
            var service    = new GenderService(repository);

            // Act
            GenderModel result = service.GetById(4);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(4, result.Id);
        }
Ejemplo n.º 14
0
        public void ConvertModelToEntity_Test()
        {
            // Arrange
            TestKolgraphEntities context = new TestKolgraphEntities();
            var         service          = new GenderService();
            GenderModel model            = GetTestModel();

            // Act
            gender entity = service.ConvertModelToEntity(model);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(entity.name, model.Name);
        }
Ejemplo n.º 15
0
        public async Task ShouldDelete()
        {
            PetFinderContext context       = dbContextFactory.CreateContext();
            Gender           gender        = CreateGender("Masculino");
            GenderService    genderService = new GenderService(context);

            await genderService.Save(gender);

            await genderService.Delete(gender.Id);

            int numberOfGenders = await context.Genders.CountAsync();

            // Deberia haber 2 generos que son los que vienen por defecto
            Assert.Equal <int>(2, numberOfGenders);
        }
Ejemplo n.º 16
0
        public async Task ShouldNotSaveWithSameName()
        {
            PetFinderContext context       = dbContextFactory.CreateContext();
            Gender           gender1       = CreateGender("Masculino");
            Gender           gender2       = CreateGender("Masculino");
            GenderService    genderService = new GenderService(context);

            await genderService.Save(gender1);

            // No deberia insertarse ya que existe un genero con el mismo nombre
            await Assert.ThrowsAsync <GenderAlreadyExistsException>(async() =>
            {
                await genderService.Save(gender2);
            });
        }
Ejemplo n.º 17
0
        public void ConvertEntityToModel_Test()
        {
            // Arrange
            TestKolgraphEntities context = new TestKolgraphEntities();
            //var repository = new GenderRepository(context);
            var    service = new GenderService();
            gender entity  = context.gender.Where(x => x.id == 4).FirstOrDefault();

            // Act
            GenderModel model = service.ConvertEntityToModel(entity);

            // Assert
            Assert.IsNotNull(model);
            Assert.AreEqual(model.Id, entity.id);
            Assert.AreEqual(model.Name, entity.name);
        }
Ejemplo n.º 18
0
        public IActionResult GetAll(string intervalo, int pg)
        {
            var service = new GenderService();

            try
            {
                var retorno = new RetornoPesquisa {
                    total = service.BuscarCount(intervalo),
                    itens = service.BuscarAll(intervalo, pg)
                };
                return(new ObjectResult(retorno));
            }
            catch (Exception) {
                return(NotFound());
            }
        }
Ejemplo n.º 19
0
        public async Task ShouldUpdateAsync()
        {
            PetFinderContext context       = dbContextFactory.CreateContext();
            Gender           gender        = CreateGender("Masculino");
            GenderService    genderService = new GenderService(context);

            await genderService.Save(gender);

            gender.Name = "Femenino";
            await genderService.Save(gender);

            int numberOfGenders = await context.Genders.CountAsync();

            // Deberia haber tres generos ya que dos vienen por defecto e insertamos uno solo
            Assert.Equal <int>(3, numberOfGenders);
        }
Ejemplo n.º 20
0
        public async Task TestGetAll()
        {
            // Arrange
            var consultants = GenerateGenders();

            var mockUnitOfWork = new Mock <IUnitOfWork>();

            mockUnitOfWork
            .Setup(x => x.GenderRepository.GetAllAsync(It.IsAny <bool>()))
            .ReturnsAsync(consultants);

            var service = new GenderService(_mapper, mockUnitOfWork.Object);

            // Act
            var result = await service.GetAllAsync();

            // Assert
            Assert.NotNull(result);
            Assert.Equal(2, result.Count());
            Assert.IsAssignableFrom <IEnumerable <GenderDTO> >(result);
        }
Ejemplo n.º 21
0
        public async Task TestGetAllNoResults()
        {
            // Arrange
            var timeSlots = new List <Gender>();

            var mockUnitOfWork = new Mock <IUnitOfWork>();

            mockUnitOfWork
            .Setup(x => x.GenderRepository.GetAllAsync(It.IsAny <bool>()))
            .ReturnsAsync(timeSlots);

            var service = new GenderService(_mapper, mockUnitOfWork.Object);

            // Act
            var result = await service.GetAllAsync();

            // Assert
            Assert.NotNull(result);
            Assert.Empty(result);
            Assert.IsAssignableFrom <IEnumerable <GenderDTO> >(result);
        }
Ejemplo n.º 22
0
        public static IEnumerable<SelectListItem> FillddlGender()
        {
            var service = new GenderService();
            var genders = service.GetAll();
            var listitems = genders.Select(x =>

                new SelectListItem
                {
                    Text = x.GenderName,
                    Value = x.Id.ToString()
                });
            return listitems;
        }
Ejemplo n.º 23
0
 public Gender GetGenderSelectByName()
 {
     GenderService = new GenderService();
     return(GenderService.GetSingleByName(CBGenero.SelectedItem.ToString()));
 }
Ejemplo n.º 24
0
 public GenderController()
 {
     service = new GenderService();
 }
Ejemplo n.º 25
0
 public GendersController()
 {
     Service = new GenderService();
 }
Ejemplo n.º 26
0
 public void TestInit()
 {
     context = new TestEcaContext();
     service = new GenderService(context);
 }
Ejemplo n.º 27
0
 public GenderManager()
 {
     _genderService = new GenderService();
 }
Ejemplo n.º 28
0
 public GendersController()
 {
     Service = new GenderService();
 }