public void Return_empty_result_for_invalid_SEO_code_on_ajax_call_to_GetNewSeoCode()
        {
            const string seoCode = "invalid code";

            _socioEconomicObjectiveRepository.GetSocioEconomicObjective(seoCode).Returns(x => null);

            _controller.WithCallTo(c => c.GetNewSeoCode(seoCode)).ShouldRenderEmptyResult();
        }
        public void Get_a_socio_economic_objective()
        {
            const string id     = "950307";
            var          entity = _repository.GetSocioEconomicObjective(id);

            Assert.That(entity, Is.Not.Null, "Socio economic objective not found");
            Assert.That(entity.Id, Is.EqualTo(id), "Incorrect socio economic objective retrieved");
        }
        public static void PopulateSeoCodes <T>(this ISocioEconomicObjectiveRepository socioEconomicObjectiveRepository, IResearchCodesViewModel vm, NameValueCollection form) where T : ClassificationBase, new()
        {
            var socioEconomicObjective = socioEconomicObjectiveRepository.GetSocioEconomicObjective(vm.SocioEconomicObjectiveCode);

            if (socioEconomicObjective == null)
            {
                throw new Exception("Socio economic objective code not found, please ensure code is correct")
                      {
                          Source = "SocioEconomicObjectiveCode"
                      };
            }

            if (vm.SocioEconomicObjectives == null)
            {
                vm.SocioEconomicObjectives = new List <ClassificationBase> {
                    new T {
                        Code = socioEconomicObjective
                    }
                };
            }
            else if (!vm.SocioEconomicObjectives.Any(o => o.Code.Id == socioEconomicObjective.Id))
            {
                vm.SocioEconomicObjectives.Add(new T {
                    Code = socioEconomicObjective
                });
                vm.SocioEconomicObjectives = vm.SocioEconomicObjectives.OrderBy(o => o.Code.Id).ToList();
            }
        }
Пример #4
0
        /// <summary>
        /// Gets a SEO code and inserts it into a suitable model for the partial view.
        /// </summary>
        /// <param name="term">The SEO code.</param>
        /// <returns>Partial view</returns>
        public ActionResult GetNewSeoCode(string term)
        {
            var socioEconomicObjective = _socioEconomicObjectiveRepository.GetSocioEconomicObjective(term);

            if (socioEconomicObjective == null)
            {
                return(new EmptyResult());
            }

            var newRow = new ClassificationBase {
                Id = 0, Code = socioEconomicObjective
            };

            return(PartialView("_SocioEconomicObjective", newRow));
        }
        public void Should_add_seo_code()
        {
            var newSeoCode = new SocioEconomicObjective
            {
                Id   = int.MaxValue.ToString(),
                Name = "New SeoCode"
            };
            var vm = GetProjectDetailsViewModel();

            vm.SocioEconomicObjectiveCode = newSeoCode.Id;
            _socioEconomicObjectiveRepository.GetSocioEconomicObjective(newSeoCode.Id).Returns(newSeoCode);
            _controller
            .WithCallTo(c => c.AddSeoCode(vm))
            .ShouldRenderView("Project");

            Assert.That(vm.SocioEconomicObjectives.Count(o => o.Code.Id == newSeoCode.Id && o.Code.Name == newSeoCode.Name), Is.EqualTo(1), "Seo Code not added");
        }