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

            //Mock
            Mock <IFinderViewModelService <Domain.Entities.Template, TemplateViewModel> > finderViewModelService = new Mock <IFinderViewModelService <Domain.Entities.Template, TemplateViewModel> >();

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

            //SUT
            var SUT           = new ClassFinderController(finderViewModelService.Object);
            var result        = SUT.GetAll() as ObjectResult;
            var viewResult    = Assert.IsType <List <TemplateViewModel> >(result.Value);
            var listViewModel = Assert.IsAssignableFrom <IEnumerable <TemplateViewModel> >(viewResult);

            //Assert
            Assert.True(listViewModel.Any());
        }
        public void GetByName_InvokeViewModelServiceExistsName_ReturnsListTemplate()
        {
            //Mock
            Mock <IFinderViewModelService <Domain.Entities.Template, TemplateViewModel> > finderViewModelService = new Mock <IFinderViewModelService <Domain.Entities.Template, TemplateViewModel> >();

            finderViewModelService.Setup((viewModelService) => viewModelService.GetByName("Prueba"));
            //SUT
            var SUT    = new ClassFinderController(finderViewModelService.Object);
            var result = SUT.GetByName("Prueba") as ObjectResult;

            //Assert
            Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
        }
        public void GetByName_InvokeViewModelServiceNotExistsName_ReturnsGettingException()
        {
            //Mock
            Mock <IFinderViewModelService <Domain.Entities.Template, TemplateViewModel> > finderViewModelService = new Mock <IFinderViewModelService <Domain.Entities.Template, TemplateViewModel> >();

            finderViewModelService.Setup((viewModelService) => viewModelService.GetByName("Prueba")).Throws(new GettingException("Records not found"));
            //SUT
            var SUT    = new ClassFinderController(finderViewModelService.Object);
            var result = SUT.GetByName("Prueba") as ObjectResult;

            //Assert
            Assert.Equal(StatusCodes.Status400BadRequest, result.StatusCode);
        }
        public void GetAll_InvokeViewModelService_Exception()
        {
            //Mock
            Mock <IFinderViewModelService <Domain.Entities.Template, TemplateViewModel> > finderViewModelService = new Mock <IFinderViewModelService <Domain.Entities.Template, TemplateViewModel> >();

            finderViewModelService.Setup((_finderService) => _finderService.GetAll()).Throws(new GettingException("Records no found."));

            //SUT
            var SUT = new ClassFinderController(finderViewModelService.Object);

            //Assert
            Assert.IsType <BadRequestObjectResult>(SUT.GetAll());
        }
        public void Get_InvokeViewModelService_BadRequest()
        {
            //Arrange
            var id = new Guid("05D5FD46-263E-E211-BFBA-1040F3A7A3B1");
            //Mock
            Mock <IFinderViewModelService <Domain.Entities.Template, TemplateViewModel> > finderViewModelService = new Mock <IFinderViewModelService <Domain.Entities.Template, TemplateViewModel> >();

            finderViewModelService.Setup((viewModelService) => viewModelService.Get(id)).Throws(new GettingException("Records not found"));
            //SUT
            var SUT    = new ClassFinderController(finderViewModelService.Object);
            var result = SUT.Get(id) as ObjectResult;

            //Assert
            Assert.Equal(StatusCodes.Status400BadRequest, result.StatusCode);
        }
        public void Get_InvokeViewModelService_InvokeSuccessful()
        {
            //Arrange
            TemplateViewModel templateViewModel = new TemplateViewModel();

            templateViewModel.Id = new Guid("05D5FD46-263E-E211-BFBA-1040F3A7A3B1");
            //Moq
            Mock <IFinderViewModelService <Domain.Entities.Template, TemplateViewModel> > finderViewModelService = new Mock <IFinderViewModelService <Domain.Entities.Template, TemplateViewModel> >();

            finderViewModelService.Setup((viewModelService) => viewModelService.Get(templateViewModel.Id));
            //SUT
            var SUT = new ClassFinderController(finderViewModelService.Object);

            SUT.Get(templateViewModel.Id);
            //Assert
            finderViewModelService.Verify((v) => v.Get(templateViewModel.Id), Times.Once);
        }
        public void Get_InvokeViewModelService_Status200()
        {
            //Arrange
            TemplateViewModel templateViewModel = new TemplateViewModel();

            templateViewModel.Id = new Guid("05D5FD46-263E-E211-BFBA-1040F3A7A3B1");
            //Mock
            Mock <IFinderViewModelService <Domain.Entities.Template, TemplateViewModel> > finderViewModelService = new Mock <IFinderViewModelService <Domain.Entities.Template, TemplateViewModel> >();

            finderViewModelService.Setup((viewModelService) => viewModelService.Get(templateViewModel.Id));
            //SUT
            var SUT    = new ClassFinderController(finderViewModelService.Object);
            var result = SUT.Get(templateViewModel.Id) as ObjectResult;

            //Assert
            Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
        }
        public void GetAll_InvokeViewModelService_ReturnsListTemplateViewModelEmpty()
        {
            //Arrange
            List <TemplateViewModel> lstTemplate = new List <TemplateViewModel>();

            //Mock
            Mock <IFinderViewModelService <Domain.Entities.Template, TemplateViewModel> > finderViewModelService = new Mock <IFinderViewModelService <Domain.Entities.Template, TemplateViewModel> >();

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

            //SUT
            var SUT        = new ClassFinderController(finderViewModelService.Object);
            var result     = SUT.GetAll() as ObjectResult;
            var viewResult = Assert.IsType <List <TemplateViewModel> >(result.Value);
            var model      = Assert.IsAssignableFrom <IEnumerable <TemplateViewModel> >(viewResult);

            //Assert
            Assert.True(!model.Any());
        }
        public void Get_InvokeViewModelService_ReturnTemplateViewModel()
        {
            //Arrange
            TemplateViewModel templateViewModel = new TemplateViewModel();

            templateViewModel.Id = new Guid("05D5FD46-263E-E211-BFBA-1040F3A7A3B1");

            //Mock
            Mock <IFinderViewModelService <Domain.Entities.Template, TemplateViewModel> > finderViewModelService = new Mock <IFinderViewModelService <Domain.Entities.Template, TemplateViewModel> >();

            finderViewModelService.Setup((viewModelService) => viewModelService.Get(templateViewModel.Id)).Returns(templateViewModel);

            //SUT
            var SUT = new ClassFinderController(finderViewModelService.Object);

            //Act
            var result = SUT.Get(templateViewModel.Id) as ObjectResult;

            //Assert
            Assert.NotNull(result);
        }