public void RootToSubNewUnchanged()
        {
            DomainObject obj = GetNewUnchanged();

            using (TestableClientTransaction.CreateSubTransaction().EnterDiscardingScope())
            {
                Assert.That(obj.State, Is.EqualTo(StateType.NotLoadedYet));
                obj.EnsureDataAvailable();
                Assert.That(obj.State, Is.EqualTo(StateType.Unchanged));
            }
            Assert.That(obj.State, Is.EqualTo(StateType.New));
        }
        public void BidirectionalForeignKeyRelationProperty_ShouldReturnNotLoadedObject()
        {
            var id = new ObjectID(typeof(ClassWithInvalidRelation), new Guid("{AFA9CF46-8E77-4da8-9793-53CAA86A277C}"));
            var objectWithInvalidRelation = (ClassWithInvalidRelation)id.GetObject <TestDomainBase> ();

            DomainObject instance = null;

            Assert.That(() => instance = objectWithInvalidRelation.ClassWithGuidKey, Throws.Nothing);

            Assert.That(instance.State, Is.EqualTo(StateType.NotLoadedYet));

            Assert.That(() => instance.EnsureDataAvailable(), Throws.TypeOf <ObjectsNotFoundException>());
            CheckObjectIsMarkedInvalid(instance.ID);

            // Note: See also ObjectWithInvalidForeignKeyTest
        }
        public void BidirectionalForeignKeyRelationProperty_Subtransaction()
        {
            DomainObject instance = null;

            using (TestableClientTransaction.CreateSubTransaction().EnterDiscardingScope())
            {
                var id = new ObjectID(typeof(ClassWithInvalidRelation), new Guid("{AFA9CF46-8E77-4da8-9793-53CAA86A277C}"));

                var objectWithInvalidRelation = (ClassWithInvalidRelation)id.GetObject <TestDomainBase> ();

                Assert.That(() => instance = objectWithInvalidRelation.ClassWithGuidKey, Throws.Nothing);
                Assert.That(instance.State, Is.EqualTo(StateType.NotLoadedYet));

                Assert.That(() => instance.EnsureDataAvailable(), Throws.TypeOf <ObjectsNotFoundException> ());
                CheckObjectIsMarkedInvalid(instance.ID);
            }
            CheckObjectIsMarkedInvalid(instance.ID);
        }