public async Task ValidationFailedTest() { var store = new Mock <ISettingsDataStore>(); var subscriber = new Mock <IPushNotificationSubscriber>(); var service = new PushNotificationSubscriptionService(store.Object, subscriber.Object); await Assert.ThrowsAsync <ArgumentNullException>(() => service.UnsubscribeDeviceAsync(null)); await Assert.ThrowsAsync <ArgumentNullException>(() => service.UnsubscribeUserAsync(null)); await Assert.ThrowsAsync <ArgumentNullException>(() => service.CreateOrUpdateSubscriptionAsync(null)); subscriber.Verify(x => x.UnsubscribeDeviceAsync(It.IsAny <string>()), Times.Never); subscriber.Verify(x => x.UnsubscribeByTagAsync(It.IsAny <string>()), Times.Never); subscriber.Verify(x => x.CreateOrUpdatePushSubscriptionAsync(It.IsAny <PushSubscriptionRequest>()), Times.Never); }
public async Task UnsubscribeUserTest() { var userId = Guid.NewGuid().ToString(); var userTag = TagHelper.GetUserTag(userId); var store = new Mock <ISettingsDataStore>(); store.Setup(x => x.DoesExistAsync(It.Is <string>(s => s == userId))) .ReturnsAsync(true); var subscriber = new Mock <IPushNotificationSubscriber>(); var service = new PushNotificationSubscriptionService(store.Object, subscriber.Object); await service.UnsubscribeUserAsync(new UserRequest(userId)); store.Verify(x => x.DoesExistAsync(userId), Times.Once); subscriber.Verify(x => x.UnsubscribeByTagAsync(userTag), Times.Once); }