public void ProfileWithNesteds() { HtmlConventionFactory.Add(new DefaultHtmlConventions()); HtmlConventionFactory.Add(new DataAnnotationHtmlConventions()); var model = new ProfileViewModel() { Name = "Test" }; var helper = MvcMockHelpers.GetHtmlHelper(model); using (helper.Profile(new ProfileTest1())) { var tag = helper.Input(x => x.Name); tag.ToHtmlString().ShouldBe("<profile>Test</profile>"); using (helper.Profile(new ProfileTest2())) { var tag3 = helper.Input(x => x.Name); tag3.ToHtmlString().ShouldBe("<profilenested>Test</profilenested>"); } var tag2 = helper.Input(x => x.Name); tag2.ToHtmlString().ShouldBe("<profile>Test</profile>"); } var tag1 = helper.Input(x => x.Name); tag1.ToHtmlString().ShouldBe("<input type=\"text\" value=\"Test\" id=\"Name\" name=\"Name\" />"); }
public ValidationConventionTests() { HtmlConventionFactory.Add(new DefaultHtmlConventions()); HtmlConventionFactory.Add(new DataAnnotationHtmlConventions()); _dep = new Mock <IDependencyResolver>(); var dict = new Dictionary <Type, IValidator>(); dict.Add(typeof(IValidator <TestInputModel>), new TestInputValidator()); _dep.Setup(x => x.GetService(It.IsAny <Type>())).Returns <Type>(x => dict[x]); HtmlConventionFactory.Add(new FluentValidationHtmlConventions(new FluentValidatorFinder(_dep.Object))); HtmlConventionFactory.Add(new CombinationConventions()); }
public void ProfileBasic() { HtmlConventionFactory.Add(new DefaultHtmlConventions()); HtmlConventionFactory.Add(new DataAnnotationHtmlConventions()); var model = new ProfileViewModel() { Name = "Test" }; var helper = MvcMockHelpers.GetHtmlHelper(model); helper.Profile(new ProfileTest1()); var tag = helper.Input(x => x.Name); tag.ToHtmlString().ShouldBe("<profile>Test</profile>"); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteTable.Routes.MapHubs(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); HtmlConventionFactory.Add(new DefaultHtmlConventions()); HtmlConventionFactory.Add(new DataAnnotationHtmlConventions()); HtmlConventionFactory.Add(new DataAnnotationValidationHtmlConventions()); HtmlConventionFactory.Add(new UploadFileHtmlConvention()); ModelValidatorProviders.Providers.Add(new FluentValidationModelValidatorProvider(new AttributedValidatorFactory())); InitNPoco.Init(); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); ObjectFactory.Initialize(x => x.Scan(scan => { scan.TheCallingAssembly(); scan.ConnectImplementationsToTypesClosing(typeof(IValidator <>)); scan.ConnectImplementationsToTypesClosing(typeof(IHandler <>)); scan.ConnectImplementationsToTypesClosing(typeof(IHandler <,>)); scan.ConnectImplementationsToTypesClosing(typeof(ICommandHandler <>)); })); var resolver = new SmDependencyResolver(ObjectFactory.Container); DependencyResolver.SetResolver(resolver); ModelValidatorProviders.Providers.Add(new FluentValidationModelValidatorProvider(new FluentValidatorFactory(resolver))); ActionControllers.Setup(x => { x.FindActionsFromCurrentAssembly(); x.ResolveActionsBy(DependencyResolver.Current.GetService); }); ValidatorOptions.DisplayNameResolver = (type, info, arg3) => { return(info.Name + "_i18n"); }; HtmlConventionFactory.Add(new DefaultHtmlConventions()); HtmlConventionFactory.Add(new DataAnnotationHtmlConventions()); HtmlConventionFactory.Add(new FluentValidationHtmlConventions(new FluentValidatorFinder(resolver))); ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(new FeatureCsRazorViewEngine("Controllers")); }
public HtmlLoopTests() { HtmlConventionFactory.Add(new DefaultHtmlConventions()); }
public ReusingConventionTests() { HtmlConventionFactory.Add(new DefaultHtmlConventions()); HtmlConventionFactory.Add(new ReusingConventions()); }
public DefaultHtmlConventionTests() { HtmlConventionFactory.Add(new DefaultHtmlConventions()); HtmlConventionFactory.Add(new DataAnnotationHtmlConventions()); }
public LessStronglyTypedConventions() { HtmlConventionFactory.Add(new DefaultHtmlConventions()); }
public DataAnnotValidationConventionTests() { HtmlConventionFactory.Add(new DataAnnotationValidationHtmlConventions()); }