Exemple #1
0
        public void ValidateEmptyCollectionNotAllowedField_ShouldPassIfNonEmptyCollectIsProvided()
        {
            var obj = new ModelWithRequiredNonEmptyCollection();

            var validation = ModelValidator.ValidateEntity(obj);

            Assert.IsFalse(validation.HasError);
        }
Exemple #2
0
        public void ValidateEmptyCollectionNotAllowedField_ShouldNotPassIfEmptyCollectIsProvided()
        {
            var obj = new ModelWithRequiredNonEmptyCollection();

            obj.Array       = Enumerable.Empty <string>().ToArray();
            obj.List        = obj.Array.ToList();
            obj.Collection  = obj.Array.ToHashSet();
            obj.IEnumerable = obj.Array.ToDictionary(x => x);

            var validation = ModelValidator.ValidateEntity(obj);

            Assert.IsTrue(validation.HasError);
            Assert.AreEqual(4, validation.Errors.Count);
        }