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 WhatWasSetIsWhatValueReturns() { var sut = new EditorComponentVM <string>(); var implicitSut = (IEditorComponent <string>)sut; const string sample = "sample"; // act implicitSut.SetValue(sample); // assert sut.Value.Should().Be(sample); }
public void SetErrorRaisesPropertyChangeNotification() { var sut = new EditorComponentVM <string>(); const string error = "error"; // act sut.MonitorEvents(); sut.SetError(error); // assert sut.ShouldRaisePropertyChangeFor(x => x.Value); }
public void WhatWasAssignedToValueIsWhatGetValueReturns() { var sut = new EditorComponentVM <string>(); var implicitSut = (IEditorComponent <string>)sut; const string sample = "sample"; // act sut.Value = sample; // assert implicitSut.GetValue().Should().Be(sample); }
public void SetValueRaisesPropertyChangeNotification() { var sut = new EditorComponentVM <string>(); var implicitSut = (IEditorComponent <string>)sut; const string sample = "sample"; // act sut.MonitorEvents(); implicitSut.SetValue(sample); // assert sut.ShouldRaisePropertyChangeFor(x => x.Value); }
public void NonEmptyErrorMessageValueIsWhatErrorInterfaceReturns() { var sut = new EditorComponentVM <string>(); var implicitSut = (IDataErrorInfo)sut; const string error = "error"; // act sut.SetError(error); // assert implicitSut.Error.Should().Be(error); implicitSut["Value"].Should().Be(error); }
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 EventIsRaisedWhenReadOnlyStateIsUpdated() { var sut = new EditorComponentVM <string>(); var implicitSut = (IEditorComponent <string>)sut; const bool isReadOnly = true; // act implicitSut.MonitorEvents(); implicitSut.SetReadOnly(isReadOnly); // assert sut.ShouldRaisePropertyChangeFor(x => x.IsReadOnly); sut.IsReadOnly.Should().Be(isReadOnly); }
public void AssignedValueCausesEventToBeRaised() { var sut = new EditorComponentVM <string>(); var implicitSut = (IEditorComponent <string>)sut; const string sample = "sample"; // act implicitSut.MonitorEvents(); sut.Value = sample; // assert implicitSut.ShouldRaise("ValueUpdated") .WithSender(implicitSut) .WithArgs <EventArgs>(args => args == EventArgs.Empty); }
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); }