public void AddingItemsManually_AsParent_ThenAsChild_ThrowsDueToInfiniteCycle()
        {
            // Arrange
            var connectedParent = HiveModelCreationHelper.MockTypedEntity();
            var middleItem = HiveModelCreationHelper.MockTypedEntity();
            connectedParent.Id = HiveId.ConvertIntToGuid(1); // It's connected with a lazy-loader so it should have an Id
            middleItem.Id = HiveId.ConvertIntToGuid(2); // It's connected with a lazy-loader so it should have an Id
            var rpc = new RelationProxyCollection(middleItem);

            // Act
            // Add parent to this item
            rpc.EnlistParent(connectedParent, FixedRelationTypes.DefaultRelationType);

            // Assert
            // Try to add the parent as a child of the middle item, hoping it throws
            Assert.Throws<InvalidOperationException>(() => rpc.EnlistChild(connectedParent, FixedRelationTypes.DefaultRelationType));
        }
Example #2
0
        public void AddingItemsManually_AsParent_ThenAsChild_ThrowsDueToInfiniteCycle()
        {
            // Arrange
            var connectedParent = HiveModelCreationHelper.MockTypedEntity();
            var middleItem      = HiveModelCreationHelper.MockTypedEntity();

            connectedParent.Id = HiveId.ConvertIntToGuid(1); // It's connected with a lazy-loader so it should have an Id
            middleItem.Id      = HiveId.ConvertIntToGuid(2); // It's connected with a lazy-loader so it should have an Id
            var rpc = new RelationProxyCollection(middleItem);

            // Act
            // Add parent to this item
            rpc.EnlistParent(connectedParent, FixedRelationTypes.DefaultRelationType);

            // Assert
            // Try to add the parent as a child of the middle item, hoping it throws
            Assert.Throws <InvalidOperationException>(() => rpc.EnlistChild(connectedParent, FixedRelationTypes.DefaultRelationType));
        }