Skip to content

Commit

Permalink
Added following test in ChangeTrackingCollectionTests:
Browse files Browse the repository at this point in the history
Adding_And_Removing_The_Same_Territory_Should_Not_Keep_Added_Territory_In_Territory_Collection

Updated RemoveItem in ChangeTrackingCollection so that removed m-m items with TrackingState.Added are not cached in the _deleted collection. Test now passes.
  • Loading branch information
Anthony Sneed committed Aug 30, 2016
1 parent f8613aa commit 17ad6b9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Source/TrackableEntities.Client/ChangeTrackingCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,15 @@ protected override void RemoveItem(int index)
item.SetTracking(false, visitationHelper.Clone(), true);

// Mark item and trackable collection properties
bool manyToManyAdded = Parent != null && item.TrackingState == TrackingState.Added;
item.SetState(TrackingState.Deleted, visitationHelper.Clone());

// Fire EntityChanged event
if (EntityChanged != null) EntityChanged(this, EventArgs.Empty);

// Cache deleted item if not added or already cached
if (item.TrackingState != TrackingState.Added
&& !manyToManyAdded
&& !_deletedEntities.Contains(item))
_deletedEntities.Add(item);
}
Expand Down

0 comments on commit 17ad6b9

Please sign in to comment.