Пример #1
0
        public async Task Should_Get_All_Subscriptions_Async()
        {
            await CreateTestSubscriptionAsync(); //AppWebhookDefinitionNames.Test
            await CreateTestSubscriptionAsync(AppWebhookDefinitionNames.Users.Created);
            await CreateTestSubscriptionAsync(); //AppWebhookDefinitionNames.Test
            await CreateTestSubscriptionAsync(AppWebhookDefinitionNames.Users.Created,
                                              AppWebhookDefinitionNames.Theme.DefaultThemeChanged);

            var testSubscriptions = await _webhookSubscriptionsStore.GetAllSubscriptionsAsync(
                AbpSession.TenantId,
                AppWebhookDefinitionNames.Test
                );

            testSubscriptions.Count.ShouldBe(2);

            foreach (var webhookSubscriptionInfo in testSubscriptions)
            {
                webhookSubscriptionInfo.GetSubscribedWebhooks().Single().ShouldBe(AppWebhookDefinitionNames.Test);
            }

            var userCreatedSubscriptions = await _webhookSubscriptionsStore.GetAllSubscriptionsAsync(
                AbpSession.TenantId,
                AppWebhookDefinitionNames.Users.Created
                );

            userCreatedSubscriptions.Count.ShouldBe(2);
            foreach (var webhookSubscriptionInfo in userCreatedSubscriptions)
            {
                webhookSubscriptionInfo.Webhooks.ShouldContain(AppWebhookDefinitionNames.Users.Created);
            }

            userCreatedSubscriptions[1].Webhooks.ShouldContain(AppWebhookDefinitionNames.Theme.DefaultThemeChanged);
        }
        public async Task Should_Get_Subscribed_Webhooks_Async()
        {
            await CreateTestSubscriptionAsync(AppWebhookDefinitionNames.Test);
            await CreateTestSubscriptionAsync(AppWebhookDefinitionNames.Test, AppWebhookDefinitionNames.Users.Created);
            await CreateTestSubscriptionAsync(AppWebhookDefinitionNames.Test, AppWebhookDefinitionNames.Users.Created, AppWebhookDefinitionNames.Theme.DefaultThemeChanged);

            var subscribedWebhooks = await _webhookSubscriptionsStore.GetAllSubscriptionsAsync(AbpSession.TenantId);

            subscribedWebhooks.Count.ShouldBe(3);

            subscribedWebhooks[0].GetSubscribedWebhooks().Count.ShouldBe(1);
            subscribedWebhooks[0].Webhooks.ShouldContain(AppWebhookDefinitionNames.Test);

            subscribedWebhooks[1].GetSubscribedWebhooks().Count.ShouldBe(2);
            subscribedWebhooks[1].Webhooks.ShouldContain(AppWebhookDefinitionNames.Test);
            subscribedWebhooks[1].Webhooks.ShouldContain(AppWebhookDefinitionNames.Users.Created);

            subscribedWebhooks[2].GetSubscribedWebhooks().Count.ShouldBe(3);
            subscribedWebhooks[2].Webhooks.ShouldContain(AppWebhookDefinitionNames.Test);
            subscribedWebhooks[2].Webhooks.ShouldContain(AppWebhookDefinitionNames.Users.Created);
            subscribedWebhooks[2].Webhooks.ShouldContain(AppWebhookDefinitionNames.Theme.DefaultThemeChanged);
        }