Ejemplo n.º 1
0
        public void AddFault_MultipleFault_FaultsMultipleElements()
        {
            var validationContext = A.Fake <IValidationContext <TestDataObject> >();

            var propertyValidationContext =
                new PropertyValidationContext <TestDataObject, string>(x => x.StrValue, validationContext);

            var fault  = A.Fake <IValidationFault>();
            var fault1 = A.Fake <IValidationFault>();
            var fault2 = A.Fake <IValidationFault>();

            propertyValidationContext.AddFault(fault);
            propertyValidationContext.AddFault(fault1);
            propertyValidationContext.AddFault(fault2);

            Assert.Equal(new[] { fault, fault1, fault2 }, propertyValidationContext.Faults);
        }
Ejemplo n.º 2
0
        public void AddFault_AddNull_ThrowsException()
        {
            var validationContext = A.Fake <IValidationContext <TestDataObject> >();

            var propertyValidationContext =
                new PropertyValidationContext <TestDataObject, string>(x => x.StrValue, validationContext);

            Assert.Throws <ArgumentNullException>(() => propertyValidationContext.AddFault(null));
        }
Ejemplo n.º 3
0
        public void AddFault_OneFault_FaultsHasExactOneElement()
        {
            var validationContext = A.Fake <IValidationContext <TestDataObject> >();

            var propertyValidationContext =
                new PropertyValidationContext <TestDataObject, string>(x => x.StrValue, validationContext);

            var fault = A.Fake <IValidationFault>();

            propertyValidationContext.AddFault(fault);

            Assert.Single((IEnumerable)propertyValidationContext.Faults);
            Assert.Single(propertyValidationContext.Faults, f => f == fault);
        }