public void Cast_CanDowncast() { var handle = new DomainObjectHandle <Order> (DomainObjectIDs.Order1).Cast <DomainObject> (); var result = handle.Cast <Order>(); Assert.That(result, Is.SameAs(handle)); Assert.That(VariableTypeInferrer.GetVariableType(result), Is.SameAs(typeof(IDomainObjectHandle <Order>))); }
public void GetSafeHandle() { var domainObject = DomainObjectMother.CreateFakeObject <Order> (); var handle = domainObject.GetSafeHandle(); var domainObjectTypedObjectID1 = domainObject.GetSafeHandle <IDomainObject> (); var domainObjectTypedObjectID2 = ((IDomainObject)domainObject).GetSafeHandle(); Assert.That(handle, Is.TypeOf <DomainObjectHandle <Order> > ().And.Property("ObjectID").EqualTo(domainObject.ID)); Assert.That(domainObjectTypedObjectID1, Is.TypeOf <DomainObjectHandle <Order> > ().And.Property("ObjectID").EqualTo(domainObject.ID)); Assert.That(domainObjectTypedObjectID2, Is.TypeOf <DomainObjectHandle <Order> > ().And.Property("ObjectID").EqualTo(domainObject.ID)); Assert.That(VariableTypeInferrer.GetVariableType(handle), Is.SameAs(typeof(IDomainObjectHandle <Order>))); Assert.That(VariableTypeInferrer.GetVariableType(domainObjectTypedObjectID1), Is.SameAs(typeof(IDomainObjectHandle <IDomainObject>))); Assert.That(VariableTypeInferrer.GetVariableType(domainObjectTypedObjectID2), Is.SameAs(typeof(IDomainObjectHandle <IDomainObject>))); }