示例#1
0
        private static EventRecorder[] BuildRecorders(INotifyPropertyChanged eventSource)
        {
            var eventRecorder = new EventRecorder(eventSource, "PropertyChanged");

            eventSource.PropertyChanged += (sender, args) => eventRecorder.RecordEvent(sender, args);
            return(new[] { eventRecorder });
        }
示例#2
0
        public void DeletingACounterShouldRaiseTheCollectionChangedEvent()
        {
            var dbfile = Path.Combine(RootPath, Guid.NewGuid().ToString("N") + ".db3");

            DatabaseHelper.CreateDatabase(dbfile);

            var db      = new DatabaseHelper();
            var counter = new Counter
            {
                Name        = "TestCounter",
                Description = "A test counter"
            };

            var res = Task.Run(async() =>
            {
                await db.AddOrUpdateCounterAsync(counter);
                return(0);
            }).Result;

            var eventRecorder = new EventRecorder(db, nameof(DatabaseHelper.CountersChanged));

            eventRecorder.RecordEvent();

            res = Task.Run(async() =>
            {
                await db.DeleteCounterAsync(counter);
                return(0);
            }).Result;

            eventRecorder.Should().HaveCount(1);
        }
示例#3
0
        private static EventRecorder[] BuildRecorders(object eventSource)
        {
            var eventRecorder = new EventRecorder(eventSource, PropertyChangedEventName);

            ((INotifyPropertyChanged)eventSource).PropertyChanged += (sender, args) => eventRecorder.RecordEvent(sender, args);
            return(new[] { eventRecorder });
        }