Ejemplo n.º 1
0
        public override void SetUp()
        {
            base.SetUp();

            _manager = new DictionaryBasedEnlistedDomainObjectManager();
            _order   = DomainObjectMother.GetObjectInOtherTransaction <Order> (DomainObjectIDs.Order1);
        }
Ejemplo n.º 2
0
        public void PerformCollectionInsertWithOtherClientTransaction()
        {
            var order1     = DomainObjectIDs.Order1.GetObject <Order> ();
            var orderItem3 = DomainObjectMother.GetObjectInOtherTransaction <OrderItem> (DomainObjectIDs.OrderItem3);

            order1.OrderItems.Insert(0, orderItem3);
        }
Ejemplo n.º 3
0
        public void SetValue_WithRelatedObject_WithObjectNotEnlistedInThisTransaction()
        {
            var order = DomainObjectIDs.Order1.GetObject <Order> ();
            var orderTicketFromOtherTransaction = DomainObjectMother.GetObjectInOtherTransaction <OrderTicket> (DomainObjectIDs.OrderTicket1);

            CreateAccessor(order, "OrderTicket").SetValueWithoutTypeCheck(orderTicketFromOtherTransaction);
        }
Ejemplo n.º 4
0
        public void EnlistDomainObject_IDAlreadyEnlisted()
        {
            var orderA = DomainObjectMother.GetObjectInOtherTransaction <Order> (DomainObjectIDs.Order1);
            var orderB = DomainObjectMother.GetObjectInOtherTransaction <Order> (DomainObjectIDs.Order1);

            _manager.EnlistDomainObject(orderA);
            _manager.EnlistDomainObject(orderB);
        }
Ejemplo n.º 5
0
        public void PerformCollectionRemoveWithOtherClientTransaction()
        {
            var order1     = DomainObjectIDs.Order1.GetObject <Order> ();
            var orderItem1 = DomainObjectMother.GetObjectInOtherTransaction <OrderItem> (DomainObjectIDs.OrderItem1);

            var endPoint = DomainObjectCollectionDataTestHelper.GetAssociatedEndPoint(order1.OrderItems);

            endPoint.Collection.Remove(orderItem1);
        }
Ejemplo n.º 6
0
        public void Disenlist_OtherReferenceEnlisted()
        {
            var orderA = DomainObjectMother.GetObjectInOtherTransaction <Order> (_order.ID);

            _manager.EnlistDomainObject(orderA);

            Assert.That(
                () => _manager.DisenlistDomainObject(_order),
                Throws.InvalidOperationException.With.Message.EqualTo(
                    "Object 'Order|5682f032-2f0b-494b-a31c-c97f02b89c36|System.Guid' is not enlisted."));
        }
        public void EnsureCompatibility_WithObjectsFromUnrelatedTransaction_ThrowsException()
        {
            var domainObject1 = DomainObjectMother.GetObjectInOtherTransaction <ClassWithAllDataTypes> (DomainObjectIDs.ClassWithAllDataTypes1);
            var domainObject2 = DomainObjectMother.GetObjectInOtherTransaction <ClassWithAllDataTypes> (DomainObjectIDs.ClassWithAllDataTypes2);

            Assert.That(
                () => _transaction.EnsureCompatibility(new[] { domainObject1, domainObject2 }),
                Throws.TypeOf <InvalidOperationException>().With.Message.StringMatching(
                    @"The following objects are incompatible with the target transaction\: "
                    + @"ClassWithAllDataTypes\|.*\|System\.Guid, ClassWithAllDataTypes\|.*\|System\.Guid\. "
                    + @"Objects of type \'Remotion\.Data\.DomainObjects\.IDomainObjectHandle\`1\[T\]\' could be used instead\.")
                .And.Message.StringContaining("ClassWithAllDataTypes|3f647d79-0caf-4a53-baa7-a56831f8ce2d|System.Guid")
                .And.Message.StringContaining("ClassWithAllDataTypes|583ec716-8443-4b55-92bf-09f7c8768529|System.Guid"));
        }
Ejemplo n.º 8
0
        public override void SetUp()
        {
            base.SetUp();

            _customer1 = DomainObjectIDs.Customer1.GetObject <Customer> ();
            _customer2 = DomainObjectIDs.Customer2.GetObject <Customer> ();
            _customer3NotInCollection      = DomainObjectIDs.Customer3.GetObject <Customer> ();
            _customer1FromOtherTransaction = DomainObjectMother.GetObjectInOtherTransaction <Customer> (_customer1.ID);

            _collection = new DomainObjectCollection(typeof(Customer))
            {
                _customer1, _customer2
            };
        }
Ejemplo n.º 9
0
        public void PerformCollectionReplaceWithOtherClientTransaction()
        {
            var order1     = DomainObjectIDs.Order1.GetObject <Order> ();
            var orderItem3 = DomainObjectMother.GetObjectInOtherTransaction <OrderItem> (DomainObjectIDs.OrderItem3);

            int index = order1.OrderItems.IndexOf(DomainObjectIDs.OrderItem1);

            try
            {
                order1.OrderItems[index] = orderItem3;
                Assert.Fail("This test expects a ClientTransactionsDifferException.");
            }
            catch (ClientTransactionsDifferException ex)
            {
                string expectedMessage =
                    "Cannot put DomainObject 'OrderItem|0d7196a5-8161-4048-820d-b1bbdabe3293|System.Guid' into the collection of property "
                    + "'Remotion.Data.DomainObjects.UnitTests.TestDomain.Order.OrderItems' of DomainObject "
                    + "'Order|5682f032-2f0b-494b-a31c-c97f02b89c36|System.Guid'. The objects do not belong to the same ClientTransaction.";
                Assert.That(ex.Message, Is.EqualTo(expectedMessage));
            }
        }
        public void SetEquals_UsesReferenceComparison()
        {
            var order1FromOtherTransaction = DomainObjectMother.GetObjectInOtherTransaction <Order> (_order1.ID);

            Assert.That(_data.SetEquals(new[] { order1FromOtherTransaction, _order2 }), Is.False);
        }
Ejemplo n.º 11
0
        public void IndexOf_Object_OtherTransaction()
        {
            var customer1InOtherTransaction = DomainObjectMother.GetObjectInOtherTransaction <Customer> (_collection[0].ID);

            Assert.That(_collection.IndexOf(customer1InOtherTransaction), Is.EqualTo(-1));
        }
Ejemplo n.º 12
0
        public void ContainsObject_False_SameID_DifferentReference()
        {
            var customer1InOtherTransaction = DomainObjectMother.GetObjectInOtherTransaction <Customer> (_collection[0].ID);

            Assert.That(_collection.ContainsObject(customer1InOtherTransaction), Is.False);
        }