public void CanValidateGuid()
 {
     var v = new NotEmptyAttribute();
     v.IsValid(Guid.NewGuid(), null).Should().Be.True();
     v.IsValid(Guid.Empty, null).Should().Be.False();
     Guid? gn = null;
     v.IsValid(gn, null).Should().Be.True();
     gn = Guid.Empty;
     v.IsValid(gn, null).Should().Be.False();
     gn = Guid.NewGuid();
     v.IsValid(gn, null).Should().Be.True();
 }
        public void IsValid()
        {
            var v = new NotEmptyAttribute();
            Assert.IsTrue(v.IsValid("abc", null));
            Assert.IsTrue(v.IsValid(new int[] { 1 }, null));
            Assert.IsTrue(v.IsValid(new List<int>(new int[] { 1 }), null));
            Assert.IsTrue(v.IsValid(null, null));

            Assert.IsFalse(v.IsValid("", null));
            Assert.IsFalse(v.IsValid("    ", null));
            Assert.IsFalse(v.IsValid(123, null));
            Assert.IsFalse(v.IsValid(new int[0], null));
            Assert.IsFalse(v.IsValid(new List<int>(), null));
        }
Exemplo n.º 3
0
        private static Attribute ConvertToNotEmpty(XmlNhvmRuleConverterArgs rule)
        {
            NhvmNotEmpty notEmptyRule = (NhvmNotEmpty)rule.schemaRule;
            NotEmptyAttribute thisAttribute = new NotEmptyAttribute();
            log.Info("Converting to NotEmptyAttribute");

            if (notEmptyRule.message != null)
            {
                thisAttribute.Message = notEmptyRule.message;
            }
            AssignTagsFromString(thisAttribute, notEmptyRule.tags);

            return thisAttribute;
        }
 public void WhenEnumeratorIsDisposable_ShouldDispose()
 {
     var v = new NotEmptyAttribute();
     DisposableEnumerator.DisposedTimes = 0;
     v.IsValid(new DisposableEnumerable(), null);
     DisposableEnumerator.DisposedTimes.Should().Be.GreaterThan(0);
 }