Beispiel #1
0
        public void ComponentErrorIsUpdatedOnlyWithItsPropertyErrors()
        {
            const string message = "Error";

            var target = new EditableStruct {
                Text = "Invalid"
            };

            var editorComponent = Substitute.For <IEditorComponent <string> >();
            var propertyAdapter = EditableStructMetadata.TextProperty;
            var sut             = new PropertyDataEditor <EditableStruct, string, ValidationState>(propertyAdapter, editorComponent, ValidationStateAdapter.GetPropertyError)
            {
                EditableTarget = target
            };

            // act
            sut.UpdateValidationState(new ValidationState(new Dictionary <string, string>
            {
                { "Some property", message }
            }));

            // assert
            editorComponent.DidNotReceive().SetError(message);
        }
Beispiel #2
0
        public void ComponentErrorIsUpdatedWhenValidationFails()
        {
            const string message = "Error";

            var target = new EditableClass {
                Text = "Invalid"
            };

            var editorComponent = Substitute.For <IEditorComponent <string> >();
            var propertyAdapter = EditableClassMetadata.TextProperty;
            var sut             = new PropertyDataEditor <EditableClass, string, ValidationState>(propertyAdapter, editorComponent, ValidationStateAdapter.GetPropertyError)
            {
                EditableTarget = target
            };

            // act
            sut.UpdateValidationState(new ValidationState(new Dictionary <string, string>
            {
                { propertyAdapter.PropertyName, message }
            }));

            // assert
            editorComponent.Received().SetError(message);
        }