Example #1
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);
        }