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 Cast_ThrowsOnUnsupportedCast()
        {
            var handle = new DomainObjectHandle <Order> (DomainObjectIDs.Order1);

            Assert.That(
                () => handle.Cast <OrderItem> (),
                Throws.TypeOf <InvalidCastException> ().With.Message.EqualTo(
                    "The handle for object 'Order|5682f032-2f0b-494b-a31c-c97f02b89c36|System.Guid' cannot be represented as a handle for type "
                    + "'Remotion.Data.DomainObjects.UnitTests.TestDomain.OrderItem'."));
        }