public void NotificationHostViewModel_AddsSpawnedNotificationToCollection_WhenNotNull() => new TestScheduler().With(scheduler => { var notificator = new Notificator(); var sut = new NotificationHostViewModel(notificator); sut.Activator.Activate(); notificator.PublishInfo("Hi"); scheduler.AdvanceBy(2); Assert.Equal(1, sut.Notifications.Count); });
public void NotificationExtensions_PublishInfo_SetsInfoLevelAtNotification() { bool success = false; var notificator = new Notificator(); (notificator as INotificationListener).Notifications .Take(1) .Where(x => x.Level == NotificationLevel.Info) .Subscribe(_ => success = true); notificator.PublishInfo("Test"); Assert.True(success); }
public void Notificator_PushesNotificationsDirectlyToStream() => new TestScheduler().With(scheduler => { bool success = false; var sut = new Notificator(); (sut as INotificationListener).Notifications .Where(x => x.Message == "123") .Subscribe(_ => success = true); sut.PublishInfo("123"); scheduler.AdvanceBy(1); Assert.True(success); });
public void NotificationHostViewModel_RemovesNotificationFromList_AfterCloseRequested() => new TestScheduler().With(scheduler => { var notificator = new Notificator(); var sut = new NotificationHostViewModel(notificator); sut.Activator.Activate(); notificator.PublishInfo("Hi"); // Pass throttle scheduler.AdvanceBy(TimeSpan.FromMilliseconds(100).Ticks + 1); var notification = sut.Notifications.First(); notification.Close.Execute(Unit.Default).Subscribe(); scheduler.AdvanceBy(4); Assert.Equal(0, sut.Notifications.Count); });