Exemplo n.º 1
0
 public void AddValidation(ClientModelValidationContext context)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     context.Attributes.Add("data-val", "true");
     context.Attributes.Add("data-val-togglerequiredfield", ErrorMessage);
     context.Attributes.Add("data-val-togglerequiredfield-expectedvalue", ExpectedValue?.ToString());
     context.Attributes.Add("data-val-togglerequiredfield-targetfieldname", TargetFieldName);
     context.Attributes.Add("data-val-togglerequiredfield-hiddenclass", HiddenClass);
 }
        public void GetActiveDirectorySizeLimit_Should_ReturnExpectedValue()
        {
            // Arrange
            const int ExpectedValue = 1;

            SizeLimitTextBox.Text = ExpectedValue.ToString();

            // Act
            var result = privateObject.Invoke(GetActiveDirectorySizeLimitMethodName) as int?;

            // Assert
            result.ShouldSatisfyAllConditions(
                () => result.ShouldNotBeNull(),
                () => result.Value.ShouldBe(ExpectedValue));
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        public bool Match(JToken token)
        {
            try
            {
                if (!string.IsNullOrEmpty(Variable) && token.Type != JTokenType.Object)
                {
                    return(false);
                }

                var tmp = string.IsNullOrEmpty(Variable) ? token : ((JObject)token).SelectToken(Variable);
                if (tmp == null || tmp.Type != JTokenType.Boolean &&
                    tmp.Type != JTokenType.Date &&
                    tmp.Type != JTokenType.Integer &&
                    tmp.Type != JTokenType.Float &&
                    tmp.Type != JTokenType.String &&
                    tmp.Type != JTokenType.Guid &&
                    tmp.Type != JTokenType.Uri)
                {
                    return(false);
                }

                switch (_operator)
                {
                case Operator.Eq:
                    return(tmp.Value <T>()?.CompareTo(ExpectedValue) == 0);

                case Operator.Gt:
                    return(tmp.Value <T>()?.CompareTo(ExpectedValue) > 0);

                case Operator.Gte:
                    return(tmp.Value <T>()?.CompareTo(ExpectedValue) >= 0);

                case Operator.Lt:
                    return(tmp.Value <T>()?.CompareTo(ExpectedValue) < 0);

                case Operator.Lte:
                    return(tmp.Value <T>()?.CompareTo(ExpectedValue) <= 0);

                case Operator.Match:
                    return(IsMatch(tmp.Value <string>(), ExpectedValue.ToString()));
                }
            }
            catch (FormatException)
            {
            }

            return(false);
        }
Exemplo n.º 4
0
        public void CreateBody()
        {
            FunctionBody = FunctionHeader;

            FunctionBody += @"
{
            " + Type.Name + " obj= new " + Type.Name + "();" + @"
            " + MethodInfo.ReturnType.ToString() + " retVal = obj." + MethodInfo.Name + "(";
            foreach (object item in Parameters)
            {
                FunctionBody += item.ToString() + ",";
            }
            FunctionBody  = FunctionBody.Substring(0, FunctionBody.Length - 1);//remove trailing comma
            FunctionBody += ");" + @"
            if (retVal==" + ExpectedValue.ToString() + @")
            {
                Assert(true);
            }else{
                Assert(false);
            }
        
                
}";
        }
Exemplo n.º 5
0
        public void ConstructorConvertsMetadataValuesToParameterTypes()
        {
            using (var transformation = new FakeTransformationWithIntParameter())
            {
                const int    ExpectedValue = 42;
                const string ParameterName = "IntParameter";
                transformation.Host.GetMetadataValue = (hierarchy, fileName, metadataName) => metadataName == ParameterName?ExpectedValue.ToString(CultureInfo.InvariantCulture) : null;

                using (new TransformationContext(transformation, transformation.GenerationEnvironment))
                {
                    Assert.AreEqual(ExpectedValue, transformation.Session[ParameterName]);
                }
            }
        }