private async Task <GetNotificationsResult> GetNotificationsAsync(
            string userId,
            string?sinceNotificationId,
            int maxItems,
            string?continuationToken,
            IUserNotificationStore userNotificationStore)
        {
            GetNotificationsResult results;

            try
            {
                this.logger.LogDebug($"Retrieving notifications for user {userId}");
                results = string.IsNullOrEmpty(continuationToken)
                                    ? await userNotificationStore.GetAsync(userId, sinceNotificationId, maxItems).ConfigureAwait(false)
                                    : await userNotificationStore.GetAsync(userId, continuationToken).ConfigureAwait(false);
            }
            catch (ArgumentException) when(!string.IsNullOrEmpty(continuationToken))
            {
                // The most likely reason for this is that the user Id in the continuation token doesn't match that in
                // the path - which makes this a bad request.
                throw new OpenApiBadRequestException("The combination of arguments supplied is invalid.", "The arguments supplied to the method were inconsistent. This likely means that the continuation token supplied was either invalid, or contained a different user Id to that specified in the path.");
            }

            return(results);
        }
        public async Task WhenIAskTheUserNotificationStoreForNotificationsForTheUserWithId(int itemCount, string userId, string resultName)
        {
            IUserNotificationStore store  = this.serviceProvider.GetRequiredService <IUserNotificationStore>();
            GetNotificationsResult result = await store.GetAsync(userId, null, itemCount).ConfigureAwait(false);

            this.scenarioContext.Set(result, resultName);
        }
        private async Task <GetNotificationsResult> GetNotificationsForUserAsync(string userId, int count)
        {
            ITenantedUserNotificationStoreFactory storeFactory = this.serviceProvider.GetRequiredService <ITenantedUserNotificationStoreFactory>();
            IUserNotificationStore store = await storeFactory.GetUserNotificationStoreForTenantAsync(this.featureContext.GetTransientTenant()).ConfigureAwait(false);

            return(await store.GetAsync(userId, null, count).ConfigureAwait(false));
        }
        public async Task WhenIAskTheUserNotificationStoreForNotificationsUsingTheContinuationTokenFromTheResultCalledAndCallTheResult(string userId, string previousResultName, string newResultName)
        {
            IUserNotificationStore store          = this.serviceProvider.GetRequiredService <IUserNotificationStore>();
            GetNotificationsResult previousResult = this.scenarioContext.Get <GetNotificationsResult>(previousResultName);
            GetNotificationsResult result         = await store.GetAsync(userId, previousResult.ContinuationToken !).ConfigureAwait(false);

            this.scenarioContext.Set(result, newResultName);
        }
        public async Task WhenIAskTheUserNotificationStoreForNotificationsSinceTheFirstNotificationInTheResultsCalledForTheUserWithIdAndCallTheResult(int itemCount, string previousResultName, string userId, string newResultName)
        {
            IUserNotificationStore store          = this.serviceProvider.GetRequiredService <IUserNotificationStore>();
            GetNotificationsResult previousResult = this.scenarioContext.Get <GetNotificationsResult>(previousResultName);
            GetNotificationsResult result         = await store.GetAsync(userId, previousResult.Results[0].Id, itemCount).ConfigureAwait(false);

            this.scenarioContext.Set(result, newResultName);
        }