コード例 #1
0
        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) }));
            });
        }
コード例 #2
0
        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) }));
            });
        }
コード例 #3
0
        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) }));
        }
コード例 #4
0
        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) }));
        }
コード例 #5
0
        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) }));
            });
        }