public void Entry_subscribes_to_INotifyCollectionChanged_for_Remove(bool ourCollection) { var item = new ChangedOnlyNotificationEntity(); var collection = CreateCollection(ourCollection, item); var testListener = SetupTestCollectionListener(collection); collection.Remove(item); Assert.Equal("RelatedCollection", testListener.CollectionChanged.Single().Item2.Name); Assert.Empty(testListener.CollectionChanged.Single().Item3); Assert.Same(item, testListener.CollectionChanged.Single().Item4.Single()); }
public void Entry_ignores_INotifyCollectionChanged_for_Move() { var item1 = new ChangedOnlyNotificationEntity(); var item2 = new ChangedOnlyNotificationEntity(); var collection = new ObservableCollection <ChangedOnlyNotificationEntity> { item1, item2 }; var testListener = SetupTestCollectionListener(collection); collection.Move(0, 1); Assert.Empty(testListener.CollectionChanged); }
public void Entry_throws_for_INotifyCollectionChanged_Reset() { var item1 = new ChangedOnlyNotificationEntity(); var item2 = new ChangedOnlyNotificationEntity(); var collection = new ObservableCollection <ChangedOnlyNotificationEntity> { item1, item2 }; var testListener = SetupTestCollectionListener(collection); Assert.Equal( CoreStrings.ResetNotSupported, Assert.Throws <InvalidOperationException>(() => collection.Clear()).Message); Assert.Empty(testListener.CollectionChanged); }
public void Entry_subscribes_to_INotifyCollectionChanged_for_Replace() { var item1 = new ChangedOnlyNotificationEntity(); var collection = new ObservableCollection <ChangedOnlyNotificationEntity> { item1 }; var testListener = SetupTestCollectionListener(collection); var item2 = new ChangedOnlyNotificationEntity(); collection[0] = item2; Assert.Equal("RelatedCollection", testListener.CollectionChanged.Single().Item2.Name); Assert.Same(item2, testListener.CollectionChanged.Single().Item3.Single()); Assert.Same(item1, testListener.CollectionChanged.Single().Item4.Single()); }
public void Entry_handles_clear_as_replace_with_ObservableHashSet() { var item1 = new ChangedOnlyNotificationEntity(); var item2 = new ChangedOnlyNotificationEntity(); var collection = new ObservableHashSet <ChangedOnlyNotificationEntity> { item1, item2 }; var testListener = SetupTestCollectionListener(collection); collection.Clear(); Assert.Empty(collection); Assert.Equal("RelatedCollection", testListener.CollectionChanged.Single().Item2.Name); Assert.Empty(testListener.CollectionChanged.Single().Item3); Assert.Same(item1, testListener.CollectionChanged.Single().Item4.First()); Assert.Same(item2, testListener.CollectionChanged.Single().Item4.Skip(1).Single()); }
public void Entry_ignores_INotifyCollectionChanged_for_Move(bool ourCollection) { var item1 = new ChangedOnlyNotificationEntity(); var item2 = new ChangedOnlyNotificationEntity(); var collection = CreateCollection(ourCollection, item1, item2); var testListener = SetupTestCollectionListener(collection); if (ourCollection) { ((ObservableCollectionWithClear <ChangedOnlyNotificationEntity>)collection).Move(0, 1); } else { ((ObservableCollection <ChangedOnlyNotificationEntity>)collection).Move(0, 1); } Assert.Empty(testListener.CollectionChanged); }
public void Snapshots_are_created_for_entities_without_changing_notifications() { var entity = new ChangedOnlyNotificationEntity { Name = "Palmer", Id = 1 }; var entry = TestHelpers.Instance.CreateInternalEntry( BuildModel(), EntityState.Unchanged, entity); Assert.True(entry.HasRelationshipSnapshot); Assert.Equal("Palmer", entry.GetOriginalValue(entry.EntityType.FindProperty("Name"))); entity.Name = "Luckey"; Assert.Equal("Palmer", entry.GetOriginalValue(entry.EntityType.FindProperty("Name"))); }
public void Entry_subscribes_to_INotifyCollectionChanged_for_Replace(bool ourCollection) { var item1 = new ChangedOnlyNotificationEntity(); var collection = CreateCollection(ourCollection, item1); var testListener = SetupTestCollectionListener(collection); var item2 = new ChangedOnlyNotificationEntity(); if (ourCollection) { ((ObservableCollectionWithClear <ChangedOnlyNotificationEntity>)collection)[0] = item2; } else { ((ObservableCollection <ChangedOnlyNotificationEntity>)collection)[0] = item2; } Assert.Equal("RelatedCollection", testListener.CollectionChanged.Single().Item1.Name); Assert.Same(item2, testListener.CollectionChanged.Single().Item2.Single()); Assert.Same(item1, testListener.CollectionChanged.Single().Item3.Single()); }