public void FindNestedNamesWithWhen() { var model = new TestViewModel(); var helper = MvcMockHelpers.GetHtmlHelper(model); var finder = new FluentValidatorFinder(_dep.Object); var vals = finder.FindValidators(RequestData.BuildRequestData(helper.ViewContext, ReflectionHelper.GetAccessor <TestViewModel>(x => x.Nested1.ReallyLongName), typeof(TestInputModel))); vals.Count().ShouldBe(1); vals.First().DisplayName.ShouldBe("ReallyLongLongNameWhen"); }
public async Task <ActionResult> About(AboutQueryModel query) { var requiredService = HttpContext.RequestServices.GetRequiredService <IUrlHelper>(); ViewData["Message"] = await requiredService.ForAsync(new AboutQueryModel(), true); var model = new AboutViewModel() { Name = "Name" }; var finder = new FluentValidatorFinder(x => { var res = (IValidator)HttpContext.RequestServices.GetService(x); return(res); }); var result = finder.FindValidators(RequestData.BuildRequestData(ReflectionHelper.GetAccessor <AboutViewModel>(x => x.NestedModel.NameNested), typeof(AboutViewModel))); return(new HandleActionBuilder <AboutQueryModel>(query, _invoker) .Returning <AboutViewModel>() .OnSuccess(View)); }