private void InitializeEditors() { NameEditor = new TextEditorComponentVM(); var propertyAdapter = SampleUserMetadata.NameProperty; var namePropertyEditor = new PropertyDataEditor <SampleUser, string, ValidationState>(propertyAdapter, NameEditor, ValidationStateAdapter.GetPropertyError); _editors.Add(namePropertyEditor); }
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); }
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); }