Esempio n. 1
0
        public void RemoveDataErrorInfo_RemovingAPropertyLevelError_GetErrorsShouldReturnGivenError()
        {
            var personDto = new TestPersonDto { FirstName = "John", LastName = "Wayne" };
            var dataErrorInfo = new DataErrorInfo ( "PropertyLevelError", ErrorLevel.Error, "FirstName" );

            personDto.AddDataErrorInfo ( dataErrorInfo );

            personDto.RemoveDataErrorInfo ( "FirstName" );

            IEnumerable<DataErrorInfo> errors = personDto.GetErrors ( "FirstName" ) as IEnumerable<DataErrorInfo>;
            List<DataErrorInfo> returnedList = new List<DataErrorInfo> ( errors );

            Assert.IsTrue ( returnedList.Count == 0 );
        }
Esempio n. 2
0
        public void RemoveDataErrorInfo_RemovingAPropertyLevelError_ErrorsChangedEventShouldFire()
        {
            var personDto = new TestPersonDto { FirstName = "John", LastName = "Wayne" };
            var dataErrorInfo = new DataErrorInfo ( "EntityLevelError", ErrorLevel.Error, "FirstName" );
            string propertyName = "Dummy";

            personDto.AddDataErrorInfo ( dataErrorInfo );
            personDto.ErrorsChanged += ( s, e ) => { propertyName = e.PropertyName; };
            personDto.RemoveDataErrorInfo ( "FirstName" );

            Assert.AreEqual ( propertyName, "FirstName" );
        }
Esempio n. 3
0
        public void RemoveDataErrorInfo_RemovingAnObjectLevelError_ErrorsChangedEventShouldFire()
        {
            var personDto = new TestPersonDto { FirstName = "John", LastName = "Wayne" };
            var dataErrorInfo = new DataErrorInfo ( "EntityLevelError", ErrorLevel.Error );
            string propertyName = "Dummy";

            personDto.AddDataErrorInfo ( dataErrorInfo );
            personDto.ErrorsChanged += ( s, e ) => { propertyName = e.PropertyName; };
            personDto.RemoveDataErrorInfo ( String.Empty );

            Assert.IsTrue ( string.IsNullOrEmpty ( propertyName ) );
        }
Esempio n. 4
0
        public void RemoveDataErrorInfo_RemovingAnObjectLevelError_GetErrorsShouldReturnGivenError()
        {
            var personDto = new TestPersonDto { FirstName = "John", LastName = "Wayne" };
            var dataErrorInfo = new DataErrorInfo ( "EntityLevelError", ErrorLevel.Error );
            IEnumerable<DataErrorInfo> errors = new List<DataErrorInfo> ();

            personDto.AddDataErrorInfo ( dataErrorInfo );

            personDto.ErrorsChanged +=
                ( s, e ) => { errors = personDto.GetErrors ( e.PropertyName ) as IEnumerable<DataErrorInfo>; };

            personDto.RemoveDataErrorInfo ( String.Empty );

            List<DataErrorInfo> returnedList = new List<DataErrorInfo> ( errors );

            Assert.IsTrue ( returnedList.Count == 0 );
        }
Esempio n. 5
0
        public void RemoveDataErrorInfo_RemovingACrossPropertyLevelError_ErrorsChangedEventShouldFireWhenLastNameRemoved()
        {
            var personDto = new TestPersonDto { FirstName = "John", LastName = "Wayne" };
            var dataErrorInfo = new DataErrorInfo ( "EntityLevelError", ErrorLevel.Error, "FirstName", "LastName" );
            List<string> propertyNames = new List<string> { "FirstName", "LastName" };

            personDto.AddDataErrorInfo ( dataErrorInfo );
            personDto.ErrorsChanged += ( s, e ) => RemoveFromList ( propertyNames, e.PropertyName );
            personDto.RemoveDataErrorInfo ( "LastName" );

            Assert.IsTrue ( propertyNames.Count == 0 );
        }