public void TryGetObject_ShouldReturnNull_AndMarkObjectNotFound()
        {
            DomainObject instance = null;

            Assert.That(() => instance = _nonExistingObjectID.TryGetObject <TestDomainBase> (), Throws.Nothing);

            Assert.That(instance, Is.Null);
            CheckObjectIsMarkedInvalid(_nonExistingObjectID);

            // After the object has been marked invalid
            Assert.That(() => instance = _nonExistingObjectID.TryGetObject <TestDomainBase> (), Throws.Nothing);
            Assert.That(instance, Is.Not.Null);
            Assert.That(instance.State, Is.EqualTo(StateType.Invalid));
        }
Beispiel #2
0
        public void TryGetObject_NotFound()
        {
            var objectID = new ObjectID(typeof(Order), Guid.NewGuid());

            Assert.That(_transaction.IsInvalid(objectID), Is.False);

            var order = _transaction.ExecuteInScope(() => objectID.TryGetObject <TestDomainBase> ());

            Assert.That(order, Is.Null);
            Assert.That(_transaction.IsInvalid(objectID), Is.True);
        }
        public void TryGetObject_Subtransaction()
        {
            using (TestableClientTransaction.CreateSubTransaction().EnterDiscardingScope())
            {
                DomainObject instance = null;
                CheckObjectIsMarkedInvalid(_nonExistingObjectIDForSubtransaction);

                Assert.That(() => instance = _nonExistingObjectIDForSubtransaction.TryGetObject <TestDomainBase> (), Throws.Nothing);

                Assert.That(instance, Is.Not.Null);
                Assert.That(instance.State, Is.EqualTo(StateType.Invalid));

                Assert.That(() => instance = _nonExistingObjectID.TryGetObject <TestDomainBase> (), Throws.Nothing);

                Assert.That(instance, Is.Null);
                CheckObjectIsMarkedInvalid(_nonExistingObjectID);
            }

            CheckObjectIsMarkedInvalid(_nonExistingObjectID);
            CheckObjectIsNotMarkedInvalid(_nonExistingObjectIDForSubtransaction);
        }
        public void TryGetObject_AllowsNotFoundObjects()
        {
            var result = _notFoundObjectID.TryGetObject <Order> (_clientTransaction);

            Assert.That(result, Is.Null);
        }
        public void TryGetObject_LoadsObjectIntoGivenTransaction()
        {
            var result = _orderID1.TryGetObject <Order> (_clientTransaction);

            CheckDomainObject(result, _clientTransaction, expectedID: _orderID1, expectedState: StateType.Unchanged);
        }