public ITestProperty SetObject(ITestObject testObject) { AssertIsVisible(); AssertIsModifiable(); ResetLastMessage(); Assert.IsFalse(field.ReturnSpec.IsParseable, "Drop(..) not allowed on value target field; use SetValue(..) instead"); var testNakedObjectAdapter = testObject.NakedObject; Assert.IsTrue(testNakedObjectAdapter.Spec.IsOfType(field.ReturnSpec), $"Can't drop a {testObject.NakedObject.Spec.ShortName} on to the {Name} field (which accepts {field.ReturnSpec})"); var nakedObjectAdapter = owningObject.NakedObject; var valid = field switch { IOneToOneAssociationSpec associationSpec => associationSpec.IsAssociationValid(nakedObjectAdapter, testNakedObjectAdapter), IOneToManyAssociationSpec _ => new Veto("Always disabled"), _ => throw new UnknownTypeException(field) }; LastMessage = valid.Reason; Assert.IsFalse(valid.IsVetoed, $"Cannot SetObject {testNakedObjectAdapter} in the field {field} within {nakedObjectAdapter}: {valid.Reason}"); var spec = field as IOneToOneAssociationSpec; spec?.SetAssociation(nakedObjectAdapter, testNakedObjectAdapter); return(this); }
public PropParmAdapter(IOneToOneAssociationSpec prop, INakedObjectsSurface surface, INakedObjectsFramework framework) : this((object) prop, surface, framework) { this.prop = prop; CheckAutocompleOrConditional(); }