public void GetByName_InvokeRepositoryExistsName_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 <IFinderRepository <Template> > finderRepository = new Mock <IFinderRepository <Template> >();

            finderRepository.Setup((service) => service.GetByName("Prueba")).Returns(lstTemplate);

            //SUT
            var SUT = new ClassFinderService(finderRepository.Object);

            //Assert
            Assert.NotEmpty(SUT.GetByName("Prueba"));
        }
        public void GetAll_InvokeRepository_ReturnsListEntityEmpty()
        {
            //Arrange
            List <Template> lstTemplate = new List <Template>();

            //Mock
            Mock <IFinderRepository <Template> > finderRepository = new Mock <IFinderRepository <Template> >();

            finderRepository.Setup((viewModelService) => viewModelService.GetAll()).Returns(lstTemplate);

            //SUT
            var SUT = new ClassFinderService(finderRepository.Object);

            //Assert
            Assert.True(!SUT.GetAll().Any());
        }
        public void Get_InvokeRepository_ReturnNotFound()
        {
            //Arrange
            var id = new Guid("05D5FD46-263E-E211-BFBA-1040F3A7A3B1");

            //Mock
            Mock <IFinderRepository <Template> > finderRepository = new Mock <IFinderRepository <Template> >();

            finderRepository.Setup((repository) => repository.Get(id)).Throws(new GettingException("Record not found."));

            //SUT
            var SUT = new ClassFinderService(finderRepository.Object);

            //Act
            GettingException ex = Assert.Throws <GettingException>(() => SUT.Get(id));

            //Assert
            Assert.Equal("Record not found.", ex.Message);
        }
        public void Get_InvokeRepository_ReturnsEntity()
        {
            //Arrange
            Template template = new Template()
            {
                Id          = new Guid("9245fe4a-d402-451c-b9ed-9c1a04247482"),
                Name        = "test",
                Description = "test"
            };

            //Mock
            Mock <IFinderRepository <Template> > finderRepository = new Mock <IFinderRepository <Template> >();

            finderRepository.Setup((service) => service.Get(template.Id)).Returns(template);

            //SUT
            var SUT = new ClassFinderService(finderRepository.Object);

            //Assert
            Assert.NotNull(SUT.Get(template.Id));
        }
        public void GetAll_InvokeRepository_ReturnsListEntity()
        {
            //Arrange
            Template        template    = new Template();
            List <Template> lstTemplate = new List <Template>();

            template.Id          = new Guid("4EC575AB-1649-4F0F-43BF-08D78D888A4C");
            template.Name        = "prueba";
            template.Description = "prueba";
            lstTemplate.Add(template);

            //Mock
            Mock <IFinderRepository <Template> > finderRepository = new Mock <IFinderRepository <Template> >();

            finderRepository.Setup((viewModelService) => viewModelService.GetAll()).Returns(lstTemplate);

            //SUT
            var SUT = new ClassFinderService(finderRepository.Object);

            //Assert
            Assert.True(SUT.GetAll().Any());
        }