public void ManagedObject_WhenChanged_CallsOnPropertyChanged() { AsyncContext.Run(async delegate { var item = new AgedObject { Birthday = DateTimeOffset.UtcNow.AddYears(-5) }; _realm.Write(() => _realm.Add(item)); var notifiedPropertyNames = new List <string>(); item.PropertyChanged += (sender, e) => { notifiedPropertyNames.Add(e.PropertyName); }; _realm.Write(() => { item.Birthday = DateTimeOffset.UtcNow.AddYears(-6); }); await Task.Yield(); Assert.That(notifiedPropertyNames, Is.EquivalentTo(new[] { nameof(AgedObject.Birthday), nameof(AgedObject.Age) })); }); }
public void ManagedObject_WhenChangedOnAnotherThread_CallsOnPropertyChanged() { TestHelpers.RunAsyncTest(async() => { var item = new AgedObject { Birthday = DateTimeOffset.UtcNow.AddYears(-5) }; _realm.Write(() => _realm.Add(item)); var notifiedPropertyNames = new List <string>(); item.PropertyChanged += (sender, e) => { notifiedPropertyNames.Add(e.PropertyName); }; await _realm.WriteAsync(r => { var otherThreadInstance = r.All <AgedObject>().Single(); otherThreadInstance.Birthday = DateTimeOffset.UtcNow.AddYears(-6); }); await Task.Yield(); Assert.That(notifiedPropertyNames, Is.EquivalentTo(new[] { nameof(AgedObject.Birthday), nameof(AgedObject.Age) })); }); }
public void UnmanagedObject_WhenChanged_CallsOnPropertyChanged() { var item = new AgedObject { Birthday = DateTimeOffset.UtcNow.AddYears(-5) }; var notifiedPropertyNames = new List <string>(); item.PropertyChanged += (sender, e) => { notifiedPropertyNames.Add(e.PropertyName); }; item.Birthday = DateTimeOffset.UtcNow.AddYears(-6); Assert.That(notifiedPropertyNames, Is.EquivalentTo(new[] { nameof(AgedObject.Birthday), nameof(AgedObject.Age) })); }
public void UnmanagedObject_WhenChanged_CallsOnPropertyChanged() { var item = new AgedObject { Birthday = DateTimeOffset.UtcNow.AddYears(-5) }; var notifiedPropertyNames = new List<string>(); item.PropertyChanged += (sender, e) => { notifiedPropertyNames.Add(e.PropertyName); }; item.Birthday = DateTimeOffset.UtcNow.AddYears(-6); Assert.That(notifiedPropertyNames, Is.EquivalentTo(new[] { nameof(AgedObject.Birthday), nameof(AgedObject.Age) })); }
public void ManagedObject_WhenChangedOnAnotherThread_CallsOnPropertyChanged() { AsyncContext.Run(async delegate { var item = new AgedObject { Birthday = DateTimeOffset.UtcNow.AddYears(-5) }; _realm.Write(() => _realm.Add(item)); var notifiedPropertyNames = new List<string>(); item.PropertyChanged += (sender, e) => { notifiedPropertyNames.Add(e.PropertyName); }; await _realm.WriteAsync(r => { var otherThreadInstance = r.All<AgedObject>().Single(); otherThreadInstance.Birthday = DateTimeOffset.UtcNow.AddYears(-6); }); await Task.Yield(); Assert.That(notifiedPropertyNames, Is.EquivalentTo(new[] { nameof(AgedObject.Birthday), nameof(AgedObject.Age) })); }); }