From d3b3b8a3298e4002a05df073cabfbfc2d153a14f Mon Sep 17 00:00:00 2001 From: Pandu Masabathula Date: Mon, 7 Nov 2022 13:07:03 +0530 Subject: [PATCH] Objectsv2 Acceptance Tests (#157) * objectsv2 acceptance tests * Content-Type to request header to support acceptance tests --- .github/workflows/run_acceptance_tests.yml | 8 +- .pubnub.yml | 21 +- CHANGELOG | 5 + src/Api/PubnubApi/Interface/IPubnubHttp.cs | 2 +- src/Api/PubnubApi/Properties/AssemblyInfo.cs | 4 +- src/Api/PubnubApi/PubnubApi.csproj | 5 +- src/Api/PubnubApi/PubnubCoreBase.cs | 4 +- src/Api/PubnubApi/PubnubHttp.cs | 28 +- src/Api/PubnubApiPCL/PubnubApiPCL.csproj | 5 +- src/Api/PubnubApiUWP/PubnubApiUWP.csproj | 5 +- .../AcceptanceTests/AcceptanceTests.csproj | 52 ++ src/UnitTests/AcceptanceTests/Data/alice.json | 11 + .../AcceptanceTests/Data/ameliamember.json | 9 + src/UnitTests/AcceptanceTests/Data/bob.json | 15 + src/UnitTests/AcceptanceTests/Data/chat.json | 9 + .../AcceptanceTests/Data/chatmembership.json | 15 + src/UnitTests/AcceptanceTests/Data/dm.json | 13 + .../AcceptanceTests/Data/dmmembership.json | 19 + .../AcceptanceTests/Data/evamember.json | 7 + src/UnitTests/AcceptanceTests/Data/james.json | 11 + src/UnitTests/AcceptanceTests/Data/lisa.json | 15 + .../AcceptanceTests/Data/olivermember.json | 12 + .../AcceptanceTests/Data/patient.json | 9 + .../Data/patientmembership.json | 15 + .../AcceptanceTests/Data/petermember.json | 22 + .../AcceptanceTests/Data/vipchat.json | 13 + .../Data/vipchatmembership.json | 22 + .../Features/channel-metadata.feature | 45 ++ .../Features/channel-metadata.feature.cs | 372 +++++++++++++ .../Features/members-metadata.feature | 53 ++ .../Features/members-metadata.feature.cs | 401 ++++++++++++++ .../Features/membership-metadata.feature | 67 +++ .../Features/membership-metadata.feature.cs | 495 ++++++++++++++++++ .../Features/uuid-metadata.feature | 51 ++ .../Features/uuid-metadata.feature.cs | 417 +++++++++++++++ .../AcceptanceTests/Steps/GrantTokenSteps.cs | 3 +- .../Steps/ObjectsV2ChannelMetadataSteps.cs | 238 +++++++++ .../Steps/ObjectsV2MembersMetadataSteps.cs | 260 +++++++++ .../ObjectsV2MembershipsMetadataSteps.cs | 286 ++++++++++ .../Steps/ObjectsV2UuidMetadataSteps.cs | 402 ++++++++++++++ 40 files changed, 3416 insertions(+), 30 deletions(-) create mode 100644 src/UnitTests/AcceptanceTests/Data/alice.json create mode 100644 src/UnitTests/AcceptanceTests/Data/ameliamember.json create mode 100644 src/UnitTests/AcceptanceTests/Data/bob.json create mode 100644 src/UnitTests/AcceptanceTests/Data/chat.json create mode 100644 src/UnitTests/AcceptanceTests/Data/chatmembership.json create mode 100644 src/UnitTests/AcceptanceTests/Data/dm.json create mode 100644 src/UnitTests/AcceptanceTests/Data/dmmembership.json create mode 100644 src/UnitTests/AcceptanceTests/Data/evamember.json create mode 100644 src/UnitTests/AcceptanceTests/Data/james.json create mode 100644 src/UnitTests/AcceptanceTests/Data/lisa.json create mode 100644 src/UnitTests/AcceptanceTests/Data/olivermember.json create mode 100644 src/UnitTests/AcceptanceTests/Data/patient.json create mode 100644 src/UnitTests/AcceptanceTests/Data/patientmembership.json create mode 100644 src/UnitTests/AcceptanceTests/Data/petermember.json create mode 100644 src/UnitTests/AcceptanceTests/Data/vipchat.json create mode 100644 src/UnitTests/AcceptanceTests/Data/vipchatmembership.json create mode 100644 src/UnitTests/AcceptanceTests/Features/channel-metadata.feature create mode 100644 src/UnitTests/AcceptanceTests/Features/channel-metadata.feature.cs create mode 100644 src/UnitTests/AcceptanceTests/Features/members-metadata.feature create mode 100644 src/UnitTests/AcceptanceTests/Features/members-metadata.feature.cs create mode 100644 src/UnitTests/AcceptanceTests/Features/membership-metadata.feature create mode 100644 src/UnitTests/AcceptanceTests/Features/membership-metadata.feature.cs create mode 100644 src/UnitTests/AcceptanceTests/Features/uuid-metadata.feature create mode 100644 src/UnitTests/AcceptanceTests/Features/uuid-metadata.feature.cs create mode 100644 src/UnitTests/AcceptanceTests/Steps/ObjectsV2ChannelMetadataSteps.cs create mode 100644 src/UnitTests/AcceptanceTests/Steps/ObjectsV2MembersMetadataSteps.cs create mode 100644 src/UnitTests/AcceptanceTests/Steps/ObjectsV2MembershipsMetadataSteps.cs create mode 100644 src/UnitTests/AcceptanceTests/Steps/ObjectsV2UuidMetadataSteps.cs diff --git a/.github/workflows/run_acceptance_tests.yml b/.github/workflows/run_acceptance_tests.yml index 335ebf957..730d09f6a 100644 --- a/.github/workflows/run_acceptance_tests.yml +++ b/.github/workflows/run_acceptance_tests.yml @@ -18,13 +18,13 @@ jobs: steps: - name: Checkout Project - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Checkout mock-server action - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: pubnub/client-engineering-deployment-tools - ref: github-actions + ref: v1 token: ${{ secrets.GH_TOKEN }} path: client-engineering-deployment-tools @@ -51,7 +51,7 @@ jobs: cd ./UnitTests/AcceptanceTests && dotnet test --no-build --verbosity normal --logger trx --results-directory ./results - name: Upload acceptance tests reports if: always() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: acceptance-test-reports path: | diff --git a/.pubnub.yml b/.pubnub.yml index f037151d4..87bebee68 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,8 +1,15 @@ name: c-sharp -version: "6.10.0" +version: "6.11.0" schema: 1 scm: github.com/pubnub/c-sharp changelog: + - date: 2022-11-07 + version: v6.11.0 + changes: + - type: improvement + text: "Added Content-Type to request header to support internal acceptance tests." + - type: improvement + text: "Added acceptance tests for ObjectsV2 feature." - date: 2022-09-06 version: v6.10.0 changes: @@ -680,7 +687,7 @@ features: - QUERY-PARAM supported-platforms: - - version: Pubnub 'C#' 6.10.0 + version: Pubnub 'C#' 6.11.0 platforms: - Windows 10 and up - Windows Server 2008 and up @@ -690,7 +697,7 @@ supported-platforms: - .Net Framework 4.5 - .Net Framework 4.6.1+ - - version: PubnubPCL 'C#' 6.10.0 + version: PubnubPCL 'C#' 6.11.0 platforms: - Xamarin.Android - Xamarin.iOS @@ -710,7 +717,7 @@ supported-platforms: - .Net Core - .Net 6.0 - - version: PubnubUWP 'C#' 6.10.0 + version: PubnubUWP 'C#' 6.11.0 platforms: - Windows Phone 10 - Universal Windows Apps @@ -734,7 +741,7 @@ sdks: distribution-type: source distribution-repository: GitHub package-name: Pubnub - location: https://github.com/pubnub/c-sharp/releases/tag/v6.10.0.0 + location: https://github.com/pubnub/c-sharp/releases/tag/v6.11.0.0 requires: - name: ".Net" @@ -1017,7 +1024,7 @@ sdks: distribution-type: source distribution-repository: GitHub package-name: PubNubPCL - location: https://github.com/pubnub/c-sharp/releases/tag/v6.10.0.0 + location: https://github.com/pubnub/c-sharp/releases/tag/v6.11.0.0 requires: - name: ".Net Core" @@ -1376,7 +1383,7 @@ sdks: distribution-type: source distribution-repository: GitHub package-name: PubnubUWP - location: https://github.com/pubnub/c-sharp/releases/tag/v6.10.0.0 + location: https://github.com/pubnub/c-sharp/releases/tag/v6.11.0.0 requires: - name: "Universal Windows Platform Development" diff --git a/CHANGELOG b/CHANGELOG index 42447d9aa..416af8ddc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +v6.11.0 - November 07 2022 +----------------------------- +- Modified: added Content-Type to request header to support internal acceptance tests. +- Modified: added acceptance tests for ObjectsV2 feature. + v6.10.0 - September 06 2022 ----------------------------- - Fixed: add Users/Spaces support to PCL versions. diff --git a/src/Api/PubnubApi/Interface/IPubnubHttp.cs b/src/Api/PubnubApi/Interface/IPubnubHttp.cs index 88d96aa04..580dd10a6 100644 --- a/src/Api/PubnubApi/Interface/IPubnubHttp.cs +++ b/src/Api/PubnubApi/Interface/IPubnubHttp.cs @@ -18,7 +18,7 @@ public interface IPubnubHttp Task SendRequestAndGetJsonResponseWithPOST(Uri requestUri, RequestState pubnubRequestState, HttpWebRequest request, byte[] postData, string contentType); - Task SendRequestAndGetJsonResponseWithPATCH(Uri requestUri, RequestState pubnubRequestState, HttpWebRequest request, byte[] patchData); + Task SendRequestAndGetJsonResponseWithPATCH(Uri requestUri, RequestState pubnubRequestState, HttpWebRequest request, byte[] patchData, string contentType); Task SendRequestAndGetStreamResponse(Uri requestUri, RequestState pubnubRequestState, HttpWebRequest request); } diff --git a/src/Api/PubnubApi/Properties/AssemblyInfo.cs b/src/Api/PubnubApi/Properties/AssemblyInfo.cs index d6114a52c..84d9ef257 100644 --- a/src/Api/PubnubApi/Properties/AssemblyInfo.cs +++ b/src/Api/PubnubApi/Properties/AssemblyInfo.cs @@ -11,8 +11,8 @@ [assembly: AssemblyProduct("Pubnub C# SDK")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("6.10.0.0")] -[assembly: AssemblyFileVersion("6.10.0.0")] +[assembly: AssemblyVersion("6.11.0.0")] +[assembly: AssemblyFileVersion("6.11.0.0")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. diff --git a/src/Api/PubnubApi/PubnubApi.csproj b/src/Api/PubnubApi/PubnubApi.csproj index c641c881b..014a671e3 100644 --- a/src/Api/PubnubApi/PubnubApi.csproj +++ b/src/Api/PubnubApi/PubnubApi.csproj @@ -13,7 +13,7 @@ Pubnub - 6.10.0.0 + 6.11.0.0 PubNub C# .NET - Web Data Push API Pandu Masabathula PubNub @@ -21,7 +21,8 @@ http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/pubnub-icon-600x600.png true https://github.com/pubnub/c-sharp/ - Add Users/Spaces support to PCL versions. + Added Content-Type to request header to support internal acceptance tests. +Added acceptance tests for ObjectsV2 feature. Web Data Push Real-time Notifications ESB Message Broadcasting Distributed Computing PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously diff --git a/src/Api/PubnubApi/PubnubCoreBase.cs b/src/Api/PubnubApi/PubnubCoreBase.cs index 7ce2c9841..50a759021 100644 --- a/src/Api/PubnubApi/PubnubCoreBase.cs +++ b/src/Api/PubnubApi/PubnubCoreBase.cs @@ -1112,7 +1112,7 @@ internal protected async Task> UrlProcessRequest(Uri } else if (pubnubRequestState != null && pubnubRequestState.UsePatchMethod) { - jsonString = await pubnubHttp.SendRequestAndGetJsonResponseWithPATCH(requestUri, pubnubRequestState, null, postOrPatchData).ConfigureAwait(false); + jsonString = await pubnubHttp.SendRequestAndGetJsonResponseWithPATCH(requestUri, pubnubRequestState, null, postOrPatchData, contentType).ConfigureAwait(false); } else { @@ -1125,7 +1125,7 @@ internal protected async Task> UrlProcessRequest(Uri } else if (pubnubRequestState != null && pubnubRequestState.UsePatchMethod) { - jsonString = await pubnubHttp.SendRequestAndGetJsonResponseWithPATCH(requestUri, pubnubRequestState, request, postOrPatchData).ConfigureAwait(false); + jsonString = await pubnubHttp.SendRequestAndGetJsonResponseWithPATCH(requestUri, pubnubRequestState, request, postOrPatchData, contentType).ConfigureAwait(false); } else { diff --git a/src/Api/PubnubApi/PubnubHttp.cs b/src/Api/PubnubApi/PubnubHttp.cs index 1609210ee..25a5c33c9 100644 --- a/src/Api/PubnubApi/PubnubHttp.cs +++ b/src/Api/PubnubApi/PubnubHttp.cs @@ -148,7 +148,7 @@ async Task IPubnubHttp.SendRequestAndGetJsonResponseWithPOST(Uri requ } } - async Task IPubnubHttp.SendRequestAndGetJsonResponseWithPATCH(Uri requestUri, RequestState pubnubRequestState, HttpWebRequest request, byte[] patchData) + async Task IPubnubHttp.SendRequestAndGetJsonResponseWithPATCH(Uri requestUri, RequestState pubnubRequestState, HttpWebRequest request, byte[] patchData, string contentType) { LoggingMethod.WriteToLog(pubnubLog, string.Format("DateTime: {0}, patchData = {1}", DateTime.Now.ToString(CultureInfo.InvariantCulture), patchData), pubnubConfig.LogVerbosity); if (pubnubConfig.UseClassicHttpWebRequest) @@ -160,14 +160,14 @@ async Task IPubnubHttp.SendRequestAndGetJsonResponseWithPATCH(Uri req #if !NET35 && !NET40 && !NET45 && !NET461 && !NET48 && !NETSTANDARD10 if (pubnubConfig.UseTaskFactoryAsyncInsteadOfHttpClient) { - return await SendRequestAndGetJsonResponseTaskFactoryWithPATCH(pubnubRequestState, request, patchData).ConfigureAwait(false); + return await SendRequestAndGetJsonResponseTaskFactoryWithPATCH(pubnubRequestState, request, patchData, contentType).ConfigureAwait(false); } else { - return await SendRequestAndGetJsonResponseHttpClientWithPATCH(requestUri, pubnubRequestState, patchData).ConfigureAwait(false); + return await SendRequestAndGetJsonResponseHttpClientWithPATCH(requestUri, pubnubRequestState, patchData, contentType).ConfigureAwait(false); } #else - return await SendRequestAndGetJsonResponseTaskFactoryWithPATCH(pubnubRequestState, request, patchData).ConfigureAwait(false); + return await SendRequestAndGetJsonResponseTaskFactoryWithPATCH(pubnubRequestState, request, patchData, contentType).ConfigureAwait(false); #endif } } @@ -447,7 +447,7 @@ async Task SendRequestAndGetJsonResponseHttpClientWithPOST(Uri reques return jsonString; } - async Task SendRequestAndGetJsonResponseHttpClientWithPATCH(Uri requestUri, RequestState pubnubRequestState, byte[] patchData) + async Task SendRequestAndGetJsonResponseHttpClientWithPATCH(Uri requestUri, RequestState pubnubRequestState, byte[] patchData, string contentType) { string jsonString = ""; HttpResponseMessage response = null; @@ -459,9 +459,20 @@ async Task SendRequestAndGetJsonResponseHttpClientWithPATCH(Uri reque System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); HttpMethod httpMethod = new HttpMethod("PATCH"); + ByteArrayContent patchDataContent = new ByteArrayContent(patchData); + patchDataContent.Headers.Remove("Content-Type"); + if (string.IsNullOrEmpty(contentType)) + { + patchDataContent.Headers.TryAddWithoutValidation("Content-Type", "application/json"); + } + else + { + patchDataContent.Headers.TryAddWithoutValidation("Content-Type", contentType); + } + HttpRequestMessage requestMsg = new HttpRequestMessage(httpMethod, requestUri) { - Content = new ByteArrayContent(patchData) + Content = patchDataContent }; if (pubnubRequestState.ResponseType == PNOperationType.PNSubscribeOperation) { @@ -795,7 +806,7 @@ async Task SendRequestAndGetJsonResponseTaskFactoryWithPOST(RequestSt } } - async Task SendRequestAndGetJsonResponseTaskFactoryWithPATCH(RequestState pubnubRequestState, HttpWebRequest request, byte[] patchData) + async Task SendRequestAndGetJsonResponseTaskFactoryWithPATCH(RequestState pubnubRequestState, HttpWebRequest request, byte[] patchData, string contentType) { System.Diagnostics.Debug.WriteLine(string.Format("DateTime {0}, Before Task.Factory.FromAsync With PATCH", DateTime.Now.ToString(CultureInfo.InvariantCulture))); try @@ -807,6 +818,9 @@ async Task SendRequestAndGetJsonResponseTaskFactoryWithPATCH(RequestS stopWatch.Start(); request.ContentType = "application/json"; +#if NET35 || NET40 || NET45 || NET461 || NET48 + request.Headers.Add("Content-Type", string.IsNullOrEmpty(contentType) ? "application/json" : contentType); +#endif using (var requestStream = await Task.Factory.FromAsync(request.BeginGetRequestStream, request.EndGetRequestStream, pubnubRequestState).ConfigureAwait(false)) { diff --git a/src/Api/PubnubApiPCL/PubnubApiPCL.csproj b/src/Api/PubnubApiPCL/PubnubApiPCL.csproj index 2fa8313f3..29debdc70 100644 --- a/src/Api/PubnubApiPCL/PubnubApiPCL.csproj +++ b/src/Api/PubnubApiPCL/PubnubApiPCL.csproj @@ -14,7 +14,7 @@ PubnubPCL - 6.10.0.0 + 6.11.0.0 PubNub C# .NET - Web Data Push API Pandu Masabathula PubNub @@ -22,7 +22,8 @@ http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/pubnub-icon-600x600.png true https://github.com/pubnub/c-sharp/ - Add Users/Spaces support to PCL versions. + Added Content-Type to request header to support internal acceptance tests. +Added acceptance tests for ObjectsV2 feature. Web Data Push Real-time Notifications ESB Message Broadcasting Distributed Computing PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously diff --git a/src/Api/PubnubApiUWP/PubnubApiUWP.csproj b/src/Api/PubnubApiUWP/PubnubApiUWP.csproj index d744c1dc3..b3b186078 100644 --- a/src/Api/PubnubApiUWP/PubnubApiUWP.csproj +++ b/src/Api/PubnubApiUWP/PubnubApiUWP.csproj @@ -15,7 +15,7 @@ PubnubUWP - 6.10.0.0 + 6.11.0.0 PubNub C# .NET - Web Data Push API Pandu Masabathula PubNub @@ -23,7 +23,8 @@ http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/pubnub-icon-600x600.png true https://github.com/pubnub/c-sharp/ - Add Users/Spaces support to PCL versions. + Added Content-Type to request header to support internal acceptance tests. +Added acceptance tests for ObjectsV2 feature. Web Data Push Real-time Notifications ESB Message Broadcasting Distributed Computing PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously diff --git a/src/UnitTests/AcceptanceTests/AcceptanceTests.csproj b/src/UnitTests/AcceptanceTests/AcceptanceTests.csproj index 83341c47f..88b19f749 100644 --- a/src/UnitTests/AcceptanceTests/AcceptanceTests.csproj +++ b/src/UnitTests/AcceptanceTests/AcceptanceTests.csproj @@ -32,10 +32,62 @@ + + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + \ No newline at end of file diff --git a/src/UnitTests/AcceptanceTests/Data/alice.json b/src/UnitTests/AcceptanceTests/Data/alice.json new file mode 100644 index 000000000..c6dc1b5c5 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Data/alice.json @@ -0,0 +1,11 @@ +{ + "name": "Alice", + "email": "alice@example.com", + "externalId": "410b802b-7f18-4a79-b788-f34b7e600cf2", + "profileUrl": "http://fWOkYZQfM.com", + "id": "alice-id", + "updated": "2022-09-16T11:51:53.316718Z", + "type": "admin", + "status": "active", + "eTag": "Afrav42WqsmyZA" +} \ No newline at end of file diff --git a/src/UnitTests/AcceptanceTests/Data/ameliamember.json b/src/UnitTests/AcceptanceTests/Data/ameliamember.json new file mode 100644 index 000000000..af87bc8e2 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Data/ameliamember.json @@ -0,0 +1,9 @@ +{ + "uuid": { + "id": "amelia-id" + }, + "status": null, + "custom": null, + "updated": "2022-10-12T10:57:19.618621Z", + "eTag": "AZO/t53al7m8fw" +} diff --git a/src/UnitTests/AcceptanceTests/Data/bob.json b/src/UnitTests/AcceptanceTests/Data/bob.json new file mode 100644 index 000000000..a269faf1d --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Data/bob.json @@ -0,0 +1,15 @@ +{ + "name": "Bob", + "email": "bob@example.com", + "externalId": "410b802b-7f18-1337-b788-f34b7e600cf2", + "profileUrl": "http://fWOkYZQfX.com", + "id": "bob-id", + "custom": { + "uuid_param1": "val1", + "uuid_param2": "val2" + }, + "type": "participant", + "status": "active", + "updated": "2022-02-22T11:51:53.316718Z", + "eTag": "Afrav42WQsmyZA" +} \ No newline at end of file diff --git a/src/UnitTests/AcceptanceTests/Data/chat.json b/src/UnitTests/AcceptanceTests/Data/chat.json new file mode 100644 index 000000000..adbdd8632 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Data/chat.json @@ -0,0 +1,9 @@ +{ + "name": "Chat", + "id": "chat-id", + "description": "chat-description", + "updated": "2022-09-16T11:51:53.316718Z", + "eTag": "Afrav42WqsmyZA", + "type": "GroupChat", + "status": "active" +} \ No newline at end of file diff --git a/src/UnitTests/AcceptanceTests/Data/chatmembership.json b/src/UnitTests/AcceptanceTests/Data/chatmembership.json new file mode 100644 index 000000000..4cb7e0abe --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Data/chatmembership.json @@ -0,0 +1,15 @@ +{ + "channel": { + "name": "Chat", + "id": "chat-id", + "description": "chat-description", + "updated": "2022-09-16T11:51:53.316718Z", + "eTag": "Afrav42WqsmyZA", + "type": "GroupChat", + "status": "active" + }, + "custom": null, + "updated": "2022-09-16T11:51:53.316718Z", + "eTag": "Afrav42WqsmyZA", + "status": "new channel" +} diff --git a/src/UnitTests/AcceptanceTests/Data/dm.json b/src/UnitTests/AcceptanceTests/Data/dm.json new file mode 100644 index 000000000..cec60fd4b --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Data/dm.json @@ -0,0 +1,13 @@ +{ + "name": "DM", + "id": "dm-id", + "description": "dm-description", + "updated": "2022-09-16T11:51:53.316718Z", + "eTag": "Afrav42WqsmyZA", + "type": "1on1", + "status": "active", + "custom": { + "uuid_param1": "val1", + "uuid_param2": "val2" + } +} \ No newline at end of file diff --git a/src/UnitTests/AcceptanceTests/Data/dmmembership.json b/src/UnitTests/AcceptanceTests/Data/dmmembership.json new file mode 100644 index 000000000..8e874825c --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Data/dmmembership.json @@ -0,0 +1,19 @@ +{ + "channel": { + "name": "DM", + "id": "dm-id", + "description": "dm-description", + "updated": "2022-09-16T11:51:53.316718Z", + "eTag": "Afrav42WqsmyZA", + "type": "1on1", + "status": "active", + "custom": { + "uuid_param1": "val1", + "uuid_param2": "val2" + } + }, + "custom": null, + "updated": "2022-09-16T11:51:53.316718Z", + "eTag": "Afrav42WqsmyZA", + "status": "new channel" +} \ No newline at end of file diff --git a/src/UnitTests/AcceptanceTests/Data/evamember.json b/src/UnitTests/AcceptanceTests/Data/evamember.json new file mode 100644 index 000000000..21b64645d --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Data/evamember.json @@ -0,0 +1,7 @@ +{ + "uuid": { + "id": "eva-id" + }, + "updated": "2022-10-12T11:55:36.951711Z", + "eTag": "AYK2yNHvqNCF/gE" +} diff --git a/src/UnitTests/AcceptanceTests/Data/james.json b/src/UnitTests/AcceptanceTests/Data/james.json new file mode 100644 index 000000000..7b0d22010 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Data/james.json @@ -0,0 +1,11 @@ +{ + "name": "James", + "email": "james@example.com", + "externalId": "410b802b-1111-4a79-b788-f34b7e600cf2", + "profileUrl": "http://fWOkYZQZZ.com", + "id": "james-id", + "type": "participant", + "status": "archived", + "updated": "2022-09-16T11:51:53.316718Z", + "eTag": "Afrav42WqsmyZA" +} \ No newline at end of file diff --git a/src/UnitTests/AcceptanceTests/Data/lisa.json b/src/UnitTests/AcceptanceTests/Data/lisa.json new file mode 100644 index 000000000..92f63f738 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Data/lisa.json @@ -0,0 +1,15 @@ +{ + "name": "Lisa", + "email": "lisa@example.com", + "externalId": "410b802b-7f18-1337-b0b0-f34b7e600cf2", + "profileUrl": "http://fWOkYZQfX.com", + "id": "lisa-id", + "custom": { + "uuid_param1": "val1", + "uuid_param2": "val2" + }, + "type": "participant", + "status": "archived", + "updated": "2022-02-22T11:51:53.316718Z", + "eTag": "Afrav42WQsmyZA" +} \ No newline at end of file diff --git a/src/UnitTests/AcceptanceTests/Data/olivermember.json b/src/UnitTests/AcceptanceTests/Data/olivermember.json new file mode 100644 index 000000000..5dbc81f4c --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Data/olivermember.json @@ -0,0 +1,12 @@ +{ + "uuid": { + "id": "oliver-id" + }, + "status": null, + "custom": { + "members_param1": "val1", + "members_param2": "val2" + }, + "updated": "2022-10-12T11:38:15.89535Z", + "eTag": "AYK2yNHvqNCF/gE" +} diff --git a/src/UnitTests/AcceptanceTests/Data/patient.json b/src/UnitTests/AcceptanceTests/Data/patient.json new file mode 100644 index 000000000..f3191d7d5 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Data/patient.json @@ -0,0 +1,9 @@ +{ + "name": "Patient", + "id": "patient-id", + "description": "patient-description", + "updated": "2022-09-16T11:51:53.316718Z", + "eTag": "Afrav42WqsmyZA", + "type": "PatientChat", + "status": "active" +} \ No newline at end of file diff --git a/src/UnitTests/AcceptanceTests/Data/patientmembership.json b/src/UnitTests/AcceptanceTests/Data/patientmembership.json new file mode 100644 index 000000000..b065b742f --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Data/patientmembership.json @@ -0,0 +1,15 @@ +{ + "channel": { + "name": "Patient", + "id": "patient-id", + "description": "patient-description", + "updated": "2022-09-16T11:51:53.316718Z", + "eTag": "Afrav42WqsmyZA", + "type": "PatientChat", + "status": "active" + }, + "custom": null, + "updated": "2022-09-16T11:51:53.316718Z", + "eTag": "Afrav42WqsmyZA", + "status": "new channel" +} \ No newline at end of file diff --git a/src/UnitTests/AcceptanceTests/Data/petermember.json b/src/UnitTests/AcceptanceTests/Data/petermember.json new file mode 100644 index 000000000..6837b6cff --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Data/petermember.json @@ -0,0 +1,22 @@ +{ + "uuid": { + "id": "peter-id", + "name": "randomName", + "externalId": "randomExternalId", + "profileUrl": "randomProfileUrl", + "email": "randomEmail", + "custom": { + "uuid_param1": "val1", + "uuid_param2": "val2" + }, + "updated": "2022-10-14T10:19:09.36237Z", + "eTag": "Acy78dXh29GnLQ" + }, + "status": null, + "custom": { + "members_param1": "val1", + "members_param2": "val2" + }, + "updated": "2022-10-14T10:29:34.56984Z", + "eTag": "AZO/t53al7m8fw" +} \ No newline at end of file diff --git a/src/UnitTests/AcceptanceTests/Data/vipchat.json b/src/UnitTests/AcceptanceTests/Data/vipchat.json new file mode 100644 index 000000000..b072bff1d --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Data/vipchat.json @@ -0,0 +1,13 @@ +{ + "name": "VIP", + "id": "vipchat-id", + "description": "vipchat-description", + "updated": "2022-09-16T11:51:53.316718Z", + "eTag": "Afrav42WqsmyZA", + "type": "VipChat", + "status": "active", + "custom": { + "uuid_param1": "val1", + "uuid_param2": "val2" + } +} \ No newline at end of file diff --git a/src/UnitTests/AcceptanceTests/Data/vipchatmembership.json b/src/UnitTests/AcceptanceTests/Data/vipchatmembership.json new file mode 100644 index 000000000..ed8a1cdec --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Data/vipchatmembership.json @@ -0,0 +1,22 @@ +{ + "channel": { + "name": "VIP", + "id": "vipchat-id", + "description": "vipchat-description", + "updated": "2022-09-16T11:51:53.316718Z", + "eTag": "Afrav42WqsmyZA", + "type": "VipChat", + "status": "active", + "custom": { + "uuid_param1": "val1", + "uuid_param2": "val2" + } + }, + "custom": { + "uuid_param1": "val1", + "uuid_param2": "val2" + }, + "updated": "2022-09-16T11:51:53.316718Z", + "eTag": "Afrav42WqsmyZA", + "status": "new channel" +} \ No newline at end of file diff --git a/src/UnitTests/AcceptanceTests/Features/channel-metadata.feature b/src/UnitTests/AcceptanceTests/Features/channel-metadata.feature new file mode 100644 index 000000000..7b8bef863 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/channel-metadata.feature @@ -0,0 +1,45 @@ +@featureSet=objectsV2 @beta +Feature: Objects V2 Channel metadata + As a PubNub customer I want to create, update, remove channels. + + Background: + Given I have a keyset with Objects V2 enabled + + @contract=getChannelMetadataOfChat + Scenario: Get a channel metadata for id + Given the id for 'Chat' channel + When I get the channel metadata + Then I receive a successful response + And the channel metadata for 'Chat' channel + + @contract=getChannelMetadataOfDMWithCustom + Scenario: Get a channel with custom metadata + Given the id for 'DM' channel + When I get the channel metadata with custom + Then I receive a successful response + And the channel metadata for 'DM' channel + + @contract=setChannelMetadataForChat + Scenario: Set a channel metadata + Given the data for 'Chat' channel + When I set the channel metadata + Then I receive a successful response + And the channel metadata for 'Chat' channel contains updated + + @contract=removeChannelMetadataOfChat + Scenario: Remove a channel metadata for id + Given the id for 'Chat' channel + When I remove the channel metadata + Then I receive a successful response + + @contract=getAllChannelMetadata + Scenario: Get all channel metadata + When I get all channel metadata + Then I receive a successful response + And the response contains list with 'Chat' and 'Patient' channel metadata + + @contract=getAllChannelMetadataWithCustom + Scenario: Get all channel metadata with custom + When I get all channel metadata with custom + Then I receive a successful response + And the response contains list with 'DM' and 'VipChat' channel metadata diff --git a/src/UnitTests/AcceptanceTests/Features/channel-metadata.feature.cs b/src/UnitTests/AcceptanceTests/Features/channel-metadata.feature.cs new file mode 100644 index 000000000..93206af86 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/channel-metadata.feature.cs @@ -0,0 +1,372 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (https://www.specflow.org/). +// SpecFlow Version:3.9.0.0 +// SpecFlow Generator Version:3.9.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +#region Designer generated code +#pragma warning disable +namespace AcceptanceTests.Features +{ + using TechTalk.SpecFlow; + using System; + using System.Linq; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.9.0.0")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [NUnit.Framework.TestFixtureAttribute()] + [NUnit.Framework.DescriptionAttribute("Objects V2 Channel metadata")] + [NUnit.Framework.CategoryAttribute("featureSet=objectsV2")] + [NUnit.Framework.CategoryAttribute("beta")] + public partial class ObjectsV2ChannelMetadataFeature + { + + private TechTalk.SpecFlow.ITestRunner testRunner; + + private string[] _featureTags = new string[] { + "featureSet=objectsV2", + "beta"}; + +#line 1 "channel-metadata.feature" +#line hidden + + [NUnit.Framework.OneTimeSetUpAttribute()] + public virtual void FeatureSetup() + { + testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); + TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Features", "Objects V2 Channel metadata", " As a PubNub customer I want to create, update, remove channels.", ProgrammingLanguage.CSharp, new string[] { + "featureSet=objectsV2", + "beta"}); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.OneTimeTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public virtual void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public virtual void TestTearDown() + { + testRunner.OnScenarioEnd(); + } + + public virtual void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioInitialize(scenarioInfo); + testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); + } + + public virtual void ScenarioStart() + { + testRunner.OnScenarioStart(); + } + + public virtual void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + public virtual void FeatureBackground() + { +#line 5 + #line hidden +#line 6 + testRunner.Given("I have a keyset with Objects V2 enabled", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Get a channel metadata for id")] + [NUnit.Framework.CategoryAttribute("contract=getChannelMetadataOfChat")] + public virtual void GetAChannelMetadataForId() + { + string[] tagsOfScenario = new string[] { + "contract=getChannelMetadataOfChat"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get a channel metadata for id", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 9 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 10 + testRunner.Given("the id for \'Chat\' channel", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 11 + testRunner.When("I get the channel metadata", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 12 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 13 + testRunner.And("the channel metadata for \'Chat\' channel", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Get a channel with custom metadata")] + [NUnit.Framework.CategoryAttribute("contract=getChannelMetadataOfDMWithCustom")] + public virtual void GetAChannelWithCustomMetadata() + { + string[] tagsOfScenario = new string[] { + "contract=getChannelMetadataOfDMWithCustom"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get a channel with custom metadata", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 16 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 17 + testRunner.Given("the id for \'DM\' channel", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 18 + testRunner.When("I get the channel metadata with custom", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 19 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 20 + testRunner.And("the channel metadata for \'DM\' channel", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Set a channel metadata")] + [NUnit.Framework.CategoryAttribute("contract=setChannelMetadataForChat")] + public virtual void SetAChannelMetadata() + { + string[] tagsOfScenario = new string[] { + "contract=setChannelMetadataForChat"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Set a channel metadata", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 23 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 24 + testRunner.Given("the data for \'Chat\' channel", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 25 + testRunner.When("I set the channel metadata", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 26 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 27 + testRunner.And("the channel metadata for \'Chat\' channel contains updated", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Remove a channel metadata for id")] + [NUnit.Framework.CategoryAttribute("contract=removeChannelMetadataOfChat")] + public virtual void RemoveAChannelMetadataForId() + { + string[] tagsOfScenario = new string[] { + "contract=removeChannelMetadataOfChat"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Remove a channel metadata for id", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 30 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 31 + testRunner.Given("the id for \'Chat\' channel", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 32 + testRunner.When("I remove the channel metadata", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 33 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Get all channel metadata")] + [NUnit.Framework.CategoryAttribute("contract=getAllChannelMetadata")] + public virtual void GetAllChannelMetadata() + { + string[] tagsOfScenario = new string[] { + "contract=getAllChannelMetadata"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get all channel metadata", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 36 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 37 + testRunner.When("I get all channel metadata", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 38 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 39 + testRunner.And("the response contains list with \'Chat\' and \'Patient\' channel metadata", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Get all channel metadata with custom")] + [NUnit.Framework.CategoryAttribute("contract=getAllChannelMetadataWithCustom")] + public virtual void GetAllChannelMetadataWithCustom() + { + string[] tagsOfScenario = new string[] { + "contract=getAllChannelMetadataWithCustom"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get all channel metadata with custom", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 42 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 43 + testRunner.When("I get all channel metadata with custom", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 44 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 45 + testRunner.And("the response contains list with \'DM\' and \'VipChat\' channel metadata", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/src/UnitTests/AcceptanceTests/Features/members-metadata.feature b/src/UnitTests/AcceptanceTests/Features/members-metadata.feature new file mode 100644 index 000000000..d65307bad --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/members-metadata.feature @@ -0,0 +1,53 @@ +@featureSet=objectsV2 @beta +Feature: Objects V2 Members + As a PubNub customer I want to create, get, remove and update channel members(UUIDs). + + Background: + Given I have a keyset with Objects V2 enabled + + @contract=getMembersOfChatChannel + Scenario: Get members for a channel + Given the id for 'Chat' channel + When I get the channel members + Then I receive a successful response + And the response contains list with 'AmeliaMember' and 'EvaMember' members + + @contract=getMembersOfVipChatChannelWithCustomAndUuidWithCustom + Scenario: Get members for VipChat channel with custom and UUID with custom + Given the id for 'VipChat' channel + When I get the channel members including custom and UUID custom information + Then I receive a successful response + And the response contains list with 'OliverMember' and 'PeterMember' members + + @contract=setMembersForChatChannel + Scenario: Set member for a channel + Given the data for 'AmeliaMember' member + And the id for 'Chat' channel + When I set a channel member + Then I receive a successful response + And the response contains list with 'AmeliaMember' member + + @contract=setMembersForChatChannelWithCustomAndUuidWithCustom + Scenario: Set member with custom for a channel and UUID with custom + Given the data for 'PeterMember' member + And the id for 'Chat' channel + When I set a channel member including custom and UUID with custom + Then I receive a successful response + And the response contains list with 'PeterMember' member + + @contract=removeMembersForChatChannel + Scenario: Remove member for a channel + Given the id for 'Chat' channel + And the data for 'AmeliaMember' member that we want to remove + When I remove a channel member + Then I receive a successful response + + @contract=manageMembersForChatChannel @na=ruby @na=js + Scenario: Manage members for a channel + Given the data for 'PeterMember' member + And the data for 'AmeliaMember' member that we want to remove + And the id for 'Chat' channel + When I manage channel members + Then I receive a successful response + And the response contains list with 'PeterMember' member + And the response does not contain list with 'AmeliaMember' member diff --git a/src/UnitTests/AcceptanceTests/Features/members-metadata.feature.cs b/src/UnitTests/AcceptanceTests/Features/members-metadata.feature.cs new file mode 100644 index 000000000..9cfab7e41 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/members-metadata.feature.cs @@ -0,0 +1,401 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (https://www.specflow.org/). +// SpecFlow Version:3.9.0.0 +// SpecFlow Generator Version:3.9.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +#region Designer generated code +#pragma warning disable +namespace AcceptanceTests.Features +{ + using TechTalk.SpecFlow; + using System; + using System.Linq; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.9.0.0")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [NUnit.Framework.TestFixtureAttribute()] + [NUnit.Framework.DescriptionAttribute("Objects V2 Members")] + [NUnit.Framework.CategoryAttribute("featureSet=objectsV2")] + [NUnit.Framework.CategoryAttribute("beta")] + public partial class ObjectsV2MembersFeature + { + + private TechTalk.SpecFlow.ITestRunner testRunner; + + private string[] _featureTags = new string[] { + "featureSet=objectsV2", + "beta"}; + +#line 1 "members-metadata.feature" +#line hidden + + [NUnit.Framework.OneTimeSetUpAttribute()] + public virtual void FeatureSetup() + { + testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); + TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Features", "Objects V2 Members", " As a PubNub customer I want to create, get, remove and update channel members(U" + + "UIDs).", ProgrammingLanguage.CSharp, new string[] { + "featureSet=objectsV2", + "beta"}); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.OneTimeTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public virtual void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public virtual void TestTearDown() + { + testRunner.OnScenarioEnd(); + } + + public virtual void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioInitialize(scenarioInfo); + testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); + } + + public virtual void ScenarioStart() + { + testRunner.OnScenarioStart(); + } + + public virtual void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + public virtual void FeatureBackground() + { +#line 5 + #line hidden +#line 6 + testRunner.Given("I have a keyset with Objects V2 enabled", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Get members for a channel")] + [NUnit.Framework.CategoryAttribute("contract=getMembersOfChatChannel")] + public virtual void GetMembersForAChannel() + { + string[] tagsOfScenario = new string[] { + "contract=getMembersOfChatChannel"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get members for a channel", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 9 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 10 + testRunner.Given("the id for \'Chat\' channel", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 11 + testRunner.When("I get the channel members", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 12 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 13 + testRunner.And("the response contains list with \'AmeliaMember\' and \'EvaMember\' members", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Get members for VipChat channel with custom and UUID with custom")] + [NUnit.Framework.CategoryAttribute("contract=getMembersOfVipChatChannelWithCustomAndUuidWithCustom")] + public virtual void GetMembersForVipChatChannelWithCustomAndUUIDWithCustom() + { + string[] tagsOfScenario = new string[] { + "contract=getMembersOfVipChatChannelWithCustomAndUuidWithCustom"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get members for VipChat channel with custom and UUID with custom", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 16 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 17 + testRunner.Given("the id for \'VipChat\' channel", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 18 + testRunner.When("I get the channel members including custom and UUID custom information", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 19 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 20 + testRunner.And("the response contains list with \'OliverMember\' and \'PeterMember\' members", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Set member for a channel")] + [NUnit.Framework.CategoryAttribute("contract=setMembersForChatChannel")] + public virtual void SetMemberForAChannel() + { + string[] tagsOfScenario = new string[] { + "contract=setMembersForChatChannel"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Set member for a channel", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 23 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 24 + testRunner.Given("the data for \'AmeliaMember\' member", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 25 + testRunner.And("the id for \'Chat\' channel", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden +#line 26 + testRunner.When("I set a channel member", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 27 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 28 + testRunner.And("the response contains list with \'AmeliaMember\' member", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Set member with custom for a channel and UUID with custom")] + [NUnit.Framework.CategoryAttribute("contract=setMembersForChatChannelWithCustomAndUuidWithCustom")] + public virtual void SetMemberWithCustomForAChannelAndUUIDWithCustom() + { + string[] tagsOfScenario = new string[] { + "contract=setMembersForChatChannelWithCustomAndUuidWithCustom"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Set member with custom for a channel and UUID with custom", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 31 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 32 + testRunner.Given("the data for \'PeterMember\' member", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 33 + testRunner.And("the id for \'Chat\' channel", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden +#line 34 + testRunner.When("I set a channel member including custom and UUID with custom", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 35 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 36 + testRunner.And("the response contains list with \'PeterMember\' member", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Remove member for a channel")] + [NUnit.Framework.CategoryAttribute("contract=removeMembersForChatChannel")] + public virtual void RemoveMemberForAChannel() + { + string[] tagsOfScenario = new string[] { + "contract=removeMembersForChatChannel"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Remove member for a channel", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 39 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 40 + testRunner.Given("the id for \'Chat\' channel", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 41 + testRunner.And("the data for \'AmeliaMember\' member that we want to remove", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden +#line 42 + testRunner.When("I remove a channel member", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 43 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Manage members for a channel")] + [NUnit.Framework.CategoryAttribute("contract=manageMembersForChatChannel")] + [NUnit.Framework.CategoryAttribute("na=ruby")] + [NUnit.Framework.CategoryAttribute("na=js")] + public virtual void ManageMembersForAChannel() + { + string[] tagsOfScenario = new string[] { + "contract=manageMembersForChatChannel", + "na=ruby", + "na=js"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Manage members for a channel", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 46 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 47 + testRunner.Given("the data for \'PeterMember\' member", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 48 + testRunner.And("the data for \'AmeliaMember\' member that we want to remove", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden +#line 49 + testRunner.And("the id for \'Chat\' channel", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden +#line 50 + testRunner.When("I manage channel members", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 51 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 52 + testRunner.And("the response contains list with \'PeterMember\' member", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden +#line 53 + testRunner.And("the response does not contain list with \'AmeliaMember\' member", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/src/UnitTests/AcceptanceTests/Features/membership-metadata.feature b/src/UnitTests/AcceptanceTests/Features/membership-metadata.feature new file mode 100644 index 000000000..f75038e41 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/membership-metadata.feature @@ -0,0 +1,67 @@ +@featureSet=objectsV2 @beta +Feature: Objects V2 Memberships + As a PubNub customer I want to create, update, remove channels. + + Background: + Given I have a keyset with Objects V2 enabled + + @contract=getAliceMemberships + Scenario: Get memberships for UUID + Given the id for 'Alice' persona + When I get the memberships + Then I receive a successful response + And the response contains list with 'ChatMembership' and 'PatientMembership' memberships + + @contract=getAliceMemberships + Scenario: Get memberships for current user + Given current user is 'Alice' persona + When I get the memberships for current user + Then I receive a successful response + And the response contains list with 'ChatMembership' and 'PatientMembership' memberships + + @contract=getBobMembershipWithCustomAndChannelCustom + Scenario: Get memberships for UUID with custom and channel custom + Given the id for 'Bob' persona + When I get the memberships including custom and channel custom information + Then I receive a successful response + And the response contains list with 'VipChatMembership' and 'DMMembership' memberships + + @contract=setAliceMembership + Scenario: Set membership + Given the id for 'Alice' persona + And the data for 'ChatMembership' membership + When I set the membership + Then I receive a successful response + And the response contains list with 'ChatMembership' membership + + @contract=setAliceMembership + Scenario: Set membership for current user + Given current user is 'Alice' persona + And the data for 'ChatMembership' membership + When I set the membership for current user + Then I receive a successful response + And the response contains list with 'ChatMembership' membership + + @contract=removeAliceMembership + Scenario: Remove membership + Given the id for 'Alice' persona + And the data for 'ChatMembership' membership + When I remove the membership + Then I receive a successful response + + @contract=removeAliceMembership + Scenario: Remove membership for current user + Given current user is 'Alice' persona + And the data for 'ChatMembership' membership that we want to remove + When I remove the membership for current user + Then I receive a successful response + + @contract=manageAliceMemberships + Scenario: Manage memberships for a UUID + Given the id for 'Alice' persona + And the data for 'ChatMembership' membership + And the data for 'PatientMembership' membership that we want to remove + When I manage memberships + Then I receive a successful response + And the response contains list with 'ChatMembership' membership + And the response does not contain list with 'PatientMembership' membership diff --git a/src/UnitTests/AcceptanceTests/Features/membership-metadata.feature.cs b/src/UnitTests/AcceptanceTests/Features/membership-metadata.feature.cs new file mode 100644 index 000000000..95db4c1c9 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/membership-metadata.feature.cs @@ -0,0 +1,495 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (https://www.specflow.org/). +// SpecFlow Version:3.9.0.0 +// SpecFlow Generator Version:3.9.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +#region Designer generated code +#pragma warning disable +namespace AcceptanceTests.Features +{ + using TechTalk.SpecFlow; + using System; + using System.Linq; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.9.0.0")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [NUnit.Framework.TestFixtureAttribute()] + [NUnit.Framework.DescriptionAttribute("Objects V2 Memberships")] + [NUnit.Framework.CategoryAttribute("featureSet=objectsV2")] + [NUnit.Framework.CategoryAttribute("beta")] + public partial class ObjectsV2MembershipsFeature + { + + private TechTalk.SpecFlow.ITestRunner testRunner; + + private string[] _featureTags = new string[] { + "featureSet=objectsV2", + "beta"}; + +#line 1 "membership-metadata.feature" +#line hidden + + [NUnit.Framework.OneTimeSetUpAttribute()] + public virtual void FeatureSetup() + { + testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); + TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Features", "Objects V2 Memberships", " As a PubNub customer I want to create, update, remove channels.", ProgrammingLanguage.CSharp, new string[] { + "featureSet=objectsV2", + "beta"}); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.OneTimeTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public virtual void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public virtual void TestTearDown() + { + testRunner.OnScenarioEnd(); + } + + public virtual void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioInitialize(scenarioInfo); + testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); + } + + public virtual void ScenarioStart() + { + testRunner.OnScenarioStart(); + } + + public virtual void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + public virtual void FeatureBackground() + { +#line 5 + #line hidden +#line 6 + testRunner.Given("I have a keyset with Objects V2 enabled", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Get memberships for UUID")] + [NUnit.Framework.CategoryAttribute("contract=getAliceMemberships")] + public virtual void GetMembershipsForUUID() + { + string[] tagsOfScenario = new string[] { + "contract=getAliceMemberships"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get memberships for UUID", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 9 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 10 + testRunner.Given("the id for \'Alice\' persona", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 11 + testRunner.When("I get the memberships", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 12 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 13 + testRunner.And("the response contains list with \'ChatMembership\' and \'PatientMembership\' membersh" + + "ips", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Get memberships for current user")] + [NUnit.Framework.CategoryAttribute("contract=getAliceMemberships")] + public virtual void GetMembershipsForCurrentUser() + { + string[] tagsOfScenario = new string[] { + "contract=getAliceMemberships"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get memberships for current user", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 16 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 17 + testRunner.Given("current user is \'Alice\' persona", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 18 + testRunner.When("I get the memberships for current user", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 19 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 20 + testRunner.And("the response contains list with \'ChatMembership\' and \'PatientMembership\' membersh" + + "ips", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Get memberships for UUID with custom and channel custom")] + [NUnit.Framework.CategoryAttribute("contract=getBobMembershipWithCustomAndChannelCustom")] + public virtual void GetMembershipsForUUIDWithCustomAndChannelCustom() + { + string[] tagsOfScenario = new string[] { + "contract=getBobMembershipWithCustomAndChannelCustom"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get memberships for UUID with custom and channel custom", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 23 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 24 + testRunner.Given("the id for \'Bob\' persona", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 25 + testRunner.When("I get the memberships including custom and channel custom information", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 26 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 27 + testRunner.And("the response contains list with \'VipChatMembership\' and \'DMMembership\' membership" + + "s", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Set membership")] + [NUnit.Framework.CategoryAttribute("contract=setAliceMembership")] + public virtual void SetMembership() + { + string[] tagsOfScenario = new string[] { + "contract=setAliceMembership"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Set membership", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 30 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 31 + testRunner.Given("the id for \'Alice\' persona", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 32 + testRunner.And("the data for \'ChatMembership\' membership", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden +#line 33 + testRunner.When("I set the membership", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 34 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 35 + testRunner.And("the response contains list with \'ChatMembership\' membership", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Set membership for current user")] + [NUnit.Framework.CategoryAttribute("contract=setAliceMembership")] + public virtual void SetMembershipForCurrentUser() + { + string[] tagsOfScenario = new string[] { + "contract=setAliceMembership"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Set membership for current user", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 38 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 39 + testRunner.Given("current user is \'Alice\' persona", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 40 + testRunner.And("the data for \'ChatMembership\' membership", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden +#line 41 + testRunner.When("I set the membership for current user", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 42 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 43 + testRunner.And("the response contains list with \'ChatMembership\' membership", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Remove membership")] + [NUnit.Framework.CategoryAttribute("contract=removeAliceMembership")] + public virtual void RemoveMembership() + { + string[] tagsOfScenario = new string[] { + "contract=removeAliceMembership"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Remove membership", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 46 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 47 + testRunner.Given("the id for \'Alice\' persona", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 48 + testRunner.And("the data for \'ChatMembership\' membership", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden +#line 49 + testRunner.When("I remove the membership", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 50 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Remove membership for current user")] + [NUnit.Framework.CategoryAttribute("contract=removeAliceMembership")] + public virtual void RemoveMembershipForCurrentUser() + { + string[] tagsOfScenario = new string[] { + "contract=removeAliceMembership"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Remove membership for current user", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 53 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 54 + testRunner.Given("current user is \'Alice\' persona", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 55 + testRunner.And("the data for \'ChatMembership\' membership that we want to remove", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden +#line 56 + testRunner.When("I remove the membership for current user", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 57 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Manage memberships for a UUID")] + [NUnit.Framework.CategoryAttribute("contract=manageAliceMemberships")] + public virtual void ManageMembershipsForAUUID() + { + string[] tagsOfScenario = new string[] { + "contract=manageAliceMemberships"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Manage memberships for a UUID", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 60 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 61 + testRunner.Given("the id for \'Alice\' persona", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 62 + testRunner.And("the data for \'ChatMembership\' membership", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden +#line 63 + testRunner.And("the data for \'PatientMembership\' membership that we want to remove", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden +#line 64 + testRunner.When("I manage memberships", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 65 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 66 + testRunner.And("the response contains list with \'ChatMembership\' membership", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden +#line 67 + testRunner.And("the response does not contain list with \'PatientMembership\' membership", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/src/UnitTests/AcceptanceTests/Features/uuid-metadata.feature b/src/UnitTests/AcceptanceTests/Features/uuid-metadata.feature new file mode 100644 index 000000000..5182b0b63 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/uuid-metadata.feature @@ -0,0 +1,51 @@ +@featureSet=objectsV2 @beta +Feature: Objects V2 UUID metadata + As a PubNub customer I want to create, update, remove uuids. + + Background: + Given I have a keyset with Objects V2 enabled + + @contract=getUUIDMetadataOfAlice + Scenario: Get a UUID metadata for id + Given the id for 'Alice' persona + When I get the UUID metadata + Then I receive a successful response + And the UUID metadata for 'Alice' persona + + @contract=getUUIDMetadataOfBobWithCustom + Scenario: Get a UUID with custom metadata, id stored in config + Given current user is 'Bob' persona + When I get the UUID metadata with custom for current user + Then I receive a successful response + And the UUID metadata for 'Bob' persona + + @contract=setUUIDMetadataForAlice + Scenario: Set a UUID metadata + Given the data for 'Alice' persona + When I set the UUID metadata + Then I receive a successful response + And the UUID metadata for 'Alice' persona contains updated + + @contract=removeUUIDMetadataOfAlice + Scenario: Remove a UUID metadata for id + Given the id for 'Alice' persona + When I remove the UUID metadata + Then I receive a successful response + + @contract=removeUUIDMetadataOfAlice + Scenario: Remove a UUID metadata, id stored in config + Given current user is 'Alice' persona + When I remove the UUID metadata for current user + Then I receive a successful response + + @contract=getAllUUIDMetadata + Scenario: Get all UUID metadata + When I get all UUID metadata + Then I receive a successful response + And the response contains list with 'Alice' and 'James' UUID metadata + + @contract=getAllUUIDMetadataWithCustom + Scenario: Get all UUID metadata with custom + When I get all UUID metadata with custom + Then I receive a successful response + And the response contains list with 'Bob' and 'Lisa' UUID metadata diff --git a/src/UnitTests/AcceptanceTests/Features/uuid-metadata.feature.cs b/src/UnitTests/AcceptanceTests/Features/uuid-metadata.feature.cs new file mode 100644 index 000000000..25e3dae05 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/uuid-metadata.feature.cs @@ -0,0 +1,417 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (https://www.specflow.org/). +// SpecFlow Version:3.9.0.0 +// SpecFlow Generator Version:3.9.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +#region Designer generated code +#pragma warning disable +namespace AcceptanceTests.Features +{ + using TechTalk.SpecFlow; + using System; + using System.Linq; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.9.0.0")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [NUnit.Framework.TestFixtureAttribute()] + [NUnit.Framework.DescriptionAttribute("Objects V2 UUID metadata")] + [NUnit.Framework.CategoryAttribute("featureSet=objectsV2")] + [NUnit.Framework.CategoryAttribute("beta")] + public partial class ObjectsV2UUIDMetadataFeature + { + + private TechTalk.SpecFlow.ITestRunner testRunner; + + private string[] _featureTags = new string[] { + "featureSet=objectsV2", + "beta"}; + +#line 1 "uuid-metadata.feature" +#line hidden + + [NUnit.Framework.OneTimeSetUpAttribute()] + public virtual void FeatureSetup() + { + testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); + TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Features", "Objects V2 UUID metadata", " As a PubNub customer I want to create, update, remove uuids.", ProgrammingLanguage.CSharp, new string[] { + "featureSet=objectsV2", + "beta"}); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.OneTimeTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public virtual void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public virtual void TestTearDown() + { + testRunner.OnScenarioEnd(); + } + + public virtual void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioInitialize(scenarioInfo); + testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); + } + + public virtual void ScenarioStart() + { + testRunner.OnScenarioStart(); + } + + public virtual void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + public virtual void FeatureBackground() + { +#line 5 + #line hidden +#line 6 + testRunner.Given("I have a keyset with Objects V2 enabled", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Get a UUID metadata for id")] + [NUnit.Framework.CategoryAttribute("contract=getUUIDMetadataOfAlice")] + public virtual void GetAUUIDMetadataForId() + { + string[] tagsOfScenario = new string[] { + "contract=getUUIDMetadataOfAlice"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get a UUID metadata for id", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 9 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 10 + testRunner.Given("the id for \'Alice\' persona", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 11 + testRunner.When("I get the UUID metadata", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 12 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 13 + testRunner.And("the UUID metadata for \'Alice\' persona", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Get a UUID with custom metadata, id stored in config")] + [NUnit.Framework.CategoryAttribute("contract=getUUIDMetadataOfBobWithCustom")] + public virtual void GetAUUIDWithCustomMetadataIdStoredInConfig() + { + string[] tagsOfScenario = new string[] { + "contract=getUUIDMetadataOfBobWithCustom"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get a UUID with custom metadata, id stored in config", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 16 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 17 + testRunner.Given("current user is \'Bob\' persona", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 18 + testRunner.When("I get the UUID metadata with custom for current user", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 19 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 20 + testRunner.And("the UUID metadata for \'Bob\' persona", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Set a UUID metadata")] + [NUnit.Framework.CategoryAttribute("contract=setUUIDMetadataForAlice")] + public virtual void SetAUUIDMetadata() + { + string[] tagsOfScenario = new string[] { + "contract=setUUIDMetadataForAlice"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Set a UUID metadata", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 23 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 24 + testRunner.Given("the data for \'Alice\' persona", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 25 + testRunner.When("I set the UUID metadata", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 26 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 27 + testRunner.And("the UUID metadata for \'Alice\' persona contains updated", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Remove a UUID metadata for id")] + [NUnit.Framework.CategoryAttribute("contract=removeUUIDMetadataOfAlice")] + public virtual void RemoveAUUIDMetadataForId() + { + string[] tagsOfScenario = new string[] { + "contract=removeUUIDMetadataOfAlice"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Remove a UUID metadata for id", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 30 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 31 + testRunner.Given("the id for \'Alice\' persona", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 32 + testRunner.When("I remove the UUID metadata", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 33 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Remove a UUID metadata, id stored in config")] + [NUnit.Framework.CategoryAttribute("contract=removeUUIDMetadataOfAlice")] + public virtual void RemoveAUUIDMetadataIdStoredInConfig() + { + string[] tagsOfScenario = new string[] { + "contract=removeUUIDMetadataOfAlice"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Remove a UUID metadata, id stored in config", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 36 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 37 + testRunner.Given("current user is \'Alice\' persona", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 38 + testRunner.When("I remove the UUID metadata for current user", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 39 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Get all UUID metadata")] + [NUnit.Framework.CategoryAttribute("contract=getAllUUIDMetadata")] + public virtual void GetAllUUIDMetadata() + { + string[] tagsOfScenario = new string[] { + "contract=getAllUUIDMetadata"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get all UUID metadata", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 42 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 43 + testRunner.When("I get all UUID metadata", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 44 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 45 + testRunner.And("the response contains list with \'Alice\' and \'James\' UUID metadata", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Get all UUID metadata with custom")] + [NUnit.Framework.CategoryAttribute("contract=getAllUUIDMetadataWithCustom")] + public virtual void GetAllUUIDMetadataWithCustom() + { + string[] tagsOfScenario = new string[] { + "contract=getAllUUIDMetadataWithCustom"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get all UUID metadata with custom", null, tagsOfScenario, argumentsOfScenario, this._featureTags); +#line 48 + this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 5 + this.FeatureBackground(); +#line hidden +#line 49 + testRunner.When("I get all UUID metadata with custom", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 50 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 51 + testRunner.And("the response contains list with \'Bob\' and \'Lisa\' UUID metadata", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/src/UnitTests/AcceptanceTests/Steps/GrantTokenSteps.cs b/src/UnitTests/AcceptanceTests/Steps/GrantTokenSteps.cs index 20c8735c7..bd907c950 100644 --- a/src/UnitTests/AcceptanceTests/Steps/GrantTokenSteps.cs +++ b/src/UnitTests/AcceptanceTests/Steps/GrantTokenSteps.cs @@ -14,6 +14,7 @@ namespace AcceptanceTests.Steps public partial class FeatureAccessSteps { public static string currentFeature = string.Empty; + public static string currentContract = string.Empty; public static bool betaVersion = false; private string acceptance_test_origin = "localhost:8090"; private bool bypassMockServer = false; @@ -112,7 +113,7 @@ public static void AfterFeature(FeatureContext featureContext) [BeforeScenario()] public void BeforeScenario() { - string currentContract = ""; + currentContract = ""; if (_scenarioContext.ScenarioInfo != null && _scenarioContext.ScenarioInfo.Tags.Length > 0) { List tagList = _scenarioContext.ScenarioInfo.Tags.AsEnumerable().ToList(); diff --git a/src/UnitTests/AcceptanceTests/Steps/ObjectsV2ChannelMetadataSteps.cs b/src/UnitTests/AcceptanceTests/Steps/ObjectsV2ChannelMetadataSteps.cs new file mode 100644 index 000000000..2bf119fc5 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Steps/ObjectsV2ChannelMetadataSteps.cs @@ -0,0 +1,238 @@ +using System; +using TechTalk.SpecFlow; +using PubnubApi; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using NUnit.Framework; +using System.Net; +using System.Globalization; +using System.IO; +using System.Text.Json; + +namespace AcceptanceTests.Steps +{ + public partial class FeatureObjectsV2MetadataSteps + { + private ChannelMetadataPersona channelMetadataPersona = null; + private PNGetChannelMetadataResult getChannelMetadataResult = null; + private PNSetChannelMetadataResult setChannelMetadataResult = null; + private PNGetAllChannelMetadataResult getAllChannelMetadataResult = null; + + internal class ChannelMetadataPersona + { + public string name { get; set; } + public string id { get; set; } + public string description { get; set; } + public string updated { get; set; } + public string eTag { get; set; } + public Dictionary custom {get; set;} + } + + [Given(@"the id for '([^']*)' channel")] + public void GivenTheIdForChannel(string personaName) + { + channelMetadataPersona = null; + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string personaFile = string.Format("{0}.json", personaName.ToLower()); + var personaFilePath = Path.Combine(dirPath, "Data", personaFile); + if (File.Exists(personaFilePath) && File.Exists(personaFilePath)) + { + using (StreamReader r = new StreamReader(personaFilePath)) + { + string json = r.ReadToEnd(); + channelMetadataPersona = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + } + } + } + + [When(@"I get the channel metadata")] + public async Task WhenIGetTheChannelMetadata() + { + PNResult getChannelMetadataResponse = await pn.GetChannelMetadata() + .Channel(channelMetadataPersona.id) + .ExecuteAsync(); + getChannelMetadataResult = getChannelMetadataResponse.Result; + pnStatus = getChannelMetadataResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [Then(@"the channel metadata for '([^']*)' channel")] + public void ThenTheChannelMetadataForChannel(string personaName) + { + Assert.AreEqual(channelMetadataPersona.name, getChannelMetadataResult.Name); + Assert.AreEqual(channelMetadataPersona.id, getChannelMetadataResult.Channel); + Assert.AreEqual(channelMetadataPersona.description, getChannelMetadataResult.Description); + Assert.AreEqual(channelMetadataPersona.updated, getChannelMetadataResult.Updated); + + if (string.Compare(personaName, "chat", true) == 0) + { + Assert.AreEqual(channelMetadataPersona.custom, getChannelMetadataResult.Custom); + } + else if (string.Compare(personaName, "dm", true) == 0) + { + Assert.AreEqual(channelMetadataPersona.custom.Count, getChannelMetadataResult.Custom.Count); + } + else + { + Assert.Fail("TEST MISMATCH", personaName); + } + } + + [When(@"I get the channel metadata with custom")] + public async Task WhenIGetTheChannelMetadataWithCustom() + { + PNResult getChannelMetadataResponse = await pn.GetChannelMetadata() + .Channel(channelMetadataPersona.id) + .IncludeCustom(true) + .ExecuteAsync(); + getChannelMetadataResult = getChannelMetadataResponse.Result; + pnStatus = getChannelMetadataResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [Given(@"the data for '([^']*)' channel")] + public void GivenTheDataForChannel(string personaName) + { + channelMetadataPersona = null; + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string personaFile = string.Format("{0}.json", personaName.ToLower()); + var personaFilePath = Path.Combine(dirPath, "Data", personaFile); + if (File.Exists(personaFilePath) && File.Exists(personaFilePath)) + { + using (StreamReader r = new StreamReader(personaFilePath)) + { + string json = r.ReadToEnd(); + channelMetadataPersona = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + } + } + } + + [When(@"I set the channel metadata")] + public async Task WhenISetTheChannelMetadata() + { + PNResult setChannelMetadataResponse = await pn.SetChannelMetadata() + .Channel(channelMetadataPersona.id) + .Name(channelMetadataPersona.name) + .Description(channelMetadataPersona.description) + .ExecuteAsync(); + setChannelMetadataResult = setChannelMetadataResponse.Result; + pnStatus = setChannelMetadataResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + + } + + [Then(@"the channel metadata for '([^']*)' channel contains updated")] + public void ThenTheChannelMetadataForChannelContainsUpdated(string personaName) + { + Assert.AreEqual(channelMetadataPersona.name, setChannelMetadataResult.Name); + Assert.AreEqual(channelMetadataPersona.id, setChannelMetadataResult.Channel); + Assert.AreEqual(channelMetadataPersona.description, setChannelMetadataResult.Description); + Assert.AreEqual(channelMetadataPersona.updated, setChannelMetadataResult.Updated); + + if (string.Compare(personaName, "chat", true) == 0) + { + Assert.AreEqual(channelMetadataPersona.custom, setChannelMetadataResult.Custom); + } + else + { + Assert.Fail("TEST MISMATCH", personaName); + } + } + + [When(@"I remove the channel metadata")] + public async Task WhenIRemoveTheChannelMetadata() + { + PNResult removeChannelMetadataResponse = await pn.RemoveChannelMetadata() + .Channel(channelMetadataPersona.id) + .ExecuteAsync(); + pnStatus = removeChannelMetadataResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + + } + + [When(@"I get all channel metadata")] + public async Task WhenIGetAllChannelMetadata() + { + getAllChannelMetadataResult = null; + PNResult getAllChannelMetadataResponse = await pn.GetAllChannelMetadata() + .ExecuteAsync(); + getAllChannelMetadataResult = getAllChannelMetadataResponse.Result; + pnStatus = getAllChannelMetadataResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [Then(@"the response contains list with '([^']*)' and '([^']*)' channel metadata")] + public void ThenTheResponseContainsListWithAndChannelMetadata(string personaName1, string personaName2) + { + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string personaFile1 = string.Format("{0}.json", personaName1.ToLower()); + string personaFile2 = string.Format("{0}.json", personaName2.ToLower()); + + var personaFile1Path = Path.Combine(dirPath, "Data", personaFile1); + var personaFile2Path = Path.Combine(dirPath, "Data", personaFile2); + List personaList = new List(); + if (File.Exists(personaFile1Path) && File.Exists(personaFile2Path)) + { + using (StreamReader r = new StreamReader(personaFile1Path)) + { + string json = r.ReadToEnd(); + channelMetadataPersona = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + personaList.Add(channelMetadataPersona); + } + using (StreamReader r = new StreamReader(personaFile2Path)) + { + string json = r.ReadToEnd(); + channelMetadataPersona = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + personaList.Add(channelMetadataPersona); + } + } + + if ( + (string.Compare(getAllChannelMetadataResult.Channels[0].Channel, personaList[0].id) == 0 + && string.Compare(getAllChannelMetadataResult.Channels[1].Channel, personaList[1].id) == 0) + || + (string.Compare(getAllChannelMetadataResult.Channels[0].Channel, personaList[1].id) == 0 + && string.Compare(getAllChannelMetadataResult.Channels[1].Channel, personaList[0].id) == 0) + ) + { + Assert.True(true); + } + else + { + Assert.Fail(); + } + } + + [When(@"I get all channel metadata with custom")] + public async Task WhenIGetAllChannelMetadataWithCustom() + { + getAllChannelMetadataResult = null; + PNResult getAllChannelMetadataResponse = await pn.GetAllChannelMetadata() + .IncludeCustom(true) + .ExecuteAsync(); + getAllChannelMetadataResult = getAllChannelMetadataResponse.Result; + pnStatus = getAllChannelMetadataResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + } +} diff --git a/src/UnitTests/AcceptanceTests/Steps/ObjectsV2MembersMetadataSteps.cs b/src/UnitTests/AcceptanceTests/Steps/ObjectsV2MembersMetadataSteps.cs new file mode 100644 index 000000000..e197842eb --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Steps/ObjectsV2MembersMetadataSteps.cs @@ -0,0 +1,260 @@ +using System; +using TechTalk.SpecFlow; +using PubnubApi; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using NUnit.Framework; +using System.Net; +using System.Globalization; +using System.IO; +using System.Text.Json; + +namespace AcceptanceTests.Steps +{ + public partial class FeatureObjectsV2MetadataSteps + { + PNChannelMembersResult getChannelMembersMetadataResult; + ChannelMemberMetadataLocal channelMemberMetadata; + ChannelMemberMetadataLocal removeChannelMemberMetadata; + PNChannelMembersResult setChannelMembersResult; + + internal class ChannelMemberMetadataLocal + { + public UuidMetadataPersona uuid { get; set; } + public string updated { get; set; } + public string eTag { get; set; } + public Dictionary custom { get; set; } + } + + + [When(@"I get the channel members")] + public async Task WhenIGetTheChannelMembers() + { + PNResult getMembersResponse = await pn.GetChannelMembers() + .Channel(channelMetadataPersona.id) + .ExecuteAsync(); + getChannelMembersMetadataResult = getMembersResponse.Result; + pnStatus = getMembersResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + + } + + [Then(@"the response contains list with '([^']*)' and '([^']*)' members")] + public void ThenTheResponseContainsListWithAndMembers(string channelMember1, string channelMember2) + { + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string channelMemberFile1 = string.Format("{0}.json", channelMember1.ToLower()); + string channelMemberFile2 = string.Format("{0}.json", channelMember2.ToLower()); + + var memberFile1Path = Path.Combine(dirPath, "Data", channelMemberFile1); + var memberFile2Path = Path.Combine(dirPath, "Data", channelMemberFile2); + List personaList = new List(); + if (File.Exists(memberFile1Path) && File.Exists(memberFile2Path)) + { + using (StreamReader r = new StreamReader(memberFile1Path)) + { + string json = r.ReadToEnd(); + channelMemberMetadata = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + personaList.Add(channelMemberMetadata); + } + using (StreamReader r = new StreamReader(memberFile2Path)) + { + string json = r.ReadToEnd(); + channelMemberMetadata = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + personaList.Add(channelMemberMetadata); + } + } + Assert.AreEqual(personaList[0].uuid.id, getChannelMembersMetadataResult.ChannelMembers[0].UuidMetadata.Uuid); + Assert.AreEqual(personaList[1].uuid.id, getChannelMembersMetadataResult.ChannelMembers[1].UuidMetadata.Uuid); + if (string.Compare(currentContract, "getMembersOfVipChatChannelWithCustomAndUuidWithCustom", true) == 0) + { + Assert.AreEqual(personaList[1].custom.Count, getChannelMembersMetadataResult.ChannelMembers[1].Custom.Count); + } + } + + [When(@"I get the channel members including custom and UUID custom information")] + public async Task WhenIGetTheChannelMembersIncludingCustomAndUUIDCustomInformation() + { + PNResult getMembersResponse = await pn.GetChannelMembers() + .Channel(channelMetadataPersona.id) + .Include(new PNChannelMemberField[] { PNChannelMemberField.CUSTOM, PNChannelMemberField.UUID, PNChannelMemberField.UUID_CUSTOM }) + .ExecuteAsync(); + getChannelMembersMetadataResult = getMembersResponse.Result; + pnStatus = getMembersResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [Given(@"the data for '([^']*)' member")] + public void GivenTheDataForMember(string whatChannelMember) + { + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string memberFile = string.Format("{0}.json", whatChannelMember.ToLower()); + + var memberFile1Path = Path.Combine(dirPath, "Data", memberFile); + if (File.Exists(memberFile1Path)) + { + using (StreamReader r = new StreamReader(memberFile1Path)) + { + string json = r.ReadToEnd(); + channelMemberMetadata = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + } + } + } + + [When(@"I set a channel member")] + public async Task WhenISetAChannelMember() + { + setChannelMembersResult = null; + PNChannelMember channelMember = new PNChannelMember() + { + Uuid = channelMemberMetadata.uuid.id + }; + + PNResult setChannelMembersResponse = await pn.SetChannelMembers() + .Channel(channelMetadataPersona.id) + .Uuids(new List() { channelMember }) + .ExecuteAsync(); + setChannelMembersResult = setChannelMembersResponse.Result; + pnStatus = setChannelMembersResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [Then(@"the response contains list with '([^']*)' member")] + public void ThenTheResponseContainsListWithMember(string whatChannelMember) + { + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string memberFile = string.Format("{0}.json", whatChannelMember.ToLower()); + + var memberFile1Path = Path.Combine(dirPath, "Data", memberFile); + List membersList = new List(); + if (File.Exists(memberFile1Path)) + { + using (StreamReader r = new StreamReader(memberFile1Path)) + { + string json = r.ReadToEnd(); + channelMemberMetadata = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + membersList.Add(channelMemberMetadata); + } + } + + Assert.AreEqual(membersList[0].uuid.id, setChannelMembersResult.ChannelMembers[0].UuidMetadata.Uuid); + if (string.Compare(currentContract, "setMembersForChatChannelWithCustomAndUuidWithCustom", true) == 0) + { + Assert.AreEqual(membersList[0].custom.Count, setChannelMembersResult.ChannelMembers[0].Custom.Count); + } + } + + [When(@"I set a channel member including custom and UUID with custom")] + public async Task WhenISetAChannelMemberIncludingCustomAndUUIDWithCustom() + { + setChannelMembersResult = null; + PNChannelMember channelMember = new PNChannelMember() + { + Uuid = channelMemberMetadata.uuid.id + }; + + PNResult setChannelMembersResponse = await pn.SetChannelMembers() + .Channel(channelMetadataPersona.id) + .Uuids(new List() { channelMember }) + .Include(new PNChannelMemberField[] { PNChannelMemberField.CUSTOM, PNChannelMemberField.UUID, PNChannelMemberField.UUID_CUSTOM }) + .ExecuteAsync(); + setChannelMembersResult = setChannelMembersResponse.Result; + pnStatus = setChannelMembersResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [Given(@"the data for '([^']*)' member that we want to remove")] + public void GivenTheDataForMemberThatWeWantToRemove(string whatChannelMember) + { + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string memberFile = string.Format("{0}.json", whatChannelMember.ToLower()); + + var memberFile1Path = Path.Combine(dirPath, "Data", memberFile); + if (File.Exists(memberFile1Path)) + { + using (StreamReader r = new StreamReader(memberFile1Path)) + { + string json = r.ReadToEnd(); + removeChannelMemberMetadata = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + } + } + } + + [When(@"I remove a channel member")] + public async Task WhenIRemoveAChannelMember() + { + List channelMemberList = new List(); + channelMemberList.Add(removeChannelMemberMetadata.uuid.id); + + PNResult removeMemberResponse = await pn.RemoveChannelMembers() + .Channel(channelMetadataPersona.id) + .Uuids(channelMemberList) + .ExecuteAsync(); + pnStatus = removeMemberResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [When(@"I manage channel members")] + public async Task WhenIManageChannelMembers() + { + PNChannelMember setChannelMemberList = new PNChannelMember() + { + Uuid = channelMemberMetadata.uuid.id + }; + + List removeChannelMemberList = new List(); + removeChannelMemberList.Add(removeChannelMemberMetadata.uuid.id); + + PNResult manageMemberResponse = await pn.ManageChannelMembers() + .Channel(channelMetadataPersona.id) + .Set(new List() { setChannelMemberList }) + .Remove(removeChannelMemberList) + .ExecuteAsync(); + setChannelMembersResult = manageMemberResponse.Result; + pnStatus = manageMemberResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [Then(@"the response does not contain list with '([^']*)' member")] + public void ThenTheResponseDoesNotContainListWithMember(string whatChannelMember) + { + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string memberFile = string.Format("{0}.json", whatChannelMember.ToLower()); + + var memberFile1Path = Path.Combine(dirPath, "Data", memberFile); + List membersList = new List(); + if (File.Exists(memberFile1Path)) + { + using (StreamReader r = new StreamReader(memberFile1Path)) + { + string json = r.ReadToEnd(); + channelMemberMetadata = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + membersList.Add(channelMemberMetadata); + } + } + + Assert.AreEqual(membersList.Count, setChannelMembersResult.ChannelMembers.Count); + Assert.AreNotEqual(membersList[0].uuid.id, setChannelMembersResult.ChannelMembers[0].UuidMetadata.Uuid); + + } + } +} diff --git a/src/UnitTests/AcceptanceTests/Steps/ObjectsV2MembershipsMetadataSteps.cs b/src/UnitTests/AcceptanceTests/Steps/ObjectsV2MembershipsMetadataSteps.cs new file mode 100644 index 000000000..025cbd085 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Steps/ObjectsV2MembershipsMetadataSteps.cs @@ -0,0 +1,286 @@ +using System; +using TechTalk.SpecFlow; +using PubnubApi; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using NUnit.Framework; +using System.Net; +using System.Globalization; +using System.IO; +using System.Text.Json; + +namespace AcceptanceTests.Steps +{ + public partial class FeatureObjectsV2MetadataSteps + { + PNMembershipsResult getMembershipsMetadataResult; + ChannelMembershipMetadataLocal channelMembershipMetadata; + ChannelMembershipMetadataLocal removeChannelMembershipMetadata; + PNMembershipsResult setMembershipsResult; + + internal class ChannelMembershipMetadataLocal + { + public ChannelMetadataPersona channel { get; set; } + public string updated { get; set; } + public string eTag { get; set; } + public Dictionary custom { get; set; } + } + + + [When(@"I get the memberships")] + public async Task WhenIGetTheMemberships() + { + PNResult getMembershipsResponse = await pn.GetMemberships() + .Uuid(uuidMetadataPersona.id) + .ExecuteAsync(); + getMembershipsMetadataResult = getMembershipsResponse.Result; + pnStatus = getMembershipsResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + + } + + [Then(@"the response contains list with '([^']*)' and '([^']*)' memberships")] + public void ThenTheResponseContainsListWithAndMemberships(string membership1, string membership2) + { + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string membershipFile1 = string.Format("{0}.json", membership1.ToLower()); + string membershipFile2 = string.Format("{0}.json", membership2.ToLower()); + + var personaFile1Path = Path.Combine(dirPath, "Data", membershipFile1); + var personaFile2Path = Path.Combine(dirPath, "Data", membershipFile2); + List personaList = new List(); + if (File.Exists(personaFile1Path) && File.Exists(personaFile2Path)) + { + using (StreamReader r = new StreamReader(personaFile1Path)) + { + string json = r.ReadToEnd(); + channelMembershipMetadata = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + personaList.Add(channelMembershipMetadata); + } + using (StreamReader r = new StreamReader(personaFile2Path)) + { + string json = r.ReadToEnd(); + channelMembershipMetadata = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + personaList.Add(channelMembershipMetadata); + } + } + Assert.AreEqual(personaList[0].channel.id, getMembershipsMetadataResult.Memberships[0].ChannelMetadata.Channel); + Assert.AreEqual(personaList[1].channel.id, getMembershipsMetadataResult.Memberships[1].ChannelMetadata.Channel); + } + + [When(@"I get the memberships for current user")] + public async Task WhenIGetTheMembershipsForCurrentUser() + { + PNResult getMembershipsResponse = await pn.GetMemberships() + .ExecuteAsync(); + getMembershipsMetadataResult = getMembershipsResponse.Result; + pnStatus = getMembershipsResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + + } + + [When(@"I get the memberships including custom and channel custom information")] + public async Task WhenIGetTheMembershipsIncludingCustomAndChannelCustomInformation() + { + PNResult getMembershipsResponse = await pn.GetMemberships() + .Uuid(uuidMetadataPersona.id) + .Include(new PNMembershipField[] { PNMembershipField.CUSTOM, PNMembershipField.CHANNEL, PNMembershipField.CHANNEL_CUSTOM }) + .ExecuteAsync(); + getMembershipsMetadataResult = getMembershipsResponse.Result; + pnStatus = getMembershipsResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [Given(@"the data for '([^']*)' membership")] + public void GivenTheDataForMembership(string whatMembership) + { + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string membershipFile = string.Format("{0}.json", whatMembership.ToLower()); + + var personaFile1Path = Path.Combine(dirPath, "Data", membershipFile); + if (File.Exists(personaFile1Path)) + { + using (StreamReader r = new StreamReader(personaFile1Path)) + { + string json = r.ReadToEnd(); + if (string.Compare(currentContract, "removeAliceMembership", true) == 0) + { + removeChannelMembershipMetadata = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + } + else + { + channelMembershipMetadata = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + } + } + } + } + + [When(@"I set the membership")] + public async Task WhenISetTheMembership() + { + PNMembership membership = new PNMembership() + { + Channel = channelMembershipMetadata.channel.id + }; + + PNResult setMembershipsResponse = await pn.SetMemberships() + .Uuid(uuidMetadataPersona.id) + .Channels(new List() { membership }) + .ExecuteAsync(); + setMembershipsResult = setMembershipsResponse.Result; + pnStatus = setMembershipsResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [Then(@"the response contains list with '([^']*)' membership")] + public void ThenTheResponseContainsListWithMembership(string whatMembership) + { + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string membershipFile = string.Format("{0}.json", whatMembership.ToLower()); + + var personaFile1Path = Path.Combine(dirPath, "Data", membershipFile); + List membershipsList = new List(); + if (File.Exists(personaFile1Path)) + { + using (StreamReader r = new StreamReader(personaFile1Path)) + { + string json = r.ReadToEnd(); + channelMembershipMetadata = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + membershipsList.Add(channelMembershipMetadata); + } + } + + Assert.AreEqual(membershipsList[0].channel.id, setMembershipsResult.Memberships[0].ChannelMetadata.Channel); + } + + [When(@"I set the membership for current user")] + public async Task WhenISetTheMembershipForCurrentUser() + { + PNMembership membership = new PNMembership() + { + Channel = channelMembershipMetadata.channel.id + }; + + PNResult setMembershipsResponse = await pn.SetMemberships() + .Channels(new List() { membership }) + .ExecuteAsync(); + setMembershipsResult = setMembershipsResponse.Result; + pnStatus = setMembershipsResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [When(@"I remove the membership")] + public async Task WhenIRemoveTheMembership() + { + List membershipList = new List(); + membershipList.Add(removeChannelMembershipMetadata.channel.id); + + PNResult removeMembershipsResponse = await pn.RemoveMemberships() + .Uuid(uuidMetadataPersona.id) + .Channels(membershipList) + .ExecuteAsync(); + pnStatus = removeMembershipsResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [When(@"I remove the membership for current user")] + public async Task WhenIRemoveTheMembershipForCurrentUser() + { + List membershipList = new List(); + membershipList.Add(removeChannelMembershipMetadata.channel.id); + + PNResult removeMembershipsResponse = await pn.RemoveMemberships() + .Channels(membershipList) + .ExecuteAsync(); + pnStatus = removeMembershipsResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [Given(@"the data for '([^']*)' membership that we want to remove")] + public void GivenTheDataForMembershipThatWeWantToRemove(string whatMembership) + { + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string membershipFile = string.Format("{0}.json", whatMembership.ToLower()); + + var personaFile1Path = Path.Combine(dirPath, "Data", membershipFile); + if (File.Exists(personaFile1Path)) + { + using (StreamReader r = new StreamReader(personaFile1Path)) + { + string json = r.ReadToEnd(); + removeChannelMembershipMetadata = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + } + } + } + + [When(@"I manage memberships")] + public async Task WhenIManageMemberships() + { + PNMembership setMembership = new PNMembership() + { + Channel = channelMembershipMetadata.channel.id + }; + + List removeMembershipList = new List(); + removeMembershipList.Add(removeChannelMembershipMetadata.channel.id); + + PNResult manageMembershipResponse = await pn.ManageMemberships() + .Uuid(uuidMetadataPersona.id) + .Set(new List() { setMembership }) + .Remove(removeMembershipList) + .ExecuteAsync(); + setMembershipsResult = manageMembershipResponse.Result; + pnStatus = manageMembershipResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + + } + + [Then(@"the response does not contain list with '([^']*)' membership")] + public void ThenTheResponseDoesNotContainListWithMembership(string whatMembership) + { + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string membershipFile = string.Format("{0}.json", whatMembership.ToLower()); + + var personaFile1Path = Path.Combine(dirPath, "Data", membershipFile); + List membershipsList = new List(); + if (File.Exists(personaFile1Path)) + { + using (StreamReader r = new StreamReader(personaFile1Path)) + { + string json = r.ReadToEnd(); + channelMembershipMetadata = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + membershipsList.Add(channelMembershipMetadata); + } + } + + Assert.AreEqual(membershipsList.Count, setMembershipsResult.Memberships.Count); + Assert.AreNotEqual(membershipsList[0].channel.id, setMembershipsResult.Memberships[0].ChannelMetadata.Channel); + } + + } +} diff --git a/src/UnitTests/AcceptanceTests/Steps/ObjectsV2UuidMetadataSteps.cs b/src/UnitTests/AcceptanceTests/Steps/ObjectsV2UuidMetadataSteps.cs new file mode 100644 index 000000000..591e26d47 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Steps/ObjectsV2UuidMetadataSteps.cs @@ -0,0 +1,402 @@ +using System; +using TechTalk.SpecFlow; +using PubnubApi; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using NUnit.Framework; +using System.Net; +using System.Globalization; +using System.IO; +using System.Text.Json; + +namespace AcceptanceTests.Steps +{ + [Binding] + public partial class FeatureObjectsV2MetadataSteps + { + public static string currentFeature = string.Empty; + public static string currentContract = string.Empty; + public static bool betaVersion = false; + private string acceptance_test_origin = "localhost:8090"; + private bool bypassMockServer = false; + private readonly ScenarioContext _scenarioContext; + private Pubnub pn; + private PNConfiguration config = null; + private UuidMetadataPersona uuidMetadataPersona = null; + private PNGetUuidMetadataResult getUuidMetadataResult = null; + private PNSetUuidMetadataResult setUuidMetadataResult = null; + private PNGetAllUuidMetadataResult getAllUuidMetadataResult = null; + PNStatus pnStatus = null; + PubnubError pnError = null; + + public class PubnubError + { + public ErrorMsg error; + public string service; + public int status; + } + public class MessageDetail + { + public string message; + public string location; + public string locationType; + } + public class ErrorMsg + { + public string message; + public string source; + public List details; + } + + public class InternalPubnubLog : IPubnubLog + { + void IPubnubLog.WriteToLog(string logText) + { + System.Diagnostics.Debug.WriteLine(logText); + } + } + internal class UuidMetadataPersona + { + public string name { get; set; } + public string email { get; set; } + public string externalId { get; set; } + public string profileUrl { get; set; } + public string id { get; set; } + public string updated { get; set; } + public string type { get; set; } + public string status { get; set; } + public string eTag { get; set; } + public Dictionary custom { get; set; } + + } + + public FeatureObjectsV2MetadataSteps(ScenarioContext scenarioContext) + { + _scenarioContext = scenarioContext; + } + + [BeforeFeature] + public static void BeforeFeature(FeatureContext featureContext) + { + betaVersion = false; + if (featureContext.FeatureInfo != null && featureContext.FeatureInfo.Tags.Length > 0) + { + List tagList = featureContext.FeatureInfo.Tags.AsEnumerable().ToList(); + foreach (string tag in tagList) + { + if (tag.IndexOf("featureSet=") == 0) + { + currentFeature = tag.Replace("featureSet=", ""); + } + + if (tag.IndexOf("beta") == 0) + { + betaVersion = true; + } + } + } + + System.Diagnostics.Debug.WriteLine("Starting " + featureContext.FeatureInfo.Title); + } + + [AfterFeature] + public static void AfterFeature(FeatureContext featureContext) + { + System.Diagnostics.Debug.WriteLine("Finished " + featureContext.FeatureInfo.Title); + } + + [BeforeScenario()] + public void BeforeScenario() + { + currentContract = ""; + if (_scenarioContext.ScenarioInfo != null && _scenarioContext.ScenarioInfo.Tags.Length > 0) + { + List tagList = _scenarioContext.ScenarioInfo.Tags.AsEnumerable().ToList(); + foreach (string tag in tagList) + { + if (tag.IndexOf("contract=") == 0) + { + currentContract = tag.Replace("contract=", ""); + break; + } + } + if (!string.IsNullOrEmpty(currentContract) && !bypassMockServer) + { + string mockInitContract = string.Format("http://{0}/init?__contract__script__={1}", acceptance_test_origin, currentContract); + System.Diagnostics.Debug.WriteLine(mockInitContract); + WebClient webClient = new WebClient(); + string mockInitResponse = webClient.DownloadString(mockInitContract); + System.Diagnostics.Debug.WriteLine(mockInitResponse); + } + } + + } + + [AfterScenario()] + public void AfterScenario() + { + if (!bypassMockServer) + { + string mockExpectContract = string.Format("http://{0}/expect", acceptance_test_origin); + System.Diagnostics.Debug.WriteLine(mockExpectContract); + WebClient webClient = new WebClient(); + string mockExpectResponse = webClient.DownloadString(mockExpectContract); + System.Diagnostics.Debug.WriteLine(mockExpectResponse); + } + } + + [Given(@"I have a keyset with Objects V(.*) enabled")] + public void GivenIHaveAKeysetWithObjectsVEnabled(int p0) + { + config = new PNConfiguration(new UserId("pn-csharp-acceptance-test-uuid")); + config.Origin = acceptance_test_origin; + config.Secure = false; + config.PublishKey = System.Environment.GetEnvironmentVariable("PN_PUB_KEY"); + config.SubscribeKey = System.Environment.GetEnvironmentVariable("PN_SUB_KEY"); + config.SecretKey = System.Environment.GetEnvironmentVariable("PN_SEC_KEY"); + + pn = new Pubnub(config); + + } + + [Given(@"the id for '([^']*)' persona")] + public void GivenTheIdForPersona(string personaName) + { + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string personaFile = string.Format("{0}.json", personaName.ToLower()); + var personaFilePath = Path.Combine(dirPath, "Data", personaFile); + if (File.Exists(personaFilePath)) + { + using (StreamReader r = new StreamReader(personaFilePath)) + { + string json = r.ReadToEnd(); + uuidMetadataPersona = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + } + } + } + + [When(@"I get the UUID metadata")] + public async Task WhenIGetTheUUIDMetadata() + { + PNResult getUuidMetadataResponse = await pn.GetUuidMetadata() + .Uuid(uuidMetadataPersona.id) + .ExecuteAsync(); + getUuidMetadataResult = getUuidMetadataResponse.Result; + pnStatus = getUuidMetadataResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [Then(@"I receive a successful response")] + public void ThenIReceiveASuccessfulResponse() + { + Assert.IsTrue(!pnStatus.Error); + } + + [Then(@"the UUID metadata for '([^']*)' persona")] + public void ThenTheUUIDMetadataForPersona(string personaName) + { + if (string.Compare(personaName, "alice", true) == 0) + { + Assert.AreEqual(uuidMetadataPersona.name, getUuidMetadataResult.Name); + Assert.AreEqual(uuidMetadataPersona.id, getUuidMetadataResult.Uuid); + Assert.AreEqual(uuidMetadataPersona.email, getUuidMetadataResult.Email); + Assert.AreEqual(uuidMetadataPersona.externalId, getUuidMetadataResult.ExternalId); + Assert.AreEqual(uuidMetadataPersona.profileUrl, getUuidMetadataResult.ProfileUrl); + Assert.AreEqual(uuidMetadataPersona.updated, getUuidMetadataResult.Updated); + Assert.IsNull(getUuidMetadataResult.Custom); + } + else if (string.Compare(personaName, "bob", true) == 0) + { + Assert.AreEqual(uuidMetadataPersona.name, getUuidMetadataResult.Name); + Assert.AreEqual(uuidMetadataPersona.id, getUuidMetadataResult.Uuid); + Assert.AreEqual(uuidMetadataPersona.email, getUuidMetadataResult.Email); + Assert.AreEqual(uuidMetadataPersona.externalId, getUuidMetadataResult.ExternalId); + Assert.AreEqual(uuidMetadataPersona.profileUrl, getUuidMetadataResult.ProfileUrl); + Assert.AreEqual(uuidMetadataPersona.updated, getUuidMetadataResult.Updated); + Assert.AreEqual(uuidMetadataPersona.custom.Count, getUuidMetadataResult.Custom.Count); + } + } + + [Given(@"current user is '([^']*)' persona")] + public void GivenCurrentUserIsPersona(string personaName) + { + if (string.Compare(personaName, "bob", true) == 0) + { + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + var personaFilePath = Path.Combine(dirPath, "Data", "bob.json"); + using (StreamReader r = new StreamReader(personaFilePath)) + { + string json = r.ReadToEnd(); + uuidMetadataPersona = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + pn.ChangeUserId(uuidMetadataPersona.id); + } + } + else if (string.Compare(personaName, "alice", true) == 0) + { + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + var personaFilePath = Path.Combine(dirPath, "Data", "alice.json"); + using (StreamReader r = new StreamReader(personaFilePath)) + { + string json = r.ReadToEnd(); + uuidMetadataPersona = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + pn.ChangeUserId(uuidMetadataPersona.id); + } + } + } + + [When(@"I get the UUID metadata with custom for current user")] + public async Task WhenIGetTheUUIDMetadataWithCustomForCurrentUser() + { + PNResult getUuidMetadataResponse = await pn.GetUuidMetadata() + .IncludeCustom(true) + .ExecuteAsync(); + getUuidMetadataResult = getUuidMetadataResponse.Result; + pnStatus = getUuidMetadataResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [Given(@"the data for '([^']*)' persona")] + public void GivenTheDataForPersona(string personaName) + { + if (string.Compare(personaName, "alice", true) == 0) + { + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + var personaFilePath = Path.Combine(dirPath, "Data", "alice.json"); + using (StreamReader r = new StreamReader(personaFilePath)) + { + string json = r.ReadToEnd(); + uuidMetadataPersona = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + } + } + } + + [When(@"I set the UUID metadata")] + public async Task WhenISetTheUUIDMetadata() + { + PNResult setUuidMetadataResponse = await pn.SetUuidMetadata() + .Uuid(uuidMetadataPersona.id) + .Name(uuidMetadataPersona.name) + .Email(uuidMetadataPersona.email) + .ExternalId(uuidMetadataPersona.externalId) + .ProfileUrl(uuidMetadataPersona.profileUrl) + .ExecuteAsync(); + + setUuidMetadataResult = setUuidMetadataResponse.Result; + pnStatus = setUuidMetadataResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [Then(@"the UUID metadata for '([^']*)' persona contains updated")] + public void ThenTheUUIDMetadataForPersonaContainsUpdated(string personaName) + { + if (string.Compare(personaName, "alice", true) == 0) + { + Assert.AreEqual(uuidMetadataPersona.name, setUuidMetadataResult.Name); + Assert.AreEqual(uuidMetadataPersona.id, setUuidMetadataResult.Uuid); + Assert.AreEqual(uuidMetadataPersona.email, setUuidMetadataResult.Email); + Assert.AreEqual(uuidMetadataPersona.externalId, setUuidMetadataResult.ExternalId); + Assert.AreEqual(uuidMetadataPersona.profileUrl, setUuidMetadataResult.ProfileUrl); + Assert.AreEqual(uuidMetadataPersona.updated, setUuidMetadataResult.Updated); + Assert.IsNull(setUuidMetadataResult.Custom); + } + + } + + [When(@"I remove the UUID metadata")] + public async Task WhenIRemoveTheUUIDMetadata() + { + PNResult removeUuidMetadataResponse = await pn.RemoveUuidMetadata() + .Uuid(uuidMetadataPersona.id) + .ExecuteAsync(); + + pnStatus = removeUuidMetadataResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [When(@"I remove the UUID metadata for current user")] + public async Task WhenIRemoveTheUUIDMetadataForCurrentUser() + { + PNResult removeUuidMetadataResponse = await pn.RemoveUuidMetadata() + .ExecuteAsync(); + + pnStatus = removeUuidMetadataResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [When(@"I get all UUID metadata")] + public async Task WhenIGetAllUUIDMetadata() + { + PNResult getAllUuidMetadataResponse = await pn.GetAllUuidMetadata() + .ExecuteAsync(); + + getAllUuidMetadataResult = getAllUuidMetadataResponse.Result; + pnStatus = getAllUuidMetadataResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [Then(@"the response contains list with '([^']*)' and '([^']*)' UUID metadata")] + public void ThenTheResponseContainsListWithAndUUIDMetadata(string personaName1, string personaName2) + { + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string personaFile1 = string.Format("{0}.json", personaName1.ToLower()); + string personaFile2 = string.Format("{0}.json", personaName2.ToLower()); + + var personaFile1Path = Path.Combine(dirPath, "Data", personaFile1); + var personaFile2Path = Path.Combine(dirPath, "Data", personaFile2); + List personaList = new List(); + if (File.Exists(personaFile1Path) && File.Exists(personaFile2Path)) + { + using (StreamReader r = new StreamReader(personaFile1Path)) + { + string json = r.ReadToEnd(); + uuidMetadataPersona = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + personaList.Add(uuidMetadataPersona); + } + using (StreamReader r = new StreamReader(personaFile2Path)) + { + string json = r.ReadToEnd(); + uuidMetadataPersona = JsonSerializer.Deserialize(json, new JsonSerializerOptions { }); + personaList.Add(uuidMetadataPersona); + } + } + + Assert.AreEqual(getAllUuidMetadataResult.Uuids[0].Uuid, personaList[0].id); + Assert.AreEqual(getAllUuidMetadataResult.Uuids[1].Uuid, personaList[1].id); + } + + [When(@"I get all UUID metadata with custom")] + public async Task WhenIGetAllUUIDMetadataWithCustom() + { + PNResult getAllUuidMetadataResponse = await pn.GetAllUuidMetadata() + .IncludeCustom(true) + .ExecuteAsync(); + + getAllUuidMetadataResult = getAllUuidMetadataResponse.Result; + pnStatus = getAllUuidMetadataResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + } +}