public void ValueChangeUpdatesTargetProperty() { const string updatedValue = "Updated"; var target = new EditableStruct { Text = "Initial" }; var editorComponent = new EditorComponentVM <string>(); var propertyAdapter = EditableStructMetadata.TextProperty; var sut = new ScalarPropertyDataEditor <EditableStruct, string, EditorComponentVM <string> >(propertyAdapter, editorComponent); // act sut.MonitorEvents(); sut.EditableTarget = target; sut.Component.Value = updatedValue; // assert sut.ShouldRaise("TargetUpdated") .WithSender(sut); sut.Component.Value.Should().Be(updatedValue); }
public void ReadonlyStateIsAssignedToComponent() { var editorComponent = new EditorComponentVM <string>(); var propertyAdapter = EditableStructMetadata.ReadonlyTextProperty; // act var sut = new ScalarPropertyDataEditor <EditableStruct, string, EditorComponentVM <string> >(propertyAdapter, editorComponent); // assert sut.Component.IsReadOnly.Should().Be(EditableStructMetadata.ReadonlyTextProperty.IsReadOnly); }
public void NullEditableTargetIsTolerated() { var editorComponent = new EditorComponentVM <string>(); var propertyAdapter = EditableClassMetadata.TextProperty; var sut = new ScalarPropertyDataEditor <EditableClass, string, EditorComponentVM <string> >(propertyAdapter, editorComponent); // act sut.Component.MonitorEvents(); sut.EditableTarget = null; // assert sut.Component.Value.Should().Be(default(string)); }
public void ValueUpdateChangeReportedOnTargetUpdate() { var target = new EditableClass { Text = "Initial" }; var editorComponent = new EditorComponentVM <string>(); var propertyAdapter = EditableClassMetadata.TextProperty; var sut = new ScalarPropertyDataEditor <EditableClass, string, EditorComponentVM <string> >(propertyAdapter, editorComponent); // act sut.Component.MonitorEvents(); sut.EditableTarget = target; // assert sut.Component.ShouldRaisePropertyChangeFor(x => x.Value); sut.Component.Value.Should().Be(target.Text); }