예제 #1
0
        public void NotRegisteredNewAttributeRuleConfigFactoryGivesEmptyRule()
        {
            var viewModel = new TestValidationAttributePropertyViewModel();

            var koValidation = new KnockoutValidationGenerator();

            var generatedValidatonJson = koValidation.Generate(viewModel, JsonConvert.SerializeObject);

            var objectToSerialize = new
            {
                SomeProperty = new { }
            };

            var expectedJson = JsonConvert.SerializeObject(objectToSerialize);

            Assert.AreEqual(expectedJson, generatedValidatonJson);
        }
예제 #2
0
        public void RequiredNoMessagePropertyTest()
        {
            var model        = new RequiredNoMessagePropertyViewModel();
            var koValidation = new KnockoutValidationGenerator();

            var generatedValidatonJson = koValidation.Generate(model, JsonConvert.SerializeObject);

            var objectToSerialize = new
            {
                SomeProperty = new
                {
                    required = true
                }
            };
            var expectedJson = JsonConvert.SerializeObject(objectToSerialize);

            Assert.AreEqual(expectedJson, generatedValidatonJson);
        }
예제 #3
0
        private static void RegisterNewAttributeRuleConfigFactoryTestCore(bool useDefaultConfiguration)
        {
            var viewModel = new TestValidationAttributePropertyViewModel();

            var koValidation = new KnockoutValidationGenerator(useDefaultConfiguration);

            koValidation.RegisterRuleConfigFactory(new TestRuleConfigFactory(), typeof(TestValidationAttribute));

            var generatedValidatonJson = koValidation.Generate(viewModel, JsonConvert.SerializeObject);

            var objectToSerialize = new
            {
                SomeProperty = new Dictionary <string, object>
                {
                    { TestRuleConfigFactory.RuleName, TestValidationAttributePropertyViewModel.AdditionalPropertyValue }
                }
            };
            var expectedJson = JsonConvert.SerializeObject(objectToSerialize);

            Assert.AreEqual(expectedJson, generatedValidatonJson);
        }
예제 #4
0
        public void RequiredResourceMessagePropertyTest()
        {
            var model        = new RequiredResourceMessagePropertyViewModel();
            var koValidation = new KnockoutValidationGenerator();

            var generatedValidatonJson = koValidation.Generate(model, JsonConvert.SerializeObject);

            var objectToSerialize = new
            {
                SomeProperty = new
                {
                    required = new
                    {
                        @params = true,
                        message = Resources.ResourceManager.GetString(RequiredResourceMessagePropertyViewModel.ErrorMessageResourceName)
                    }
                }
            };
            var expectedJson = JsonConvert.SerializeObject(objectToSerialize);

            Assert.AreEqual(expectedJson, generatedValidatonJson);
        }