Exemplo n.º 1
0
        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());
        }
Exemplo n.º 3
0
        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>");
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        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"));
        }
Exemplo n.º 6
0
 public HtmlLoopTests()
 {
     HtmlConventionFactory.Add(new DefaultHtmlConventions());
 }
Exemplo n.º 7
0
 public ReusingConventionTests()
 {
     HtmlConventionFactory.Add(new DefaultHtmlConventions());
     HtmlConventionFactory.Add(new ReusingConventions());
 }
 public DefaultHtmlConventionTests()
 {
     HtmlConventionFactory.Add(new DefaultHtmlConventions());
     HtmlConventionFactory.Add(new DataAnnotationHtmlConventions());
 }
Exemplo n.º 9
0
 public LessStronglyTypedConventions()
 {
     HtmlConventionFactory.Add(new DefaultHtmlConventions());
 }
 public DataAnnotValidationConventionTests()
 {
     HtmlConventionFactory.Add(new DataAnnotationValidationHtmlConventions());
 }