コード例 #1
0
        private void InitializeEditors()
        {
            NameEditor = new TextEditorComponentVM();

            var propertyAdapter    = SampleUserMetadata.NameProperty;
            var namePropertyEditor = new PropertyDataEditor <SampleUser, string, ValidationState>(propertyAdapter,
                                                                                                  NameEditor,
                                                                                                  ValidationStateAdapter.GetPropertyError);

            _editors.Add(namePropertyEditor);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }