コード例 #1
0
        public override void IsValid_ArgumentChecks()
        {
            base.IsValid_ArgumentChecks();
            var compareOperator_noProperty = new CompareOperatorAttribute("noProperty");

            Assert.IsNotNull(compareOperator_noProperty.GetValidationResult(1, _context), "Null other property");
        }
コード例 #2
0
        public void OtherPropertyTitle()
        {
            var methodInfo = typeof(CompareOperatorAttribute).GetMethod("TryToExtractOtherPropertyTitle",
                                                                        BindingFlags.Instance | BindingFlags.NonPublic);
            var getOtherPropertyTitle = typeof(CompareOperatorAttribute).GetProperty("OtherPropertyTitle",
                                                                                     BindingFlags.Instance | BindingFlags.NonPublic).GetGetMethod(true);

            var checks = new Checks <string, string>()
            {
                { "WithNonExistentNameAndResourceType", "WithNonExistentNameAndResourceType" },
                { "WithDisplayName", "WithDisplayName" },
                { "WithName", "WithName" },
                { "WithNameAndResourceType", "TestFieldValue" },
                { "WithNonExistentNameAndResourceType", "WithNonExistentNameAndResourceType" },
                { "WithNameAndNullResourceType", "WithNameAndNullResourceType" }
            };

            foreach (var check in checks)
            {
                var attribute    = new CompareOperatorAttribute(check.Item1);
                var propertyInfo = typeof(TestProperties).GetProperty(check.Item1);
                methodInfo.Invoke(attribute, new[] { propertyInfo });
                Assert.AreEqual(check.Item2, getOtherPropertyTitle.Invoke(attribute, null),
                                "Invalid title for property " + check.Item1);
            }
        }
コード例 #3
0
        public void CannotSetNullOtherProperty()
        {
            var compareOperator = new CompareOperatorAttribute("otherProperty");

            compareOperator.OtherProperty = null;
        }
コード例 #4
0
 public override void TestInit()
 {
     base.TestInit();
     _operator = new CompareOperatorAttribute(_holderPropertyName);
 }