public void ComplexValueSet_ValueIsGettable() { var controller = new PropertyAccessController(BindingState.Bound); var thing = new DummyComplexProperty(); var accessor = new PropertyAccessor <DummyComplexProperty>(controller, string.Empty, BindingAccess.Read | BindingAccess.Write); accessor.Value = thing; Assert.Equal(thing, accessor.Value); }
public void ComplexValueChanged_HasBeenModifiedChanges() { var controller = new PropertyAccessController(BindingState.Bound); var thing = new DummyComplexProperty(); var accessor = new PropertyAccessor <DummyComplexProperty>(thing, controller, string.Empty, BindingAccess.Read | BindingAccess.Write); Assert.False(accessor.HasBeenModified); thing.HasBeenModified = true; //Simulate a change to the complex value Assert.True(accessor.HasBeenModified); }
public void ComplexValueSet_HasBeenModifiedChanges() { var controller = new PropertyAccessController(BindingState.Bound); var thing = new DummyComplexProperty(); var accessor = new PropertyAccessor <DummyComplexProperty>(controller, string.Empty, BindingAccess.Read | BindingAccess.Write); Assert.False(accessor.HasBeenModified); accessor.Value = thing; Assert.True(accessor.HasBeenModified); }
public void ComplexPropertyReadOnlySet_ObjectIsNotWritable() { var controller = new PropertyAccessController(BindingState.Bound); var property = new DummyComplexProperty(); var accessor = new PropertyAccessor <DummyComplexProperty>(property, controller, string.Empty, BindingAccess.Read | BindingAccess.Write); //Set readonly accessor.IsReadOnly = true; Assert.Throws <InvalidOperationException>(() => accessor.Value = new DummyComplexProperty()); Assert.False(accessor.HasBeenModified); }
public void ComplexPropertyReadOnlySet_ObjectIsReadable() { var controller = new PropertyAccessController(BindingState.Bound); var property = new DummyComplexProperty(); var accessor = new PropertyAccessor <DummyComplexProperty>(property, controller, string.Empty, BindingAccess.Read | BindingAccess.Write); //Set readonly accessor.IsReadOnly = true; Assert.True(accessor.IsReadOnly); Assert.True(accessor.Value.IsReadOnly); Assert.Equal(property, accessor.Value); }
public void ComplexPropertyReadOnlySetAndUnset_ObjectIsReadWritable() { var controller = new PropertyAccessController(BindingState.Bound); var property = new DummyComplexProperty(); var accessor = new PropertyAccessor <DummyComplexProperty>(property, controller, string.Empty, BindingAccess.Read | BindingAccess.Write); //Set readonly accessor.IsReadOnly = true; //Un-set readonly accessor.IsReadOnly = false; Assert.False(accessor.Value.IsReadOnly); Assert.False(accessor.IsReadOnly); accessor.Value.HasBeenModified = true; Assert.True(accessor.HasBeenModified); }