public void Get_InvokeService_ReturnTemplate()
        {
            //Arrange
            Template template = new Template();

            template.Id          = new Guid("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4");
            template.Name        = "Test";
            template.Description = "Test Description";

            //Moq
            Mock <IFinderService <Template> > finderService = new Mock <IFinderService <Template> >();
            MapperConfiguration mapperconfig = new MapperConfiguration(_mapper =>
            {
                _mapper.CreateMap <Template, TemplateViewModel>();
            });

            IMapper mapper = mapperconfig.CreateMapper();

            finderService.Setup((_finderService) => _finderService.Get(template.Id)).Returns(template);

            //SUT
            var SUT    = new ClassFinderViewModelService(mapper, finderService.Object);
            var result = SUT.Get(template.Id);

            //Assert
            Assert.NotNull(result);
        }
        public void GetAll_InvokeService_ReturnsListTemplate()
        {
            //Arrange
            List <Template> lstTemplate = new List <Template>()
            {
                new Template()
                {
                    Id           = new Guid("4EC575AB-1649-4F0F-43BF-08D78D888A4C"),
                    Name         = "prueba",
                    Description  = "prueba",
                    AddedDate    = DateTime.UtcNow,
                    ModifiedDate = DateTime.UtcNow,
                    IsActive     = true
                }
            };

            //Mock
            Mock <IFinderService <Template> > finderService = new Mock <IFinderService <Template> >();
            MapperConfiguration mapperconfig = new MapperConfiguration(_mapper =>
            {
                _mapper.CreateMap <Template, TemplateViewModel>();
            });

            IMapper mapper = mapperconfig.CreateMapper();

            finderService.Setup((_finderService) => _finderService.GetAll()).Returns(lstTemplate);

            //SUT
            var SUT = new ClassFinderViewModelService(mapper, finderService.Object);

            //Assert
            Assert.True(SUT.GetAll().Any());
        }
        public void GetByName_InvokeServiceNotExistsName_ReturnsGettingException()
        {
            //Mock
            Mock <IFinderService <Template> > finderService = new Mock <IFinderService <Template> >();
            MapperConfiguration mapperconfig = new MapperConfiguration(_mapper =>
            {
                _mapper.CreateMap <Template, TemplateViewModel>();
            });

            IMapper mapper = mapperconfig.CreateMapper();

            finderService.Setup((_finderService) => _finderService.GetByName("Prueba_1")).Throws(new GettingException("Registro no encontrado."));

            //SUT
            var SUT = new ClassFinderViewModelService(mapper, finderService.Object);

            //Assert
            Assert.Throws <GettingException>(() => SUT.GetByName("Prueba_1"));
        }
        public void GetByName_InvokeServiceExistsName_ReturnsListTemplate()
        {
            //Arrange
            List <Template> lstTemplate = new List <Template>()
            {
                new Template {
                    Id           = new Guid("00000000-0000-0000-0000-000000000000"),
                    Name         = "Prueba",
                    Description  = "Prueba",
                    AddedDate    = DateTime.Now,
                    ModifiedDate = DateTime.Now,
                    IsActive     = true
                },
                new Template {
                    Id           = new Guid("00000000-0000-0000-0000-000000000000"),
                    Name         = "Prueba",
                    Description  = "Prueba",
                    AddedDate    = DateTime.Now,
                    ModifiedDate = DateTime.Now,
                    IsActive     = true
                }
            };

            //Mock
            Mock <IFinderService <Template> > finderService = new Mock <IFinderService <Template> >();
            MapperConfiguration mapperconfig = new MapperConfiguration(_mapper =>
            {
                _mapper.CreateMap <Template, TemplateViewModel>();
            });

            IMapper mapper = mapperconfig.CreateMapper();

            finderService.Setup((_finderService) => _finderService.GetByName("Prueba")).Returns(lstTemplate);

            //SUT
            var SUT = new ClassFinderViewModelService(mapper, finderService.Object);

            //Assert
            Assert.NotEmpty(SUT.GetByName("Prueba"));
        }
        public void Get_ConvertEntity_ConvertSuccessful()
        {
            //Arrange
            Template template = new Template();

            template.Id = new Guid("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4");
            TemplateViewModel templateViewModel = new TemplateViewModel();

            //Mock
            Mock <IFinderService <Template> > finderService = new Mock <IFinderService <Template> >();
            Mock <IMapper> mapper = new Mock <IMapper>();

            finderService.Setup((service) => service.Get(template.Id)).Returns(template);
            mapper.Setup((map) => map.Map <TemplateViewModel>(template)).Returns(templateViewModel);

            //Act
            var SUT    = new ClassFinderViewModelService(mapper.Object, finderService.Object);
            var result = SUT.Get(template.Id);

            //Assert
            Assert.IsType <TemplateViewModel>(result);
        }
        public void GetAll_InvokeService_ReturnsListTemplateEmpty()
        {
            //Arrange
            List <Template> lstTemplate = new List <Template>();

            //Mock
            Mock <IFinderService <Template> > finderService = new Mock <IFinderService <Template> >();
            MapperConfiguration mapperconfig = new MapperConfiguration(_mapper =>
            {
                _mapper.CreateMap <Template, TemplateViewModel>();
            });

            IMapper mapper = mapperconfig.CreateMapper();

            finderService.Setup((_finderService) => _finderService.GetAll()).Returns(lstTemplate);

            //SUT
            var SUT = new ClassFinderViewModelService(mapper, finderService.Object);

            //Assert
            Assert.True(!SUT.GetAll().Any());
        }
        public void Get_InvokeService_ReturnTemplateEmpty()
        {
            //Arrange
            var id = new Guid("00000000-0000-0000-0000-000000000000");

            //Mock
            Mock <IFinderService <Template> > finderService = new Mock <IFinderService <Template> >();
            MapperConfiguration mapperconfig = new MapperConfiguration(_mapper =>
            {
                _mapper.CreateMap <Template, TemplateViewModel>();
            });
            IMapper mapper = mapperconfig.CreateMapper();

            finderService.Setup((_finderService) => _finderService.Get(id));

            //SUT
            var SUT = new ClassFinderViewModelService(mapper, finderService.Object);

            //Act
            var templateFound = SUT.Get(id);

            //Assert
            Assert.Null(templateFound);
        }