|
| 1 | +using System.Collections.Generic; |
| 2 | +using Bunq.Sdk.Context; |
| 3 | +using Bunq.Sdk.Model.Core; |
| 4 | +using Bunq.Sdk.Model.Generated.Endpoint; |
| 5 | +using Bunq.Sdk.Model.Generated.Object; |
| 6 | +using Xunit; |
| 7 | + |
| 8 | +namespace Bunq.Sdk.Tests.Model.Core |
| 9 | +{ |
| 10 | + /// <summary> |
| 11 | + /// Tests: |
| 12 | + /// NotificationFilterUrlMonetaryAccountInternal |
| 13 | + /// NotificationFilterUrlUserInternal |
| 14 | + /// NotificationFilterPushUserInternal |
| 15 | + /// </summary> |
| 16 | + public class NotificationFilterTest: BunqSdkTestBase, IClassFixture<NotificationFilterTest> |
| 17 | + { |
| 18 | + /// <summary> |
| 19 | + /// Filter constants. |
| 20 | + /// </summary> |
| 21 | + private const string FILTER_CATEGORY_MUTATION = "MUTATION"; |
| 22 | + private const string FILTER_CALLBACK_URL = "https://test.com/callback"; |
| 23 | + |
| 24 | + /// <summary> |
| 25 | + /// Test NotificationFilterUrlMonetaryAccount creation. |
| 26 | + /// </summary> |
| 27 | + [Fact] |
| 28 | + public void TestNotificationFilterUrlMonetaryAccount() |
| 29 | + { |
| 30 | + SetUpApiContext(); |
| 31 | + |
| 32 | + NotificationFilterUrl notificationFilter = GetNotificationFilterUrl(); |
| 33 | + List<NotificationFilterUrl> allCreatedNotificationFilter = NotificationFilterUrlMonetaryAccountInternal.CreateWithListResponse( |
| 34 | + GetPrimaryMonetaryAccount().Id.Value, |
| 35 | + new List<NotificationFilterUrl>() {notificationFilter} |
| 36 | + ).Value; |
| 37 | + |
| 38 | + Assert.True(allCreatedNotificationFilter.Count == 1); |
| 39 | + } |
| 40 | + |
| 41 | + /// <summary> |
| 42 | + /// Test NotificationFilterUrlUser creation. |
| 43 | + /// </summary> |
| 44 | + [Fact] |
| 45 | + public void TestNotificationFilterUrlUser() |
| 46 | + { |
| 47 | + SetUpApiContext(); |
| 48 | + |
| 49 | + NotificationFilterUrl notificationFilter = GetNotificationFilterUrl(); |
| 50 | + List<NotificationFilterUrl> allCreatedNotificationFilter = NotificationFilterUrlUserInternal.CreateWithListResponse( |
| 51 | + new List<NotificationFilterUrl>() {notificationFilter} |
| 52 | + ).Value; |
| 53 | + |
| 54 | + Assert.True(allCreatedNotificationFilter.Count == 1); |
| 55 | + } |
| 56 | + /// <summary> |
| 57 | + /// Test NotificationFilterPushUser creation. |
| 58 | + /// </summary> |
| 59 | + [Fact] |
| 60 | + public void TestNotificationFilterPushUser() |
| 61 | + { |
| 62 | + SetUpApiContext(); |
| 63 | + |
| 64 | + NotificationFilterPush notificationFilter = GetNotificationFilterPush(); |
| 65 | + List<NotificationFilterPush> allCreatedNotificationFilter = NotificationFilterPushUserInternal.CreateWithListResponse( |
| 66 | + new List<NotificationFilterPush>() {notificationFilter} |
| 67 | + ).Value; |
| 68 | + |
| 69 | + Assert.True(allCreatedNotificationFilter.Count == 1); |
| 70 | + } |
| 71 | + |
| 72 | + /// <summary> |
| 73 | + /// Test clear all filters. |
| 74 | + /// </summary> |
| 75 | + [Fact] |
| 76 | + public void TestNotificationFilterClear() |
| 77 | + { |
| 78 | + SetUpApiContext(); |
| 79 | + |
| 80 | + List<NotificationFilterPush> allCreatedNotificationFilterPushUser = |
| 81 | + NotificationFilterPushUserInternal.CreateWithListResponse().Value; |
| 82 | + List<NotificationFilterUrl> allCreatedNotificationFilterUrlUser = |
| 83 | + NotificationFilterUrlUserInternal.CreateWithListResponse().Value; |
| 84 | + List<NotificationFilterUrl> allCreatedNotificationFilterUrlMonetaryAccount = |
| 85 | + NotificationFilterUrlMonetaryAccountInternal.CreateWithListResponse().Value; |
| 86 | + |
| 87 | + Assert.Empty(allCreatedNotificationFilterPushUser); |
| 88 | + Assert.Empty(allCreatedNotificationFilterUrlUser); |
| 89 | + Assert.Empty(allCreatedNotificationFilterUrlMonetaryAccount); |
| 90 | + |
| 91 | + Assert.StrictEqual(0, NotificationFilterPushUserInternal.List().Value.Count); |
| 92 | + Assert.StrictEqual(0, NotificationFilterUrlUserInternal.List().Value.Count); |
| 93 | + Assert.StrictEqual(0, NotificationFilterUrlMonetaryAccountInternal.List().Value.Count); |
| 94 | + } |
| 95 | + |
| 96 | + private NotificationFilterUrl GetNotificationFilterUrl() |
| 97 | + { |
| 98 | + return new NotificationFilterUrl(FILTER_CATEGORY_MUTATION, FILTER_CALLBACK_URL); |
| 99 | + } |
| 100 | + |
| 101 | + private NotificationFilterPush GetNotificationFilterPush() |
| 102 | + { |
| 103 | + return new NotificationFilterPush(FILTER_CATEGORY_MUTATION); |
| 104 | + } |
| 105 | + |
| 106 | + private MonetaryAccountBank GetPrimaryMonetaryAccount() |
| 107 | + { |
| 108 | + return BunqContext.UserContext.PrimaryMonetaryAccountBank; |
| 109 | + } |
| 110 | + } |
| 111 | +} |
0 commit comments