Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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);
        }