public void ReplaceAllUsesIdentityComparerGivenAtConstruction() { IEnumerable <IntWrapper> originalItems = new IntWrapper[] { 1, 2, 3 }; var replacements = new IntWrapper[] { 1, 3 }; // NOTE: Due to conservate update check, unchanged items will appear as item changes of type update // NOTE2: Need to use the actual instances, since IntWrapper uses reference equality var expectedChanges = new ItemChange <IntWrapper>[] { new ItemChange <IntWrapper>(ChangeType.Updated, replacements[0]), new ItemChange <IntWrapper>(ChangeType.Updated, replacements[1]), new ItemChange <IntWrapper>(ChangeType.Removed, originalItems.ElementAt(1)) }; var loader = new ThreadSafeAsyncLoader <IntWrapper>( Seq.ListBased, loadDataAsync: _ => Task.FromResult(originalItems), identityComparer: new IntWrapperComparer(), eventContext: new RunInlineSynchronizationContext()); loader.LoadAsync(); // load initial values loader.CollectionChanged += (s, e) => { // Verify that the actual changes match the expected changes e.Should().BeEquivalentTo(expectedChanges); }; loader.ReplaceAll(replacements); // --- Perform --- }