public void Throws_when_not_initialized()
            {
                var entityReference = new EntityReference<object>();

                Assert.Equal(
                    Strings.RelatedEnd_OwnerIsNull,
                    Assert.Throws<InvalidOperationException>(() => entityReference.Load()).Message);
            }
        internal void BeginForeignKeyUpdate(EntityReference relationship)
        {
            Debug.Assert(!IsForeignKeyUpdate);

            RelationshipBeingUpdated = relationship;
            IsForeignKeyUpdate = true;
        }
            public void OperationCanceledException_thrown_before_loading_results_if_task_is_cancelled()
            {
                var mockEntityWrapper = new Mock<IEntityWrapper>();
                mockEntityWrapper
                    .Setup(w => w.Entity)
                    .Returns(new object());

                var entityReference =
                    new EntityReference<object>(
                        mockEntityWrapper.Object,
                        new RelationshipNavigation("Going", "fromA", "toB", null, null),
                        new Mock<IRelationshipFixer>().Object);


                Assert.Throws<OperationCanceledException>(
                    () => entityReference.LoadAsync(new CancellationToken(canceled: true))
                        .GetAwaiter().GetResult());

                Assert.Throws<OperationCanceledException>(
                    () => entityReference.LoadAsync(MergeOption.NoTracking, new CancellationToken(canceled: true))
                        .GetAwaiter().GetResult());
            }
            public void Throws_when_not_initialized()
            {
                var entityReference = new EntityReference<object>();

                Assert.Equal(
                    Strings.RelatedEnd_OwnerIsNull,
                    Assert.Throws<InvalidOperationException>(
                        () =>
                        ExceptionHelpers.UnwrapAggregateExceptions(
                            () =>
                            entityReference.LoadAsync(CancellationToken.None).Wait())).Message);
            }