From f9dd2e13a750b184c9c3ee794706b8c7e4eedd7d Mon Sep 17 00:00:00 2001 From: Pandu Masabathula Date: Thu, 23 Mar 2023 14:13:12 +0530 Subject: [PATCH 1/4] Type and SpaceId --- .../PubnubApi/Builder/UrlRequestBuilder.cs | 56 +++++++++++++++++-- .../EndPoint/Files/PublishFileMessage.cs | 17 +++++- .../EndPoint/PubSub/FireOperation.cs | 4 +- .../EndPoint/PubSub/PublishOperation.cs | 38 +++++++++---- .../EndPoint/PubSub/SignalOperation.cs | 37 +++++++++--- .../StoragePlayback/FetchHistoryOperation.cs | 18 +++++- .../PubnubApi/Interface/IUrlRequestBuilder.cs | 8 +-- .../PNFetchHistoryJsonDataParse.cs | 14 ++++- .../History/PNFetchHistoryItemResult.cs | 19 +++++++ .../Consumer/History/PNFetchHistoryResult.cs | 2 +- .../Model/Consumer/Pubsub/PNMessageResult.cs | 2 + .../Derived/Pubsub/SubscribeCallbackExt.cs | 20 ++++--- .../Model/Server/SubscribeMessage.cs | 33 +++++++++++ src/Api/PubnubApi/NewtonsoftJsonDotNet.cs | 34 ++++++++--- src/Api/PubnubApi/PubnubCoreBase.cs | 23 +++++++- 15 files changed, 272 insertions(+), 53 deletions(-) create mode 100644 src/Api/PubnubApi/Model/Consumer/History/PNFetchHistoryItemResult.cs diff --git a/src/Api/PubnubApi/Builder/UrlRequestBuilder.cs b/src/Api/PubnubApi/Builder/UrlRequestBuilder.cs index 8a6a206fe..9427bd57f 100644 --- a/src/Api/PubnubApi/Builder/UrlRequestBuilder.cs +++ b/src/Api/PubnubApi/Builder/UrlRequestBuilder.cs @@ -171,7 +171,7 @@ Uri IUrlRequestBuilder.BuildMultiChannelLeaveRequest(string requestMethod, strin return BuildRestApiRequest(requestMethod, requestBody, url, currentType, queryString, true); } - Uri IUrlRequestBuilder.BuildPublishRequest(string requestMethod, string requestBody, string channel, object originalMessage, bool storeInHistory, int ttl, Dictionary userMetaData, Dictionary additionalUrlParams, Dictionary externalQueryParam) + Uri IUrlRequestBuilder.BuildPublishRequest(string requestMethod, string requestBody, string channel, object originalMessage, bool storeInHistory, int ttl, Dictionary userMetaData, string type, string spaceId, Dictionary additionalUrlParams, Dictionary externalQueryParam) { PNOperationType currentType = PNOperationType.PNPublishOperation; @@ -202,6 +202,16 @@ Uri IUrlRequestBuilder.BuildPublishRequest(string requestMethod, string requestB requestQueryStringParams.Add("meta", UriUtil.EncodeUriComponent(jsonMetaData, currentType, false, false, false)); } + if (!string.IsNullOrEmpty(type)) + { + requestQueryStringParams.Add("type", UriUtil.EncodeUriComponent(type, currentType, false, false, false)); + } + + if (!string.IsNullOrEmpty(spaceId)) + { + requestQueryStringParams.Add("space-id", UriUtil.EncodeUriComponent(spaceId, currentType, false, false, false)); + } + if (storeInHistory && ttl >= 0) { requestQueryStringParams.Add("tt1", ttl.ToString(CultureInfo.InvariantCulture)); @@ -229,7 +239,7 @@ Uri IUrlRequestBuilder.BuildPublishRequest(string requestMethod, string requestB return BuildRestApiRequest(requestMethod, requestBody, url, currentType, queryString, allowPAMv3Sign); } - Uri IUrlRequestBuilder.BuildSignalRequest(string requestMethod, string requestBody, string channel, object originalMessage, Dictionary userMetaData, Dictionary externalQueryParam) + Uri IUrlRequestBuilder.BuildSignalRequest(string requestMethod, string requestBody, string channel, object originalMessage, Dictionary userMetaData, string type, string spaceId, Dictionary externalQueryParam) { PNOperationType currentType = PNOperationType.PNSignalOperation; @@ -253,6 +263,16 @@ Uri IUrlRequestBuilder.BuildSignalRequest(string requestMethod, string requestBo requestQueryStringParams.Add("meta", UriUtil.EncodeUriComponent(jsonMetaData, currentType, false, false, false)); } + if (!string.IsNullOrEmpty(type)) + { + requestQueryStringParams.Add("type", UriUtil.EncodeUriComponent(type, currentType, false, false, false)); + } + + if (!string.IsNullOrEmpty(spaceId)) + { + requestQueryStringParams.Add("space-id", UriUtil.EncodeUriComponent(spaceId, currentType, false, false, false)); + } + if (externalQueryParam != null && externalQueryParam.Count > 0) { foreach (KeyValuePair kvp in externalQueryParam) @@ -370,7 +390,7 @@ Uri IUrlRequestBuilder.BuildHistoryRequest(string requestMethod, string requestB return BuildRestApiRequest(requestMethod, requestBody, url, currentType, queryString, true); } - Uri IUrlRequestBuilder.BuildFetchRequest(string requestMethod, string requestBody, string[] channels, long start, long end, int count, bool reverse, bool includeMeta, bool includeMessageActions, bool includeUuid, bool includeMessageType, Dictionary externalQueryParam) + Uri IUrlRequestBuilder.BuildFetchRequest(string requestMethod, string requestBody, string[] channels, long start, long end, int count, bool reverse, bool includeMeta, bool includeMessageActions, bool includeUuid, bool includeMessageType, bool includeType, bool includeSpaceId, Dictionary externalQueryParam) { string channel = (channels != null && channels.Length > 0) ? string.Join(",", channels.OrderBy(x => x).ToArray()) : ""; @@ -415,6 +435,24 @@ Uri IUrlRequestBuilder.BuildFetchRequest(string requestMethod, string requestBod { requestQueryStringParams.Add("include_message_type", "true"); } + else + { + requestQueryStringParams.Add("include_message_type", "false"); + } + + if (includeType) + { + requestQueryStringParams.Add("include_type", "true"); + } + else + { + requestQueryStringParams.Add("include_type", "false"); + } + + if (includeSpaceId) + { + requestQueryStringParams.Add("include_space_id", "true"); + } if (externalQueryParam != null && externalQueryParam.Count > 0) { @@ -1895,7 +1933,7 @@ Uri IUrlRequestBuilder.BuildGenerateFileUploadUrlRequest(string requestMethod, s return BuildRestApiRequest(requestMethod, requestBody, url, currentType, queryString, true); } - Uri IUrlRequestBuilder.BuildPublishFileMessageRequest(string requestMethod, string requestBody, string channel, object originalMessage, bool storeInHistory, int ttl, Dictionary userMetaData, Dictionary additionalUrlParams, Dictionary externalQueryParam) + Uri IUrlRequestBuilder.BuildPublishFileMessageRequest(string requestMethod, string requestBody, string channel, object originalMessage, bool storeInHistory, int ttl, Dictionary userMetaData, string type, string spaceId, Dictionary additionalUrlParams, Dictionary externalQueryParam) { PNOperationType currentType = PNOperationType.PNPublishFileMessageOperation; @@ -1938,6 +1976,16 @@ Uri IUrlRequestBuilder.BuildPublishFileMessageRequest(string requestMethod, stri requestQueryStringParams.Add("store", "0"); } + if (!string.IsNullOrEmpty(type)) + { + requestQueryStringParams.Add("type",UriUtil.EncodeUriComponent(type, currentType, false, false, false)); + } + + if (!string.IsNullOrEmpty(spaceId)) + { + requestQueryStringParams.Add("space-id", UriUtil.EncodeUriComponent(spaceId, currentType, false, false, false)); + } + if (externalQueryParam != null && externalQueryParam.Count > 0) { foreach (KeyValuePair kvp in externalQueryParam) diff --git a/src/Api/PubnubApi/EndPoint/Files/PublishFileMessage.cs b/src/Api/PubnubApi/EndPoint/Files/PublishFileMessage.cs index 9036f7043..58f2d771c 100644 --- a/src/Api/PubnubApi/EndPoint/Files/PublishFileMessage.cs +++ b/src/Api/PubnubApi/EndPoint/Files/PublishFileMessage.cs @@ -27,6 +27,8 @@ public class PublishFileMessageOperation : PubnubCoreBase private bool storeInHistory = true; private Dictionary userMetadata; private int ttl = -1; + private string type = string.Empty; + private string spaceId = string.Empty; public PublishFileMessageOperation(PNConfiguration pubnubConfig, IJsonPluggableLibrary jsonPluggableLibrary, IPubnubUnitTest pubnubUnit, IPubnubLog log, EndPoint.TelemetryManager telemetryManager, EndPoint.TokenManager tokenManager, Pubnub instance) : base(pubnubConfig, jsonPluggableLibrary, pubnubUnit, log, telemetryManager, tokenManager, instance) { @@ -95,6 +97,17 @@ public PublishFileMessageOperation FileName(string name) return this; } + public PublishFileMessageOperation Type(string type) + { + this.type = type; + return this; + } + public PublishFileMessageOperation SpaceId(string spaceId) + { + this.spaceId = spaceId; + return this; + } + public PublishFileMessageOperation QueryParam(Dictionary customQueryParam) { this.queryParam = customQueryParam; @@ -178,7 +191,7 @@ private void ProcessFileMessagePublish(Dictionary externalQueryP IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr, (PubnubInstance != null && !string.IsNullOrEmpty(PubnubInstance.InstanceId) && PubnubTokenMgrCollection.ContainsKey(PubnubInstance.InstanceId)) ? PubnubTokenMgrCollection[PubnubInstance.InstanceId] : null, (PubnubInstance != null) ? PubnubInstance.InstanceId : ""); - Uri request = urlBuilder.BuildPublishFileMessageRequest("GET", "", this.channelName, publishPayload, this.storeInHistory, this.ttl, this.userMetadata, null, externalQueryParam); + Uri request = urlBuilder.BuildPublishFileMessageRequest("GET", "", this.channelName, publishPayload, this.storeInHistory, this.ttl, this.userMetadata, this.type, this.spaceId, null, externalQueryParam); string json = ""; UrlProcessRequest(request, requestState, false).ContinueWith(r => @@ -246,7 +259,7 @@ private async Task> ProcessFileMessagePubli requestState.EndPointOperation = this; IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr, (PubnubInstance != null && !string.IsNullOrEmpty(PubnubInstance.InstanceId) && PubnubTokenMgrCollection.ContainsKey(PubnubInstance.InstanceId)) ? PubnubTokenMgrCollection[PubnubInstance.InstanceId] : null, (PubnubInstance != null) ? PubnubInstance.InstanceId : ""); - Uri request = urlBuilder.BuildPublishFileMessageRequest("GET", "", this.channelName, publishPayload, this.storeInHistory, this.ttl, this.userMetadata, null, externalQueryParam); + Uri request = urlBuilder.BuildPublishFileMessageRequest("GET", "", this.channelName, publishPayload, this.storeInHistory, this.ttl, this.userMetadata, this.type, this.spaceId, null, externalQueryParam); Tuple JsonAndStatusTuple = await UrlProcessRequest(request, requestState, false).ConfigureAwait(false); ret.Status = JsonAndStatusTuple.Item2; diff --git a/src/Api/PubnubApi/EndPoint/PubSub/FireOperation.cs b/src/Api/PubnubApi/EndPoint/PubSub/FireOperation.cs index 4575b0724..c0ead8df8 100644 --- a/src/Api/PubnubApi/EndPoint/PubSub/FireOperation.cs +++ b/src/Api/PubnubApi/EndPoint/PubSub/FireOperation.cs @@ -178,7 +178,7 @@ private void Fire(string channel, object message, bool storeInHistory, int ttl, string requestMethodName = (this.httpPost) ? "POST" : "GET"; IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr, (PubnubInstance != null && !string.IsNullOrEmpty(PubnubInstance.InstanceId) && PubnubTokenMgrCollection.ContainsKey(PubnubInstance.InstanceId)) ? PubnubTokenMgrCollection[PubnubInstance.InstanceId] : null, (PubnubInstance != null) ? PubnubInstance.InstanceId : ""); - Uri request = urlBuilder.BuildPublishRequest(requestMethodName, "", channel, message, storeInHistory, ttl, metaData, urlParam, externalQueryParam); + Uri request = urlBuilder.BuildPublishRequest(requestMethodName, "", channel, message, storeInHistory, ttl, metaData, null, null, urlParam, externalQueryParam); RequestState requestState = new RequestState(); requestState.Channels = new [] { channel }; @@ -261,7 +261,7 @@ private async Task> Fire(string channel, object messag string requestMethodName = (this.httpPost) ? "POST" : "GET"; IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr, (PubnubInstance != null && !string.IsNullOrEmpty(PubnubInstance.InstanceId) && PubnubTokenMgrCollection.ContainsKey(PubnubInstance.InstanceId)) ? PubnubTokenMgrCollection[PubnubInstance.InstanceId] : null, (PubnubInstance != null) ? PubnubInstance.InstanceId : ""); - Uri request = urlBuilder.BuildPublishRequest(requestMethodName, "", channel, message, storeInHistory, ttl, metaData, urlParam, externalQueryParam); + Uri request = urlBuilder.BuildPublishRequest(requestMethodName, "", channel, message, storeInHistory, ttl, metaData, null, null, urlParam, externalQueryParam); RequestState requestState = new RequestState(); requestState.Channels = new[] { channel }; diff --git a/src/Api/PubnubApi/EndPoint/PubSub/PublishOperation.cs b/src/Api/PubnubApi/EndPoint/PubSub/PublishOperation.cs index afc99d735..9f169d4e4 100644 --- a/src/Api/PubnubApi/EndPoint/PubSub/PublishOperation.cs +++ b/src/Api/PubnubApi/EndPoint/PubSub/PublishOperation.cs @@ -23,6 +23,8 @@ public class PublishOperation : PubnubCoreBase private bool httpPost; private Dictionary userMetadata; private int ttl = -1; + private string type = string.Empty; + private string spaceId = string.Empty; private PNCallback savedCallback; private bool syncRequest; private Dictionary queryParam; @@ -77,6 +79,16 @@ public PublishOperation Ttl(int ttl) this.ttl = ttl; return this; } + public PublishOperation Type(string type) + { + this.type = type; + return this; + } + public PublishOperation SpaceId(string spaceId) + { + this.spaceId = spaceId; + return this; + } public PublishOperation QueryParam(Dictionary customQueryParam) { @@ -112,14 +124,14 @@ public void Execute(PNCallback callback) { syncRequest = false; this.savedCallback = callback; - Publish(this.channelName, this.msg, this.storeInHistory, this.ttl, this.userMetadata, this.queryParam, callback); + Publish(this.channelName, this.msg, this.storeInHistory, this.ttl, this.userMetadata, this.type, this.spaceId, this.queryParam, callback); }, CancellationToken.None, TaskCreationOptions.PreferFairness, TaskScheduler.Default).ConfigureAwait(false); #else new Thread(() => { syncRequest = false; this.savedCallback = callback; - Publish(this.channelName, this.msg, this.storeInHistory, this.ttl, this.userMetadata, this.queryParam, callback); + Publish(this.channelName, this.msg, this.storeInHistory, this.ttl, this.userMetadata, this.type, this.spaceId, this.queryParam, callback); }) { IsBackground = true }.Start(); #endif @@ -128,7 +140,7 @@ public void Execute(PNCallback callback) public async Task> ExecuteAsync() { syncRequest = false; - return await Publish(this.channelName, this.msg, this.storeInHistory, this.ttl, this.userMetadata, this.queryParam).ConfigureAwait(false); + return await Publish(this.channelName, this.msg, this.storeInHistory, this.ttl, this.userMetadata, this.type, this.spaceId, this.queryParam).ConfigureAwait(false); } public PNPublishResult Sync() @@ -148,7 +160,7 @@ public PNPublishResult Sync() { syncRequest = true; syncEvent = new System.Threading.ManualResetEvent(false); - Publish(this.channelName, this.msg, this.storeInHistory, this.ttl, this.userMetadata, this.queryParam, new PNPublishResultExt((r, s) => { SyncResult = r; syncEvent.Set(); })); + Publish(this.channelName, this.msg, this.storeInHistory, this.ttl, this.userMetadata, this.type, this.spaceId, this.queryParam, new PNPublishResultExt((r, s) => { SyncResult = r; syncEvent.Set(); })); syncEvent.WaitOne(config.NonSubscribeRequestTimeout * 1000); return SyncResult; @@ -165,7 +177,7 @@ internal void Retry() { if (!syncRequest) { - Publish(this.channelName, this.msg, this.storeInHistory, this.ttl, this.userMetadata, this.queryParam, savedCallback); + Publish(this.channelName, this.msg, this.storeInHistory, this.ttl, this.userMetadata, this.type, this.spaceId, this.queryParam, savedCallback); } }, CancellationToken.None, TaskCreationOptions.PreferFairness, TaskScheduler.Default).ConfigureAwait(false); #else @@ -173,14 +185,14 @@ internal void Retry() { if (!syncRequest) { - Publish(this.channelName, this.msg, this.storeInHistory, this.ttl, this.userMetadata, this.queryParam, savedCallback); + Publish(this.channelName, this.msg, this.storeInHistory, this.ttl, this.userMetadata, this.type, this.spaceId, this.queryParam, savedCallback); } }) { IsBackground = true }.Start(); #endif } - internal void Publish(string channel, object message, bool storeInHistory, int ttl, Dictionary metaData, Dictionary externalQueryParam, PNCallback callback) + internal void Publish(string channel, object message, bool storeInHistory, int ttl, Dictionary metaData, string type, string spaceId, Dictionary externalQueryParam, PNCallback callback) { if (string.IsNullOrEmpty(channel) || string.IsNullOrEmpty(channel.Trim()) || message == null) { @@ -211,7 +223,7 @@ internal void Publish(string channel, object message, bool storeInHistory, int t string requestMethodName = (this.httpPost) ? "POST" : "GET"; IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr, (PubnubInstance != null && !string.IsNullOrEmpty(PubnubInstance.InstanceId) && PubnubTokenMgrCollection.ContainsKey(PubnubInstance.InstanceId)) ? PubnubTokenMgrCollection[PubnubInstance.InstanceId] : null, (PubnubInstance != null) ? PubnubInstance.InstanceId : ""); - Uri request = urlBuilder.BuildPublishRequest(requestMethodName, "", channel, message, storeInHistory, ttl, metaData, null, externalQueryParam); + Uri request = urlBuilder.BuildPublishRequest(requestMethodName, "", channel, message, storeInHistory, ttl, metaData, type, spaceId, null, externalQueryParam); requestState.Channels = new[] { channel }; requestState.ResponseType = PNOperationType.PNPublishOperation; @@ -282,7 +294,7 @@ internal void Publish(string channel, object message, bool storeInHistory, int t } } - internal async Task> Publish(string channel, object message, bool storeInHistory, int ttl, Dictionary metaData, Dictionary externalQueryParam) + internal async Task> Publish(string channel, object message, bool storeInHistory, int ttl, Dictionary metaData, string type, string spaceid, Dictionary externalQueryParam) { PNResult ret = new PNResult(); @@ -310,7 +322,7 @@ internal async Task> Publish(string channel, object me string requestMethodName = (this.httpPost) ? "POST" : "GET"; IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr, (PubnubInstance != null && !string.IsNullOrEmpty(PubnubInstance.InstanceId) && PubnubTokenMgrCollection.ContainsKey(PubnubInstance.InstanceId)) ? PubnubTokenMgrCollection[PubnubInstance.InstanceId] : null, (PubnubInstance != null) ? PubnubInstance.InstanceId : ""); - Uri request = urlBuilder.BuildPublishRequest(requestMethodName, "", channel, message, storeInHistory, ttl, metaData, null, externalQueryParam); + Uri request = urlBuilder.BuildPublishRequest(requestMethodName, "", channel, message, storeInHistory, ttl, metaData, type, spaceid, null, externalQueryParam); requestState.Channels = new[] { channel }; requestState.ResponseType = PNOperationType.PNPublishOperation; @@ -354,6 +366,12 @@ internal async Task> Publish(string channel, object me } } } + else + { + PNStatusCategory category = PNStatusCategoryHelper.GetPNStatusCategory(400, result[0].ToString()); + PNStatus status = new StatusBuilder(config, jsonLibrary).CreateStatusResponse(PNOperationType.PNPublishOperation, category, requestState, 400, new PNException(result[0].ToString())); + ret.Status = status; + } } } } diff --git a/src/Api/PubnubApi/EndPoint/PubSub/SignalOperation.cs b/src/Api/PubnubApi/EndPoint/PubSub/SignalOperation.cs index d1564461d..eb503745c 100644 --- a/src/Api/PubnubApi/EndPoint/PubSub/SignalOperation.cs +++ b/src/Api/PubnubApi/EndPoint/PubSub/SignalOperation.cs @@ -19,6 +19,8 @@ public class SignalOperation : PubnubCoreBase private object msg; private string channelName = ""; + private string type = string.Empty; + private string spaceId = string.Empty; private PNCallback savedCallback; private Dictionary queryParam; @@ -59,6 +61,17 @@ public SignalOperation Channel(string channelName) return this; } + public SignalOperation Type(string type) + { + this.type = type; + return this; + } + public SignalOperation SpaceId(string spaceId) + { + this.spaceId = spaceId; + return this; + } + public SignalOperation QueryParam(Dictionary customQueryParam) { queryParam = customQueryParam; @@ -93,7 +106,7 @@ public void Execute(PNCallback callback) this.savedCallback = callback; try { - Signal(this.channelName, this.msg, null, this.queryParam, callback); + Signal(this.channelName, this.msg, null, this.type, this.spaceId, this.queryParam, callback); } catch(Exception ex) { @@ -107,7 +120,7 @@ public void Execute(PNCallback callback) this.savedCallback = callback; try { - Signal(this.channelName, this.msg, null, this.queryParam, callback); + Signal(this.channelName, this.msg, null, this.type, this.spaceId, this.queryParam, callback); } catch(Exception ex) { @@ -121,7 +134,7 @@ public void Execute(PNCallback callback) public async Task> ExecuteAsync() { - return await Signal(this.channelName, this.msg, null, this.queryParam).ConfigureAwait(false); + return await Signal(this.channelName, this.msg, null, this.type, this.spaceId, this.queryParam).ConfigureAwait(false); } internal void Retry() @@ -129,18 +142,18 @@ internal void Retry() #if NETFX_CORE || WINDOWS_UWP || UAP || NETSTANDARD10 || NETSTANDARD11 || NETSTANDARD12 Task.Factory.StartNew(() => { - Signal(this.channelName, this.msg, null, this.queryParam, savedCallback); + Signal(this.channelName, this.msg, null, this.type, this.spaceId, this.queryParam, savedCallback); }, CancellationToken.None, TaskCreationOptions.PreferFairness, TaskScheduler.Default).ConfigureAwait(false); #else new Thread(() => { - Signal(this.channelName, this.msg, null, this.queryParam, savedCallback); + Signal(this.channelName, this.msg, null, this.type, this.spaceId, this.queryParam, savedCallback); }) { IsBackground = true }.Start(); #endif } - private void Signal(string channel, object message, Dictionary metaData, Dictionary externalQueryParam, PNCallback callback) + private void Signal(string channel, object message, Dictionary metaData, string type, string spaceid, Dictionary externalQueryParam, PNCallback callback) { if (string.IsNullOrEmpty(channel) || string.IsNullOrEmpty(channel.Trim()) || message == null) { @@ -165,7 +178,7 @@ private void Signal(string channel, object message, Dictionary m IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr, (PubnubInstance != null && !string.IsNullOrEmpty(PubnubInstance.InstanceId) && PubnubTokenMgrCollection.ContainsKey(PubnubInstance.InstanceId)) ? PubnubTokenMgrCollection[PubnubInstance.InstanceId] : null, (PubnubInstance != null) ? PubnubInstance.InstanceId : ""); - Uri request = urlBuilder.BuildSignalRequest("GET", "", channel, message, metaData, externalQueryParam); + Uri request = urlBuilder.BuildSignalRequest("GET", "", channel, message, metaData, type, spaceid, externalQueryParam); RequestState requestState = new RequestState(); requestState.Channels = new[] { channel }; @@ -207,7 +220,7 @@ private void Signal(string channel, object message, Dictionary m }, TaskContinuationOptions.ExecuteSynchronously).Wait(); } - private async Task> Signal(string channel, object message, Dictionary metaData, Dictionary externalQueryParam) + private async Task> Signal(string channel, object message, Dictionary metaData, string type, string spaceid, Dictionary externalQueryParam) { PNResult ret = new PNResult(); @@ -234,7 +247,7 @@ private async Task> Signal(string channel, object mess IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr, (PubnubInstance != null && !string.IsNullOrEmpty(PubnubInstance.InstanceId) && PubnubTokenMgrCollection.ContainsKey(PubnubInstance.InstanceId)) ? PubnubTokenMgrCollection[PubnubInstance.InstanceId] : null, (PubnubInstance != null) ? PubnubInstance.InstanceId : ""); - Uri request = urlBuilder.BuildSignalRequest("GET", "", channel, message, metaData, externalQueryParam); + Uri request = urlBuilder.BuildSignalRequest("GET", "", channel, message, metaData, type, spaceid, externalQueryParam); RequestState requestState = new RequestState(); requestState.Channels = new[] { channel }; @@ -272,6 +285,12 @@ private async Task> Signal(string channel, object mess ret.Result = default(PNPublishResult); } } + else + { + PNStatusCategory category = PNStatusCategoryHelper.GetPNStatusCategory(400, result[0].ToString()); + PNStatus status = new StatusBuilder(config, jsonLibrary).CreateStatusResponse(PNOperationType.PNSignalOperation, category, requestState, 400, new PNException(result[0].ToString())); + ret.Status = status; + } } } diff --git a/src/Api/PubnubApi/EndPoint/StoragePlayback/FetchHistoryOperation.cs b/src/Api/PubnubApi/EndPoint/StoragePlayback/FetchHistoryOperation.cs index ac42f2951..5e9109a8c 100644 --- a/src/Api/PubnubApi/EndPoint/StoragePlayback/FetchHistoryOperation.cs +++ b/src/Api/PubnubApi/EndPoint/StoragePlayback/FetchHistoryOperation.cs @@ -21,7 +21,9 @@ public class FetchHistoryOperation : PubnubCoreBase private bool withMetaOption; private bool withMessageActionsOption; private bool includeMessageType = true; //default to true + private bool includeType = true; //default to true private bool withUuidOption = true; //default to true + private bool withSpaceIdOption = false; private long startTimetoken = -1; private long endTimetoken = -1; private int perChannelCount = -1; @@ -79,12 +81,24 @@ public FetchHistoryOperation IncludeMessageType(bool withMessageType) return this; } + public FetchHistoryOperation IncludeType(bool withType) + { + includeType = withType; + return this; + } + public FetchHistoryOperation IncludeUuid(bool withUuid) { withUuidOption = withUuid; return this; } + public FetchHistoryOperation IncludeSpaceId(bool withSpaceId) + { + withSpaceIdOption = withSpaceId; + return this; + } + public FetchHistoryOperation IncludeMessageActions(bool withMessageActions) { this.withMessageActionsOption = withMessageActions; @@ -194,7 +208,7 @@ internal void History(PNCallback callback) IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr, (PubnubInstance != null && !string.IsNullOrEmpty(PubnubInstance.InstanceId) && PubnubTokenMgrCollection.ContainsKey(PubnubInstance.InstanceId)) ? PubnubTokenMgrCollection[PubnubInstance.InstanceId] : null, (PubnubInstance != null) ? PubnubInstance.InstanceId : ""); - Uri request = urlBuilder.BuildFetchRequest("GET", "", this.channelNames, this.startTimetoken, this.endTimetoken, this.perChannelCount, this.reverseOption, this.withMetaOption, this.withMessageActionsOption, this.withUuidOption, this.includeMessageType, this.queryParam); + Uri request = urlBuilder.BuildFetchRequest("GET", "", this.channelNames, this.startTimetoken, this.endTimetoken, this.perChannelCount, this.reverseOption, this.withMetaOption, this.withMessageActionsOption, this.withUuidOption, this.includeMessageType, this.includeType, this.withSpaceIdOption, this.queryParam); RequestState requestState = new RequestState(); requestState.Channels = new[] { channel }; @@ -225,7 +239,7 @@ internal async Task> History() IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr, (PubnubInstance != null && !string.IsNullOrEmpty(PubnubInstance.InstanceId) && PubnubTokenMgrCollection.ContainsKey(PubnubInstance.InstanceId)) ? PubnubTokenMgrCollection[PubnubInstance.InstanceId] : null, (PubnubInstance != null) ? PubnubInstance.InstanceId : ""); - Uri request = urlBuilder.BuildFetchRequest("GET", "", this.channelNames, this.startTimetoken, this.endTimetoken, this.perChannelCount, this.reverseOption, this.withMetaOption, this.withMessageActionsOption, this.withUuidOption, this.includeMessageType, this.queryParam); + Uri request = urlBuilder.BuildFetchRequest("GET", "", this.channelNames, this.startTimetoken, this.endTimetoken, this.perChannelCount, this.reverseOption, this.withMetaOption, this.withMessageActionsOption, this.withUuidOption, this.includeMessageType, this.includeType, this.withSpaceIdOption, this.queryParam); RequestState requestState = new RequestState(); requestState.Channels = new[] { channel }; diff --git a/src/Api/PubnubApi/Interface/IUrlRequestBuilder.cs b/src/Api/PubnubApi/Interface/IUrlRequestBuilder.cs index 2d3f7a5b8..2bacb12aa 100644 --- a/src/Api/PubnubApi/Interface/IUrlRequestBuilder.cs +++ b/src/Api/PubnubApi/Interface/IUrlRequestBuilder.cs @@ -13,15 +13,15 @@ public interface IUrlRequestBuilder Uri BuildMultiChannelLeaveRequest(string requestMethod, string requestBody, string[] channels, string[] channelGroups, string jsonUserState, Dictionary externalQueryParam); - Uri BuildPublishRequest(string requestMethod, string requestBody, string channel, object originalMessage, bool storeInHistory, int ttl, Dictionary userMetaData, Dictionary additionalUrlParams, Dictionary externalQueryParam); + Uri BuildPublishRequest(string requestMethod, string requestBody, string channel, object originalMessage, bool storeInHistory, int ttl, Dictionary userMetaData, string type, string spaceId, Dictionary additionalUrlParams, Dictionary externalQueryParam); - Uri BuildSignalRequest(string requestMethod, string requestBody, string channel, object originalMessage, Dictionary userMetaData, Dictionary externalQueryParam); + Uri BuildSignalRequest(string requestMethod, string requestBody, string channel, object originalMessage, Dictionary userMetaData, string type, string spaceId, Dictionary externalQueryParam); Uri BuildHereNowRequest(string requestMethod, string requestBody, string[] channels, string[] channelGroups, bool showUUIDList, bool includeUserState, Dictionary externalQueryParam); Uri BuildHistoryRequest(string requestMethod, string requestBody, string channel, long start, long end, int count, bool reverse, bool includeToken, bool includeMeta, Dictionary externalQueryParam); - Uri BuildFetchRequest(string requestMethod, string requestBody, string[] channels, long start, long end, int count, bool reverse, bool includeMeta, bool includeMessageActions, bool includeUuid, bool includeMessageType, Dictionary externalQueryParam); + Uri BuildFetchRequest(string requestMethod, string requestBody, string[] channels, long start, long end, int count, bool reverse, bool includeMeta, bool includeMessageActions, bool includeUuid, bool includeMessageType, bool includeType, bool includeSpaceId, Dictionary externalQueryParam); Uri BuildDeleteMessageRequest(string requestMethod, string requestBody, string channel, long start, long end, Dictionary externalQueryParam); @@ -91,7 +91,7 @@ public interface IUrlRequestBuilder Uri BuildGenerateFileUploadUrlRequest(string requestMethod, string requestBody, string channel, Dictionary externalQueryParam); - Uri BuildPublishFileMessageRequest(string requestMethod, string requestBody, string channel, object originalMessage, bool storeInHistory, int ttl, Dictionary userMetaData, Dictionary additionalUrlParams, Dictionary externalQueryParam); + Uri BuildPublishFileMessageRequest(string requestMethod, string requestBody, string channel, object originalMessage, bool storeInHistory, int ttl, Dictionary userMetaData, string type, string spaceId, Dictionary additionalUrlParams, Dictionary externalQueryParam); Uri BuildGetFileUrlOrDeleteReqest(string requestMethod, string requestBody, string channel, string fileId, string fileName, Dictionary externalQueryParam, PNOperationType operationType); diff --git a/src/Api/PubnubApi/JsonDataParse/PNFetchHistoryJsonDataParse.cs b/src/Api/PubnubApi/JsonDataParse/PNFetchHistoryJsonDataParse.cs index 0f1c8040c..1598706a8 100644 --- a/src/Api/PubnubApi/JsonDataParse/PNFetchHistoryJsonDataParse.cs +++ b/src/Api/PubnubApi/JsonDataParse/PNFetchHistoryJsonDataParse.cs @@ -23,18 +23,18 @@ internal static PNFetchHistoryResult GetObject(List listObject) } if (channelMessagesContainer != null) { - ack.Messages = new Dictionary>(); + ack.Messages = new Dictionary>(); foreach (var channelKVP in channelMessagesContainer) { string channel = channelKVP.Key; - List resultList = new List(); + List resultList = new List(); object[] channelValArray = channelKVP.Value != null ? JsonDataParseInternalUtil.ConvertToObjectArray(channelKVP.Value) : new object[0]; foreach (object msgContainerObj in channelValArray) { Dictionary messagesContainer = JsonDataParseInternalUtil.ConvertToDictionaryObject(msgContainerObj); if (messagesContainer != null) { - PNHistoryItemResult result = new PNHistoryItemResult(); + PNFetchHistoryItemResult result = new PNFetchHistoryItemResult(); if (messagesContainer.ContainsKey("message") && (messagesContainer.ContainsKey("timetoken") || messagesContainer.ContainsKey("meta") || messagesContainer.ContainsKey("actions"))) { @@ -64,6 +64,14 @@ internal static PNFetchHistoryResult GetObject(List listObject) { result.MessageType = messageType; } + if (messagesContainer.ContainsKey("type") && messagesContainer["type"] != null) + { + result.Type = messagesContainer["type"].ToString(); + } + if (messagesContainer.ContainsKey("space_id") && messagesContainer["space_id"] != null) + { + result.SpaceId = messagesContainer["space_id"].ToString(); + } } resultList.Add(result); } diff --git a/src/Api/PubnubApi/Model/Consumer/History/PNFetchHistoryItemResult.cs b/src/Api/PubnubApi/Model/Consumer/History/PNFetchHistoryItemResult.cs new file mode 100644 index 000000000..115896c30 --- /dev/null +++ b/src/Api/PubnubApi/Model/Consumer/History/PNFetchHistoryItemResult.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace PubnubApi +{ + public class PNFetchHistoryItemResult + { + public long Timetoken { get; internal set; } + public object Entry { get; internal set; } + public object Meta { get; internal set; } + public object Actions { get; internal set; } + public string Uuid { get; internal set; } + public int MessageType { get; internal set; } + public string Type { get; internal set;} + public string SpaceId { get; internal set; } + } +} diff --git a/src/Api/PubnubApi/Model/Consumer/History/PNFetchHistoryResult.cs b/src/Api/PubnubApi/Model/Consumer/History/PNFetchHistoryResult.cs index d3ee15e32..4ec10085d 100644 --- a/src/Api/PubnubApi/Model/Consumer/History/PNFetchHistoryResult.cs +++ b/src/Api/PubnubApi/Model/Consumer/History/PNFetchHistoryResult.cs @@ -12,7 +12,7 @@ public class MoreInfo public int Max { get; internal set; } } - public Dictionary> Messages { get; internal set; } + public Dictionary> Messages { get; internal set; } public MoreInfo More { get; internal set; } } } diff --git a/src/Api/PubnubApi/Model/Consumer/Pubsub/PNMessageResult.cs b/src/Api/PubnubApi/Model/Consumer/Pubsub/PNMessageResult.cs index ddb0e2e78..cc4901518 100644 --- a/src/Api/PubnubApi/Model/Consumer/Pubsub/PNMessageResult.cs +++ b/src/Api/PubnubApi/Model/Consumer/Pubsub/PNMessageResult.cs @@ -10,5 +10,7 @@ public class PNMessageResult public long Timetoken { get; internal set; } public object UserMetadata { get; internal set; } public string Publisher { get; internal set; } + public string Type { get; internal set;} + public string SpaceId { get; internal set; } } } diff --git a/src/Api/PubnubApi/Model/Derived/Pubsub/SubscribeCallbackExt.cs b/src/Api/PubnubApi/Model/Derived/Pubsub/SubscribeCallbackExt.cs index 5817f6193..5f4c9db45 100644 --- a/src/Api/PubnubApi/Model/Derived/Pubsub/SubscribeCallbackExt.cs +++ b/src/Api/PubnubApi/Model/Derived/Pubsub/SubscribeCallbackExt.cs @@ -127,13 +127,17 @@ public SubscribeCallbackExt(Action> messageCallb public override void Message(Pubnub pubnub, PNMessageResult message) { - PNMessageResult message1 = new PNMessageResult(); - message1.Channel = message.Channel; - message1.Message = (T)(object)message.Message; - message1.Subscription = message.Subscription; - message1.Timetoken = message.Timetoken; - message1.UserMetadata = message.UserMetadata; - message1.Publisher = message.Publisher; + PNMessageResult message1 = new PNMessageResult + { + Channel = message.Channel, + Message = (T)(object)message.Message, + Subscription = message.Subscription, + Timetoken = message.Timetoken, + UserMetadata = message.UserMetadata, + Publisher = message.Publisher, + Type = message.Type, + SpaceId = message.SpaceId + }; subscribeAction?.Invoke(pubnub, message1); } @@ -157,6 +161,8 @@ public override void Signal(Pubnub pubnub, PNSignalResult signalMessage) message1.Timetoken = signalMessage.Timetoken; message1.UserMetadata = signalMessage.UserMetadata; message1.Publisher = signalMessage.Publisher; + message1.Type = signalMessage.Type; + message1.SpaceId = signalMessage.SpaceId; signalAction?.Invoke(pubnub, message1); } diff --git a/src/Api/PubnubApi/Model/Server/SubscribeMessage.cs b/src/Api/PubnubApi/Model/Server/SubscribeMessage.cs index f6aaf0bdc..d703fe643 100644 --- a/src/Api/PubnubApi/Model/Server/SubscribeMessage.cs +++ b/src/Api/PubnubApi/Model/Server/SubscribeMessage.cs @@ -32,6 +32,11 @@ internal class SubscribeMessage /// private int e { get; set; } + /// + /// custom message type + /// + private string mt { get; set; } + /// /// flags /// @@ -67,6 +72,11 @@ internal class SubscribeMessage /// private object u { get; set; } + /// + /// spaceid + /// + private string si { get; set; } = ""; + public string Shard { get @@ -103,6 +113,18 @@ internal set } } + public string Type + { + get + { + return mt; + } + internal set + { + mt = value; + } + } + public string Channel { get @@ -211,5 +233,16 @@ internal set } } + public string SpaceId + { + get + { + return si; + } + internal set + { + si = value; + } + } } } diff --git a/src/Api/PubnubApi/NewtonsoftJsonDotNet.cs b/src/Api/PubnubApi/NewtonsoftJsonDotNet.cs index fe1671538..73880b486 100644 --- a/src/Api/PubnubApi/NewtonsoftJsonDotNet.cs +++ b/src/Api/PubnubApi/NewtonsoftJsonDotNet.cs @@ -269,17 +269,27 @@ private T DeserializeMessageToObjectBasedOnPlatform(List listObject) string publisherValue = (listObject[3] != null) ? listObject[3].ToString() : ""; publisherProp.SetValue(message, publisherValue, null); + //Set Type + PropertyInfo typeProp = specific.GetProperty("Type"); + string typeValue = (listObject[4] != null) ? listObject[4].ToString() : ""; + typeProp.SetValue(message, typeValue, null); + + //Set SpaceId + PropertyInfo spaceIdProp = specific.GetProperty("SpaceId"); + string spaceIdValue = (listObject[5] != null) ? listObject[5].ToString() : ""; + spaceIdProp.SetValue(message, spaceIdValue, null); + // Set ChannelName PropertyInfo channelNameProp = specific.GetProperty("Channel"); - channelNameProp.SetValue(message, (listObject.Count == 6) ? listObject[5].ToString() : listObject[4].ToString(), null); + channelNameProp.SetValue(message, (listObject.Count == 8) ? listObject[7].ToString() : listObject[6].ToString(), null); // Set ChannelGroup - if (listObject.Count == 6) + if (listObject.Count == 8) { PropertyInfo subsciptionProp = specific.GetProperty("Subscription"); - subsciptionProp.SetValue(message, listObject[4].ToString(), null); + subsciptionProp.SetValue(message, listObject[6].ToString(), null); } - + //Set Metadata list second position, index=1 if (listObject[1] != null) { @@ -342,15 +352,25 @@ private T DeserializeMessageToObjectBasedOnPlatform(List listObject) string publisherValue = (listObject[3] != null) ? listObject[3].ToString() : ""; publisherProp.SetValue(message, publisherValue, null); + //Set Type + PropertyInfo typeProp = specific.GetProperty("Type"); + string typeValue = (listObject[4] != null) ? listObject[4].ToString() : ""; + typeProp.SetValue(message, typeValue, null); + + //Set SpaceId + PropertyInfo spaceIdProp = specific.GetProperty("SpaceId"); + string spaceIdValue = (listObject[5] != null) ? listObject[5].ToString() : ""; + spaceIdProp.SetValue(message, spaceIdValue, null); + // Set ChannelName PropertyInfo channelNameProp = specific.GetRuntimeProperty("Channel"); - channelNameProp.SetValue(message, (listObject.Count == 6) ? listObject[5].ToString() : listObject[4].ToString(), null); + channelNameProp.SetValue(message, (listObject.Count == 8) ? listObject[7].ToString() : listObject[6].ToString(), null); // Set ChannelGroup - if (listObject.Count == 6) + if (listObject.Count == 8) { PropertyInfo subsciptionProp = specific.GetRuntimeProperty("Subscription"); - subsciptionProp.SetValue(message, listObject[4].ToString(), null); + subsciptionProp.SetValue(message, listObject[6].ToString(), null); } //Set Metadata list second position, index=1 diff --git a/src/Api/PubnubApi/PubnubCoreBase.cs b/src/Api/PubnubApi/PubnubCoreBase.cs index 0b818f936..7ef15a636 100644 --- a/src/Api/PubnubApi/PubnubCoreBase.cs +++ b/src/Api/PubnubApi/PubnubCoreBase.cs @@ -430,6 +430,12 @@ private static List GetMessageFromMultiplexResult(List var _ = Int32.TryParse(dicItem[key].ToString(), out subscriptionTypeIndicator); msg.MessageType = subscriptionTypeIndicator; break; + case "mt": + if (dicItem[key] != null && !string.IsNullOrEmpty(dicItem[key].ToString())) + { + msg.Type = dicItem[key].ToString(); + } + break; case "f": msg.Flags = dicItem[key].ToString(); break; @@ -493,11 +499,16 @@ private static List GetMessageFromMultiplexResult(List case "u": msg.UserMetadata = dicItem[key]; break; + case "si": + if (dicItem[key] != null) + { + msg.SpaceId = dicItem[key].ToString(); + } + break; default: break; } } - msgList.Add(msg); } } @@ -747,6 +758,12 @@ private void ResponseToUserCallback(List result, PNOperationType type payloadContainer.Add(currentMessage.IssuingClientId); //Fourth one always Publisher + payloadContainer.Add(currentMessage.Type); //Fifth one always Type + + string currentSpaceId = currentMessage.SpaceId; + + payloadContainer.Add(string.IsNullOrEmpty(currentSpaceId) ? "" : currentSpaceId); //Six one always SpaceId + if (!string.IsNullOrEmpty(currentMessageChannelGroup)) //Add cg first before channel { payloadContainer.Add(currentMessageChannelGroup); @@ -770,7 +787,9 @@ private void ResponseToUserCallback(List result, PNOperationType type Subscription = pnMessageResult.Subscription, Timetoken = pnMessageResult.Timetoken, UserMetadata = pnMessageResult.UserMetadata, - Publisher = pnMessageResult.Publisher + Publisher = pnMessageResult.Publisher, + Type = pnMessageResult.Type, + SpaceId = pnMessageResult.SpaceId }; Announce(signalMessage); } From 9dd0d98f6d0abcdf39d99695b6db57995fc301ac Mon Sep 17 00:00:00 2001 From: Pandu Masabathula Date: Thu, 23 Mar 2023 14:33:47 +0530 Subject: [PATCH 2/4] Update SendFileOperation.cs --- .../EndPoint/Files/SendFileOperation.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Api/PubnubApi/EndPoint/Files/SendFileOperation.cs b/src/Api/PubnubApi/EndPoint/Files/SendFileOperation.cs index 05a6c3ba6..10dc916e2 100644 --- a/src/Api/PubnubApi/EndPoint/Files/SendFileOperation.cs +++ b/src/Api/PubnubApi/EndPoint/Files/SendFileOperation.cs @@ -31,6 +31,8 @@ public class SendFileOperation : PubnubCoreBase private bool storeInHistory = true; private Dictionary userMetadata; private int ttl = -1; + private string type = string.Empty; + private string spaceId = string.Empty; public SendFileOperation(PNConfiguration pubnubConfig, IJsonPluggableLibrary jsonPluggableLibrary, IPubnubUnitTest pubnubUnit, IPubnubLog log, EndPoint.TelemetryManager telemetryManager, EndPoint.TokenManager tokenManager, Pubnub instance) : base(pubnubConfig, jsonPluggableLibrary, pubnubUnit, log, telemetryManager, tokenManager, instance) { @@ -87,6 +89,17 @@ public SendFileOperation Ttl(int ttl) return this; } + public SendFileOperation Type(string type) + { + this.type = type; + return this; + } + public SendFileOperation SpaceId(string spaceId) + { + this.spaceId = spaceId; + return this; + } + public SendFileOperation File(string fileNameWithFullPath) { this.sendFileFullPath = fileNameWithFullPath; @@ -400,7 +413,7 @@ private async Task> PublishFileMessage(obje IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr, (PubnubInstance != null && !string.IsNullOrEmpty(PubnubInstance.InstanceId) && PubnubTokenMgrCollection.ContainsKey(PubnubInstance.InstanceId)) ? PubnubTokenMgrCollection[PubnubInstance.InstanceId] : null, (PubnubInstance != null) ? PubnubInstance.InstanceId : ""); - Uri request = urlBuilder.BuildPublishFileMessageRequest("GET", "", this.channelName, message, this.storeInHistory, this.ttl, this.userMetadata, null, externalQueryParam); + Uri request = urlBuilder.BuildPublishFileMessageRequest("GET", "", this.channelName, message, this.storeInHistory, this.ttl, this.userMetadata, this.type, this.spaceId, null, externalQueryParam); RequestState requestState = new RequestState(); requestState.Channels = new[] { this.channelName }; @@ -420,7 +433,9 @@ await UrlProcessRequest(request, requestState, false).ContinueWith(r => ResponseBuilder responseBuilder = new ResponseBuilder(config, jsonLibrary, pubnubLog); PNPublishFileMessageResult publishResult = responseBuilder.JsonToObject(result, true); StatusBuilder statusBuilder = new StatusBuilder(config, jsonLibrary); - if (publishResult != null) + if (result != null && + string.Compare(result[0].ToString(), "1", StringComparison.OrdinalIgnoreCase) == 0 && + publishResult != null) { ret.Result = publishResult; PNStatus status = statusBuilder.CreateStatusResponse(requestState.ResponseType, PNStatusCategory.PNAcknowledgmentCategory, requestState, (int)HttpStatusCode.OK, null); From 3f73ae3008e8af66720ff162d0fbde2ae6ad3ae7 Mon Sep 17 00:00:00 2001 From: Pandu Masabathula Date: Thu, 23 Mar 2023 19:54:47 +0530 Subject: [PATCH 3/4] Updated tests --- src/Api/PubnubApiPCL/PubnubApiPCL.csproj | 1 + src/Api/PubnubApiUWP/PubnubApiUWP.csproj | 3 + .../AcceptanceTests/AcceptanceTests.csproj | 11 +- .../Features/channel-metadata.feature.cs | 112 +--- .../Features/file-upload-to-space.feature | 22 + .../Features/file-upload-to-space.feature.cs | 193 ++++++ .../Features/grant-token.feature.cs | 127 +--- .../Features/history-vsp.feature | 37 ++ .../Features/history-vsp.feature.cs | 244 ++++++++ .../Features/members-metadata.feature.cs | 112 +--- .../Features/membership-metadata.feature.cs | 144 +---- .../Features/publish-to-space.feature | 82 +++ .../Features/publish-to-space.feature.cs | 590 ++++++++++++++++++ .../AcceptanceTests/Features/publish.feature | 29 + .../Features/publish.feature.cs | 216 +++++++ .../Features/revoke-token.feature.cs | 80 +-- .../Features/signal-to-space.feature | 82 +++ .../Features/signal-to-space.feature.cs | 590 ++++++++++++++++++ .../AcceptanceTests/Features/signal.feature | 11 + .../Features/signal.feature.cs | 115 ++++ .../Features/subscribe-vsp.feature | 15 + .../Features/subscribe-vsp.feature.cs | 131 ++++ .../Features/uuid-metadata.feature.cs | 128 +--- .../Steps/FetchHistoryForVSPSteps.cs | 428 +++++++++++++ .../Steps/ObjectsV2UuidMetadataSteps.cs | 4 + .../Steps/PublishAMessageSteps.cs | 252 ++++++++ .../Steps/PublishToSpaceSteps.cs | 47 ++ .../Steps/SendAFileToSpaceSteps.cs | 192 ++++++ .../AcceptanceTests/Steps/SignalSteps.cs | 182 ++++++ .../Steps/SignalToSpaceSteps.cs | 191 ++++++ .../Steps/SubscribeForVSPSteps.cs | 277 ++++++++ src/UnitTests/AcceptanceTests/fileupload.txt | 1 + .../WhenFetchHistoryIsRequested.cs | 90 +-- 33 files changed, 4143 insertions(+), 596 deletions(-) create mode 100644 src/UnitTests/AcceptanceTests/Features/file-upload-to-space.feature create mode 100644 src/UnitTests/AcceptanceTests/Features/file-upload-to-space.feature.cs create mode 100644 src/UnitTests/AcceptanceTests/Features/history-vsp.feature create mode 100644 src/UnitTests/AcceptanceTests/Features/history-vsp.feature.cs create mode 100644 src/UnitTests/AcceptanceTests/Features/publish-to-space.feature create mode 100644 src/UnitTests/AcceptanceTests/Features/publish-to-space.feature.cs create mode 100644 src/UnitTests/AcceptanceTests/Features/publish.feature create mode 100644 src/UnitTests/AcceptanceTests/Features/publish.feature.cs create mode 100644 src/UnitTests/AcceptanceTests/Features/signal-to-space.feature create mode 100644 src/UnitTests/AcceptanceTests/Features/signal-to-space.feature.cs create mode 100644 src/UnitTests/AcceptanceTests/Features/signal.feature create mode 100644 src/UnitTests/AcceptanceTests/Features/signal.feature.cs create mode 100644 src/UnitTests/AcceptanceTests/Features/subscribe-vsp.feature create mode 100644 src/UnitTests/AcceptanceTests/Features/subscribe-vsp.feature.cs create mode 100644 src/UnitTests/AcceptanceTests/Steps/FetchHistoryForVSPSteps.cs create mode 100644 src/UnitTests/AcceptanceTests/Steps/PublishAMessageSteps.cs create mode 100644 src/UnitTests/AcceptanceTests/Steps/PublishToSpaceSteps.cs create mode 100644 src/UnitTests/AcceptanceTests/Steps/SendAFileToSpaceSteps.cs create mode 100644 src/UnitTests/AcceptanceTests/Steps/SignalSteps.cs create mode 100644 src/UnitTests/AcceptanceTests/Steps/SignalToSpaceSteps.cs create mode 100644 src/UnitTests/AcceptanceTests/Steps/SubscribeForVSPSteps.cs create mode 100644 src/UnitTests/AcceptanceTests/fileupload.txt diff --git a/src/Api/PubnubApiPCL/PubnubApiPCL.csproj b/src/Api/PubnubApiPCL/PubnubApiPCL.csproj index 8330aaa89..00fe6787f 100644 --- a/src/Api/PubnubApiPCL/PubnubApiPCL.csproj +++ b/src/Api/PubnubApiPCL/PubnubApiPCL.csproj @@ -307,6 +307,7 @@ Added TcpKeepAlive and ConnectionLimit to improve performance. + Model\Consumer\History\PNHistoryItemResult.cs diff --git a/src/Api/PubnubApiUWP/PubnubApiUWP.csproj b/src/Api/PubnubApiUWP/PubnubApiUWP.csproj index 545a8d30a..25976b99f 100644 --- a/src/Api/PubnubApiUWP/PubnubApiUWP.csproj +++ b/src/Api/PubnubApiUWP/PubnubApiUWP.csproj @@ -422,6 +422,9 @@ Added TcpKeepAlive and ConnectionLimit to improve performance. + + Model\Consumer\History\PNFetchHistoryItemResult.cs + Model\Consumer\History\PNHistoryItemResult.cs diff --git a/src/UnitTests/AcceptanceTests/AcceptanceTests.csproj b/src/UnitTests/AcceptanceTests/AcceptanceTests.csproj index b5169b946..bb9721ce6 100644 --- a/src/UnitTests/AcceptanceTests/AcceptanceTests.csproj +++ b/src/UnitTests/AcceptanceTests/AcceptanceTests.csproj @@ -10,22 +10,22 @@ - + - + - + - + @@ -88,6 +88,9 @@ Always + + Always + \ No newline at end of file diff --git a/src/UnitTests/AcceptanceTests/Features/channel-metadata.feature.cs b/src/UnitTests/AcceptanceTests/Features/channel-metadata.feature.cs index 93206af86..fd47689f4 100644 --- a/src/UnitTests/AcceptanceTests/Features/channel-metadata.feature.cs +++ b/src/UnitTests/AcceptanceTests/Features/channel-metadata.feature.cs @@ -28,7 +28,7 @@ public partial class ObjectsV2ChannelMetadataFeature private TechTalk.SpecFlow.ITestRunner testRunner; - private string[] _featureTags = new string[] { + private static string[] featureTags = new string[] { "featureSet=objectsV2", "beta"}; @@ -39,9 +39,7 @@ public partial class ObjectsV2ChannelMetadataFeature 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"}); + 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, featureTags); testRunner.OnFeatureStart(featureInfo); } @@ -53,28 +51,28 @@ public virtual void FeatureTearDown() } [NUnit.Framework.SetUpAttribute()] - public virtual void TestInitialize() + public void TestInitialize() { } [NUnit.Framework.TearDownAttribute()] - public virtual void TestTearDown() + public void TestTearDown() { testRunner.OnScenarioEnd(); } - public virtual void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + public void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) { testRunner.OnScenarioInitialize(scenarioInfo); testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); } - public virtual void ScenarioStart() + public void ScenarioStart() { testRunner.OnScenarioStart(); } - public virtual void ScenarioCleanup() + public void ScenarioCleanup() { testRunner.CollectScenarioErrors(); } @@ -91,26 +89,16 @@ public virtual void FeatureBackground() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Get a channel metadata for id")] [NUnit.Framework.CategoryAttribute("contract=getChannelMetadataOfChat")] - public virtual void GetAChannelMetadataForId() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get a channel metadata for id", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -139,26 +127,16 @@ public virtual void GetAChannelMetadataForId() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Get a channel with custom metadata")] [NUnit.Framework.CategoryAttribute("contract=getChannelMetadataOfDMWithCustom")] - public virtual void GetAChannelWithCustomMetadata() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get a channel with custom metadata", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -187,26 +165,16 @@ public virtual void GetAChannelWithCustomMetadata() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Set a channel metadata")] [NUnit.Framework.CategoryAttribute("contract=setChannelMetadataForChat")] - public virtual void SetAChannelMetadata() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Set a channel metadata", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -235,26 +203,16 @@ public virtual void SetAChannelMetadata() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Remove a channel metadata for id")] [NUnit.Framework.CategoryAttribute("contract=removeChannelMetadataOfChat")] - public virtual void RemoveAChannelMetadataForId() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Remove a channel metadata for id", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -280,26 +238,16 @@ public virtual void RemoveAChannelMetadataForId() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Get all channel metadata")] [NUnit.Framework.CategoryAttribute("contract=getAllChannelMetadata")] - public virtual void GetAllChannelMetadata() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get all channel metadata", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -325,26 +273,16 @@ public virtual void GetAllChannelMetadata() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Get all channel metadata with custom")] [NUnit.Framework.CategoryAttribute("contract=getAllChannelMetadataWithCustom")] - public virtual void GetAllChannelMetadataWithCustom() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get all channel metadata with custom", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } diff --git a/src/UnitTests/AcceptanceTests/Features/file-upload-to-space.feature b/src/UnitTests/AcceptanceTests/Features/file-upload-to-space.feature new file mode 100644 index 000000000..5611af8fb --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/file-upload-to-space.feature @@ -0,0 +1,22 @@ +@featureSet=files @beta + Feature: Send a file to Space + As a PubNub user I want to send a file to Space with message type. + Client should be able to pass optional spaceId and type to the File endpoint. + + Background: + Given the demo keyset + + @contract=sendFileWithSpaceIdAndType + Scenario: Send a file to space success + When I send a file with 'space-id' space id and 'test_message_type' type + Then I receive a successful response + + @contract=sendFileWithTooShortType + Scenario: Send a file to space fails when message type is too short, shorten than 3 characters + When I send a file with 'space-id' space id and 'ts' type + Then I receive an error response + + @contract=sendFileWithTooLongType + Scenario: Send a file to space fails when message type is too long, longer than 50 characters + When I send a file with 'space-id' space id and 'this-is-really-long-message-type-to-be-used-with-publish' type + Then I receive an error response \ No newline at end of file diff --git a/src/UnitTests/AcceptanceTests/Features/file-upload-to-space.feature.cs b/src/UnitTests/AcceptanceTests/Features/file-upload-to-space.feature.cs new file mode 100644 index 000000000..c4ec32649 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/file-upload-to-space.feature.cs @@ -0,0 +1,193 @@ +// ------------------------------------------------------------------------------ +// +// 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("Send a file to Space")] + [NUnit.Framework.CategoryAttribute("featureSet=files")] + [NUnit.Framework.CategoryAttribute("beta")] + public partial class SendAFileToSpaceFeature + { + + private TechTalk.SpecFlow.ITestRunner testRunner; + + private static string[] featureTags = new string[] { + "featureSet=files", + "beta"}; + +#line 1 "file-upload-to-space.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", "Send a file to Space", " As a PubNub user I want to send a file to Space with message type.\r\n Clien" + + "t should be able to pass optional spaceId and type to the File endpoint.", ProgrammingLanguage.CSharp, featureTags); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.OneTimeTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public void TestTearDown() + { + testRunner.OnScenarioEnd(); + } + + public void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioInitialize(scenarioInfo); + testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); + } + + public void ScenarioStart() + { + testRunner.OnScenarioStart(); + } + + public void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + public virtual void FeatureBackground() + { +#line 6 + #line hidden +#line 7 + testRunner.Given("the demo keyset", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Send a file to space success")] + [NUnit.Framework.CategoryAttribute("contract=sendFileWithSpaceIdAndType")] + public void SendAFileToSpaceSuccess() + { + string[] tagsOfScenario = new string[] { + "contract=sendFileWithSpaceIdAndType"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Send a file to space success", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 10 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 11 + testRunner.When("I send a file with \'space-id\' space id and \'test_message_type\' type", ((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 + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Send a file to space fails when message type is too short, shorten than 3 charact" + + "ers")] + [NUnit.Framework.CategoryAttribute("contract=sendFileWithTooShortType")] + public void SendAFileToSpaceFailsWhenMessageTypeIsTooShortShortenThan3Characters() + { + string[] tagsOfScenario = new string[] { + "contract=sendFileWithTooShortType"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Send a file to space fails when message type is too short, shorten than 3 charact" + + "ers", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 15 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 16 + testRunner.When("I send a file with \'space-id\' space id and \'ts\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 17 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Send a file to space fails when message type is too long, longer than 50 characte" + + "rs")] + [NUnit.Framework.CategoryAttribute("contract=sendFileWithTooLongType")] + public void SendAFileToSpaceFailsWhenMessageTypeIsTooLongLongerThan50Characters() + { + string[] tagsOfScenario = new string[] { + "contract=sendFileWithTooLongType"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Send a file to space fails when message type is too long, longer than 50 characte" + + "rs", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 20 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 21 + testRunner.When("I send a file with \'space-id\' space id and \'this-is-really-long-message-type-to-b" + + "e-used-with-publish\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 22 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/src/UnitTests/AcceptanceTests/Features/grant-token.feature.cs b/src/UnitTests/AcceptanceTests/Features/grant-token.feature.cs index 299ba3b92..a1aaaf549 100644 --- a/src/UnitTests/AcceptanceTests/Features/grant-token.feature.cs +++ b/src/UnitTests/AcceptanceTests/Features/grant-token.feature.cs @@ -27,7 +27,7 @@ public partial class GrantAnAccessTokenFeature private TechTalk.SpecFlow.ITestRunner testRunner; - private string[] _featureTags = new string[] { + private static string[] featureTags = new string[] { "featureSet=access"}; #line 1 "grant-token.feature" @@ -39,8 +39,7 @@ public virtual void FeatureSetup() testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Features", "Grant an access token", " As a PubNub customer I want to restrict and allow access to\r\n specific PubNub " + "resources (channels, channel groups, uuids)\r\n by my user base (both people and " + - "devices) which are each\r\n identified by a unique UUID.", ProgrammingLanguage.CSharp, new string[] { - "featureSet=access"}); + "devices) which are each\r\n identified by a unique UUID.", ProgrammingLanguage.CSharp, featureTags); testRunner.OnFeatureStart(featureInfo); } @@ -52,28 +51,28 @@ public virtual void FeatureTearDown() } [NUnit.Framework.SetUpAttribute()] - public virtual void TestInitialize() + public void TestInitialize() { } [NUnit.Framework.TearDownAttribute()] - public virtual void TestTearDown() + public void TestTearDown() { testRunner.OnScenarioEnd(); } - public virtual void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + public void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) { testRunner.OnScenarioInitialize(scenarioInfo); testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); } - public virtual void ScenarioStart() + public void ScenarioStart() { testRunner.OnScenarioStart(); } - public virtual void ScenarioCleanup() + public void ScenarioCleanup() { testRunner.CollectScenarioErrors(); } @@ -91,27 +90,17 @@ public virtual void FeatureBackground() [NUnit.Framework.DescriptionAttribute("Grant an access token with all permissions on all resource types with authorized " + "uuid")] [NUnit.Framework.CategoryAttribute("contract=grantAllPermissions")] - public virtual void GrantAnAccessTokenWithAllPermissionsOnAllResourceTypesWithAuthorizedUuid() + public void GrantAnAccessTokenWithAllPermissionsOnAllResourceTypesWithAuthorizedUuid() { string[] tagsOfScenario = new string[] { "contract=grantAllPermissions"}; System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Grant an access token with all permissions on all resource types with authorized " + - "uuid", null, tagsOfScenario, argumentsOfScenario, this._featureTags); + "uuid", null, tagsOfScenario, argumentsOfScenario, featureTags); #line 12 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -323,26 +312,16 @@ public virtual void GrantAnAccessTokenWithAllPermissionsOnAllResourceTypesWithAu [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Grant an access token without an authorized uuid")] [NUnit.Framework.CategoryAttribute("contract=grantWithoutAuthorizedUUID")] - public virtual void GrantAnAccessTokenWithoutAnAuthorizedUuid() + public void GrantAnAccessTokenWithoutAnAuthorizedUuid() { string[] tagsOfScenario = new string[] { "contract=grantWithoutAuthorizedUUID"}; System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Grant an access token without an authorized uuid", null, tagsOfScenario, argumentsOfScenario, this._featureTags); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Grant an access token without an authorized uuid", null, tagsOfScenario, argumentsOfScenario, featureTags); #line 81 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -383,26 +362,16 @@ public virtual void GrantAnAccessTokenWithoutAnAuthorizedUuid() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Grant an access token successfully with an authorized uuid")] [NUnit.Framework.CategoryAttribute("contract=grantWithAuthorizedUUID")] - public virtual void GrantAnAccessTokenSuccessfullyWithAnAuthorizedUuid() + public void GrantAnAccessTokenSuccessfullyWithAnAuthorizedUuid() { string[] tagsOfScenario = new string[] { "contract=grantWithAuthorizedUUID"}; System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Grant an access token successfully with an authorized uuid", null, tagsOfScenario, argumentsOfScenario, this._featureTags); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Grant an access token successfully with an authorized uuid", null, tagsOfScenario, argumentsOfScenario, featureTags); #line 92 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -447,27 +416,17 @@ public virtual void GrantAnAccessTokenSuccessfullyWithAnAuthorizedUuid() [NUnit.Framework.DescriptionAttribute("Attempt to grant an access token with all permissions empty or false and expect a" + " server error")] [NUnit.Framework.CategoryAttribute("contract=grantWithoutAnyPermissionsError")] - public virtual void AttemptToGrantAnAccessTokenWithAllPermissionsEmptyOrFalseAndExpectAServerError() + public void AttemptToGrantAnAccessTokenWithAllPermissionsEmptyOrFalseAndExpectAServerError() { string[] tagsOfScenario = new string[] { "contract=grantWithoutAnyPermissionsError"}; System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Attempt to grant an access token with all permissions empty or false and expect a" + - " server error", null, tagsOfScenario, argumentsOfScenario, this._featureTags); + " server error", null, tagsOfScenario, argumentsOfScenario, featureTags); #line 104 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -519,27 +478,17 @@ public virtual void AttemptToGrantAnAccessTokenWithAllPermissionsEmptyOrFalseAnd [NUnit.Framework.DescriptionAttribute("Attempt to grant an access token with a regular expression containing a syntax er" + "ror and expect a server error")] [NUnit.Framework.CategoryAttribute("contract=grantWithRegExpSyntaxError")] - public virtual void AttemptToGrantAnAccessTokenWithARegularExpressionContainingASyntaxErrorAndExpectAServerError() + public void AttemptToGrantAnAccessTokenWithARegularExpressionContainingASyntaxErrorAndExpectAServerError() { string[] tagsOfScenario = new string[] { "contract=grantWithRegExpSyntaxError"}; System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Attempt to grant an access token with a regular expression containing a syntax er" + - "ror and expect a server error", null, tagsOfScenario, argumentsOfScenario, this._featureTags); + "ror and expect a server error", null, tagsOfScenario, argumentsOfScenario, featureTags); #line 118 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -590,27 +539,17 @@ public virtual void AttemptToGrantAnAccessTokenWithARegularExpressionContainingA [NUnit.Framework.DescriptionAttribute("Attempt to grant an access token with a regular expression containing capturing g" + "roups and expect a server error")] [NUnit.Framework.CategoryAttribute("contract=grantWithRegExpNonCapturingError")] - public virtual void AttemptToGrantAnAccessTokenWithARegularExpressionContainingCapturingGroupsAndExpectAServerError() + public void AttemptToGrantAnAccessTokenWithARegularExpressionContainingCapturingGroupsAndExpectAServerError() { string[] tagsOfScenario = new string[] { "contract=grantWithRegExpNonCapturingError"}; System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Attempt to grant an access token with a regular expression containing capturing g" + - "roups and expect a server error", null, tagsOfScenario, argumentsOfScenario, this._featureTags); + "roups and expect a server error", null, tagsOfScenario, argumentsOfScenario, featureTags); #line 132 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -663,28 +602,18 @@ public virtual void AttemptToGrantAnAccessTokenWithARegularExpressionContainingC " (use default max 43200 for the test)")] [NUnit.Framework.CategoryAttribute("contract=grantWithTTLExceedMaxTTL")] [NUnit.Framework.CategoryAttribute("beta")] - public virtual void AttemptToGrantAnAccessTokenWhenTtlProvidedExceedsTheMaxTtlConfiguredUseDefaultMax43200ForTheTest() + public void AttemptToGrantAnAccessTokenWhenTtlProvidedExceedsTheMaxTtlConfiguredUseDefaultMax43200ForTheTest() { string[] tagsOfScenario = new string[] { "contract=grantWithTTLExceedMaxTTL", "beta"}; System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Attempt to grant an access token when ttl provided exceeds the max ttl configured" + - " (use default max 43200 for the test)", null, tagsOfScenario, argumentsOfScenario, this._featureTags); + " (use default max 43200 for the test)", null, tagsOfScenario, argumentsOfScenario, featureTags); #line 146 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } diff --git a/src/UnitTests/AcceptanceTests/Features/history-vsp.feature b/src/UnitTests/AcceptanceTests/Features/history-vsp.feature new file mode 100644 index 000000000..018a53f8e --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/history-vsp.feature @@ -0,0 +1,37 @@ +@featureSet=historyVSP @beta +Feature: History for VSP + As a PubNub user I want to fetch history with message type and space id information. + Client should be able to opt-out default `includeType` and specify whether space id should + be returned with `includeSpaceId`. + + Background: + Given the demo keyset with enabled storage + + @contract=fetchHistoryWithPubNubMessageTypes + Scenario: Client can fetch history with message types + When I fetch message history for 'simple-channel' channel + Then I receive a successful response + And history response contains messages with '0' and '4' message types + And history response contains messages without space ids + + @contract=fetchHistoryWithUserAndPubNubTypes + Scenario: Client can fetch history with types + When I fetch message history for 'vsp-channel' channel + Then I receive a successful response + And history response contains messages with 'custom-message' and 'vc-message' types + And history response contains messages without space ids + + @contract=fetchHistoryWithoutTypes + Scenario: Client can fetch history without types enabled by default + When I fetch message history with 'includeType' set to 'false' for 'vsp-channel' channel + Then I receive a successful response + And history response contains messages without types + And history response contains messages without space ids + + @contract=fetchHistoryWithSpaceId + Scenario: Client can fetch history with space id disabled by default + When I fetch message history with 'includeSpaceId' set to 'true' for 'vsp-channel' channel + Then I receive a successful response + And history response contains messages with space ids + + diff --git a/src/UnitTests/AcceptanceTests/Features/history-vsp.feature.cs b/src/UnitTests/AcceptanceTests/Features/history-vsp.feature.cs new file mode 100644 index 000000000..558be8142 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/history-vsp.feature.cs @@ -0,0 +1,244 @@ +// ------------------------------------------------------------------------------ +// +// 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("History for VSP")] + [NUnit.Framework.CategoryAttribute("featureSet=historyVSP")] + [NUnit.Framework.CategoryAttribute("beta")] + public partial class HistoryForVSPFeature + { + + private TechTalk.SpecFlow.ITestRunner testRunner; + + private static string[] featureTags = new string[] { + "featureSet=historyVSP", + "beta"}; + +#line 1 "history-vsp.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", "History for VSP", " As a PubNub user I want to fetch history with message type and space id informa" + + "tion.\r\n Client should be able to opt-out default `includeType` and specify whet" + + "her space id should\r\n be returned with `includeSpaceId`.", ProgrammingLanguage.CSharp, featureTags); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.OneTimeTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public void TestTearDown() + { + testRunner.OnScenarioEnd(); + } + + public void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioInitialize(scenarioInfo); + testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); + } + + public void ScenarioStart() + { + testRunner.OnScenarioStart(); + } + + public void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + public virtual void FeatureBackground() + { +#line 7 + #line hidden +#line 8 + testRunner.Given("the demo keyset with enabled storage", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Client can fetch history with message types")] + [NUnit.Framework.CategoryAttribute("contract=fetchHistoryWithPubNubMessageTypes")] + public void ClientCanFetchHistoryWithMessageTypes() + { + string[] tagsOfScenario = new string[] { + "contract=fetchHistoryWithPubNubMessageTypes"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Client can fetch history with message types", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 11 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 7 + this.FeatureBackground(); +#line hidden +#line 12 + testRunner.When("I fetch message history for \'simple-channel\' channel", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 13 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 14 + testRunner.And("history response contains messages with \'0\' and \'4\' message types", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden +#line 15 + testRunner.And("history response contains messages without space ids", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Client can fetch history with types")] + [NUnit.Framework.CategoryAttribute("contract=fetchHistoryWithUserAndPubNubTypes")] + public void ClientCanFetchHistoryWithTypes() + { + string[] tagsOfScenario = new string[] { + "contract=fetchHistoryWithUserAndPubNubTypes"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Client can fetch history with types", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 18 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 7 + this.FeatureBackground(); +#line hidden +#line 19 + testRunner.When("I fetch message history for \'vsp-channel\' channel", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 20 + testRunner.Then("I receive a successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 21 + testRunner.And("history response contains messages with \'custom-message\' and \'vc-message\' types", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden +#line 22 + testRunner.And("history response contains messages without space ids", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Client can fetch history without types enabled by default")] + [NUnit.Framework.CategoryAttribute("contract=fetchHistoryWithoutTypes")] + public void ClientCanFetchHistoryWithoutTypesEnabledByDefault() + { + string[] tagsOfScenario = new string[] { + "contract=fetchHistoryWithoutTypes"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Client can fetch history without types enabled by default", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 25 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 7 + this.FeatureBackground(); +#line hidden +#line 26 + testRunner.When("I fetch message history with \'includeType\' set to \'false\' for \'vsp-channel\' chann" + + "el", ((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("history response contains messages without types", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden +#line 29 + testRunner.And("history response contains messages without space ids", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Client can fetch history with space id disabled by default")] + [NUnit.Framework.CategoryAttribute("contract=fetchHistoryWithSpaceId")] + public void ClientCanFetchHistoryWithSpaceIdDisabledByDefault() + { + string[] tagsOfScenario = new string[] { + "contract=fetchHistoryWithSpaceId"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Client can fetch history with space id disabled by default", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 32 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 7 + this.FeatureBackground(); +#line hidden +#line 33 + testRunner.When("I fetch message history with \'includeSpaceId\' set to \'true\' for \'vsp-channel\' cha" + + "nnel", ((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("history response contains messages with space ids", ((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.cs b/src/UnitTests/AcceptanceTests/Features/members-metadata.feature.cs index 9cfab7e41..c391514fc 100644 --- a/src/UnitTests/AcceptanceTests/Features/members-metadata.feature.cs +++ b/src/UnitTests/AcceptanceTests/Features/members-metadata.feature.cs @@ -28,7 +28,7 @@ public partial class ObjectsV2MembersFeature private TechTalk.SpecFlow.ITestRunner testRunner; - private string[] _featureTags = new string[] { + private static string[] featureTags = new string[] { "featureSet=objectsV2", "beta"}; @@ -40,9 +40,7 @@ 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"}); + "UIDs).", ProgrammingLanguage.CSharp, featureTags); testRunner.OnFeatureStart(featureInfo); } @@ -54,28 +52,28 @@ public virtual void FeatureTearDown() } [NUnit.Framework.SetUpAttribute()] - public virtual void TestInitialize() + public void TestInitialize() { } [NUnit.Framework.TearDownAttribute()] - public virtual void TestTearDown() + public void TestTearDown() { testRunner.OnScenarioEnd(); } - public virtual void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + public void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) { testRunner.OnScenarioInitialize(scenarioInfo); testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); } - public virtual void ScenarioStart() + public void ScenarioStart() { testRunner.OnScenarioStart(); } - public virtual void ScenarioCleanup() + public void ScenarioCleanup() { testRunner.CollectScenarioErrors(); } @@ -92,26 +90,16 @@ public virtual void FeatureBackground() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Get members for a channel")] [NUnit.Framework.CategoryAttribute("contract=getMembersOfChatChannel")] - public virtual void GetMembersForAChannel() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get members for a channel", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -140,26 +128,16 @@ public virtual void GetMembersForAChannel() [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() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get members for VipChat channel with custom and UUID with custom", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -188,26 +166,16 @@ public virtual void GetMembersForVipChatChannelWithCustomAndUUIDWithCustom() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Set member for a channel")] [NUnit.Framework.CategoryAttribute("contract=setMembersForChatChannel")] - public virtual void SetMemberForAChannel() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Set member for a channel", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -239,26 +207,16 @@ public virtual void SetMemberForAChannel() [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() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Set member with custom for a channel and UUID with custom", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -290,26 +248,16 @@ public virtual void SetMemberWithCustomForAChannelAndUUIDWithCustom() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Remove member for a channel")] [NUnit.Framework.CategoryAttribute("contract=removeMembersForChatChannel")] - public virtual void RemoveMemberForAChannel() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Remove member for a channel", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -340,28 +288,18 @@ public virtual void RemoveMemberForAChannel() [NUnit.Framework.CategoryAttribute("contract=manageMembersForChatChannel")] [NUnit.Framework.CategoryAttribute("na=ruby")] [NUnit.Framework.CategoryAttribute("na=js")] - public virtual void ManageMembersForAChannel() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Manage members for a channel", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } diff --git a/src/UnitTests/AcceptanceTests/Features/membership-metadata.feature.cs b/src/UnitTests/AcceptanceTests/Features/membership-metadata.feature.cs index 95db4c1c9..3b0874e95 100644 --- a/src/UnitTests/AcceptanceTests/Features/membership-metadata.feature.cs +++ b/src/UnitTests/AcceptanceTests/Features/membership-metadata.feature.cs @@ -28,7 +28,7 @@ public partial class ObjectsV2MembershipsFeature private TechTalk.SpecFlow.ITestRunner testRunner; - private string[] _featureTags = new string[] { + private static string[] featureTags = new string[] { "featureSet=objectsV2", "beta"}; @@ -39,9 +39,7 @@ public partial class ObjectsV2MembershipsFeature 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"}); + 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, featureTags); testRunner.OnFeatureStart(featureInfo); } @@ -53,28 +51,28 @@ public virtual void FeatureTearDown() } [NUnit.Framework.SetUpAttribute()] - public virtual void TestInitialize() + public void TestInitialize() { } [NUnit.Framework.TearDownAttribute()] - public virtual void TestTearDown() + public void TestTearDown() { testRunner.OnScenarioEnd(); } - public virtual void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + public void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) { testRunner.OnScenarioInitialize(scenarioInfo); testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); } - public virtual void ScenarioStart() + public void ScenarioStart() { testRunner.OnScenarioStart(); } - public virtual void ScenarioCleanup() + public void ScenarioCleanup() { testRunner.CollectScenarioErrors(); } @@ -91,26 +89,16 @@ public virtual void FeatureBackground() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Get memberships for UUID")] [NUnit.Framework.CategoryAttribute("contract=getAliceMemberships")] - public virtual void GetMembershipsForUUID() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get memberships for UUID", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -140,26 +128,16 @@ public virtual void GetMembershipsForUUID() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Get memberships for current user")] [NUnit.Framework.CategoryAttribute("contract=getAliceMemberships")] - public virtual void GetMembershipsForCurrentUser() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get memberships for current user", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -189,26 +167,16 @@ public virtual void GetMembershipsForCurrentUser() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Get memberships for UUID with custom and channel custom")] [NUnit.Framework.CategoryAttribute("contract=getBobMembershipWithCustomAndChannelCustom")] - public virtual void GetMembershipsForUUIDWithCustomAndChannelCustom() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get memberships for UUID with custom and channel custom", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -238,26 +206,16 @@ public virtual void GetMembershipsForUUIDWithCustomAndChannelCustom() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Set membership")] [NUnit.Framework.CategoryAttribute("contract=setAliceMembership")] - public virtual void SetMembership() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Set membership", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -289,26 +247,16 @@ public virtual void SetMembership() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Set membership for current user")] [NUnit.Framework.CategoryAttribute("contract=setAliceMembership")] - public virtual void SetMembershipForCurrentUser() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Set membership for current user", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -340,26 +288,16 @@ public virtual void SetMembershipForCurrentUser() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Remove membership")] [NUnit.Framework.CategoryAttribute("contract=removeAliceMembership")] - public virtual void RemoveMembership() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Remove membership", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -388,26 +326,16 @@ public virtual void RemoveMembership() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Remove membership for current user")] [NUnit.Framework.CategoryAttribute("contract=removeAliceMembership")] - public virtual void RemoveMembershipForCurrentUser() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Remove membership for current user", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -436,26 +364,16 @@ public virtual void RemoveMembershipForCurrentUser() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Manage memberships for a UUID")] [NUnit.Framework.CategoryAttribute("contract=manageAliceMemberships")] - public virtual void ManageMembershipsForAUUID() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Manage memberships for a UUID", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } diff --git a/src/UnitTests/AcceptanceTests/Features/publish-to-space.feature b/src/UnitTests/AcceptanceTests/Features/publish-to-space.feature new file mode 100644 index 000000000..de0fb1a9c --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/publish-to-space.feature @@ -0,0 +1,82 @@ +@featureSet=publishToSpace @beta +Feature: Publish to Space + As a PubNub user I want to publish messages to Space with type. + Client should be able to pass optional spaceId and type to publish endpoint. + + Background: + Given the demo keyset + + @contract=publishWithSpaceIdAndType + Scenario: Publish message to space success + When I publish message with 'space-id' space id and 'test_step' type + Then I receive a successful response + + @contract=publishWithTooShortType + Scenario: Publish message to space fails when type is too short + When I publish message with 'test-space' space id and 'ts' type + Then I receive an error response + + @contract=publishWithTooLongType + Scenario: Publish message to space fails when type is too long + When I publish message with 'test-space' space id and 'this-is-really-long-message-type-to-be-used-with-publish' type + Then I receive an error response + + @contract=publishWithTooShortSpaceId + Scenario: Publish message to space fails when space id is too short + When I publish message with 'ts' space id and 'test-step' type + Then I receive an error response + + @contract=publishWithTooLongSpaceId + Scenario: Publish message to space fails when space id is too long + When I publish message with 'this-is-really-long-identifier-for-space-id-to-be-used-with-publish' space id and 'test-step' type + Then I receive an error response + + @contract=publishWithSpaceIdStartingWithReservedStrings + Scenario: Publish message to space fails when space id starts with reserved 'pn-' (hyphen) string + When I publish message with 'pn-test-space' space id and 'test-step' type + Then I receive an error response + + @contract=publishWithSpaceIdStartingWithReservedStrings + Scenario: Publish message to space fails when space id starts with reserved 'pn_' (underscore) string + When I publish message with 'pn_test-space' space id and 'test-step' type + Then I receive an error response + + @contract=publishWithSpaceIdStartingWithNotAllowedCharacter + Scenario: Publish message to space fails when space id starts with not allowed '-' (hyphen) character + When I publish message with '-test-space' space id and 'test-step' type + Then I receive an error response + + @contract=publishWithSpaceIdStartingWithNotAllowedCharacter + Scenario: Publish message to space fails when space id starts with not allowed '_' (underscore) character + When I publish message with '_test-space' space id and 'test-step' type + Then I receive an error response + + @contract=publishWithSpaceIdContainingNotAllowedCharacter + Scenario: Publish message to space fails when space id contains not allowed characters + When I publish message with 'test@space.com' space id and 'test-step' type + Then I receive an error response + + @contract=publishWithTypeStartingWithReservedStrings + Scenario: Publish message to space fails when type starts with reserved 'pn-' (hyphen) string + When I publish message with 'test-space' space id and 'pn-test-step' type + Then I receive an error response + + @contract=publishWithTypeStartingWithReservedStrings + Scenario: Publish message to space fails when type starts with reserved 'pn_' (underscore) string + When I publish message with 'test-space' space id and 'pn_test-step' type + Then I receive an error response + + @contract=publishWithTypeStartingWithNotAllowedCharacter + Scenario: Publish message to space fails when type starts with not allowed '-' (hyphen) character + When I publish message with 'test-space' space id and '-test-step' type + Then I receive an error response + + @contract=publishWithTypeStartingWithNotAllowedCharacter + Scenario: Publish message to space fails when type starts with not allowed '_' (underscore) character + When I publish message with 'test-space' space id and '_test-step' type + Then I receive an error response + + @contract=publishWithTypeContainingNotAllowedCharacter + Scenario: Publish message to space fails when type contains not allowed characters + When I publish message with 'test-space' space id and 'test:step' type + Then I receive an error response diff --git a/src/UnitTests/AcceptanceTests/Features/publish-to-space.feature.cs b/src/UnitTests/AcceptanceTests/Features/publish-to-space.feature.cs new file mode 100644 index 000000000..fa2cb6f9e --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/publish-to-space.feature.cs @@ -0,0 +1,590 @@ +// ------------------------------------------------------------------------------ +// +// 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("Publish to Space")] + [NUnit.Framework.CategoryAttribute("featureSet=publishToSpace")] + [NUnit.Framework.CategoryAttribute("beta")] + public partial class PublishToSpaceFeature + { + + private TechTalk.SpecFlow.ITestRunner testRunner; + + private static string[] featureTags = new string[] { + "featureSet=publishToSpace", + "beta"}; + +#line 1 "publish-to-space.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", "Publish to Space", " As a PubNub user I want to publish messages to Space with type.\r\n Client shoul" + + "d be able to pass optional spaceId and type to publish endpoint.", ProgrammingLanguage.CSharp, featureTags); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.OneTimeTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public void TestTearDown() + { + testRunner.OnScenarioEnd(); + } + + public void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioInitialize(scenarioInfo); + testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); + } + + public void ScenarioStart() + { + testRunner.OnScenarioStart(); + } + + public void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + public virtual void FeatureBackground() + { +#line 6 + #line hidden +#line 7 + testRunner.Given("the demo keyset", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Publish message to space success")] + [NUnit.Framework.CategoryAttribute("contract=publishWithSpaceIdAndType")] + public void PublishMessageToSpaceSuccess() + { + string[] tagsOfScenario = new string[] { + "contract=publishWithSpaceIdAndType"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Publish message to space success", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 10 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 11 + testRunner.When("I publish message with \'space-id\' space id and \'test_step\' type", ((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 + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Publish message to space fails when type is too short")] + [NUnit.Framework.CategoryAttribute("contract=publishWithTooShortType")] + public void PublishMessageToSpaceFailsWhenTypeIsTooShort() + { + string[] tagsOfScenario = new string[] { + "contract=publishWithTooShortType"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Publish message to space fails when type is too short", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 15 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 16 + testRunner.When("I publish message with \'test-space\' space id and \'ts\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 17 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Publish message to space fails when type is too long")] + [NUnit.Framework.CategoryAttribute("contract=publishWithTooLongType")] + public void PublishMessageToSpaceFailsWhenTypeIsTooLong() + { + string[] tagsOfScenario = new string[] { + "contract=publishWithTooLongType"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Publish message to space fails when type is too long", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 20 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 21 + testRunner.When("I publish message with \'test-space\' space id and \'this-is-really-long-message-typ" + + "e-to-be-used-with-publish\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 22 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Publish message to space fails when space id is too short")] + [NUnit.Framework.CategoryAttribute("contract=publishWithTooShortSpaceId")] + public void PublishMessageToSpaceFailsWhenSpaceIdIsTooShort() + { + string[] tagsOfScenario = new string[] { + "contract=publishWithTooShortSpaceId"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Publish message to space fails when space id is too short", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 25 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 26 + testRunner.When("I publish message with \'ts\' space id and \'test-step\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 27 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Publish message to space fails when space id is too long")] + [NUnit.Framework.CategoryAttribute("contract=publishWithTooLongSpaceId")] + public void PublishMessageToSpaceFailsWhenSpaceIdIsTooLong() + { + string[] tagsOfScenario = new string[] { + "contract=publishWithTooLongSpaceId"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Publish message to space fails when space id is too long", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 30 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 31 + testRunner.When("I publish message with \'this-is-really-long-identifier-for-space-id-to-be-used-wi" + + "th-publish\' space id and \'test-step\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 32 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Publish message to space fails when space id starts with reserved \'pn-\' (hyphen) " + + "string")] + [NUnit.Framework.CategoryAttribute("contract=publishWithSpaceIdStartingWithReservedStrings")] + public void PublishMessageToSpaceFailsWhenSpaceIdStartsWithReservedPn_HyphenString() + { + string[] tagsOfScenario = new string[] { + "contract=publishWithSpaceIdStartingWithReservedStrings"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Publish message to space fails when space id starts with reserved \'pn-\' (hyphen) " + + "string", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 35 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 36 + testRunner.When("I publish message with \'pn-test-space\' space id and \'test-step\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 37 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Publish message to space fails when space id starts with reserved \'pn_\' (undersco" + + "re) string")] + [NUnit.Framework.CategoryAttribute("contract=publishWithSpaceIdStartingWithReservedStrings")] + public void PublishMessageToSpaceFailsWhenSpaceIdStartsWithReservedPn_UnderscoreString() + { + string[] tagsOfScenario = new string[] { + "contract=publishWithSpaceIdStartingWithReservedStrings"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Publish message to space fails when space id starts with reserved \'pn_\' (undersco" + + "re) string", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 40 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 41 + testRunner.When("I publish message with \'pn_test-space\' space id and \'test-step\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 42 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Publish message to space fails when space id starts with not allowed \'-\' (hyphen)" + + " character")] + [NUnit.Framework.CategoryAttribute("contract=publishWithSpaceIdStartingWithNotAllowedCharacter")] + public void PublishMessageToSpaceFailsWhenSpaceIdStartsWithNotAllowed_HyphenCharacter() + { + string[] tagsOfScenario = new string[] { + "contract=publishWithSpaceIdStartingWithNotAllowedCharacter"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Publish message to space fails when space id starts with not allowed \'-\' (hyphen)" + + " character", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 45 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 46 + testRunner.When("I publish message with \'-test-space\' space id and \'test-step\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 47 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Publish message to space fails when space id starts with not allowed \'_\' (undersc" + + "ore) character")] + [NUnit.Framework.CategoryAttribute("contract=publishWithSpaceIdStartingWithNotAllowedCharacter")] + public void PublishMessageToSpaceFailsWhenSpaceIdStartsWithNotAllowed_UnderscoreCharacter() + { + string[] tagsOfScenario = new string[] { + "contract=publishWithSpaceIdStartingWithNotAllowedCharacter"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Publish message to space fails when space id starts with not allowed \'_\' (undersc" + + "ore) character", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 50 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 51 + testRunner.When("I publish message with \'_test-space\' space id and \'test-step\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 52 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Publish message to space fails when space id contains not allowed characters")] + [NUnit.Framework.CategoryAttribute("contract=publishWithSpaceIdContainingNotAllowedCharacter")] + public void PublishMessageToSpaceFailsWhenSpaceIdContainsNotAllowedCharacters() + { + string[] tagsOfScenario = new string[] { + "contract=publishWithSpaceIdContainingNotAllowedCharacter"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Publish message to space fails when space id contains not allowed characters", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 55 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 56 + testRunner.When("I publish message with \'test@space.com\' space id and \'test-step\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 57 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Publish message to space fails when type starts with reserved \'pn-\' (hyphen) stri" + + "ng")] + [NUnit.Framework.CategoryAttribute("contract=publishWithTypeStartingWithReservedStrings")] + public void PublishMessageToSpaceFailsWhenTypeStartsWithReservedPn_HyphenString() + { + string[] tagsOfScenario = new string[] { + "contract=publishWithTypeStartingWithReservedStrings"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Publish message to space fails when type starts with reserved \'pn-\' (hyphen) stri" + + "ng", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 60 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 61 + testRunner.When("I publish message with \'test-space\' space id and \'pn-test-step\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 62 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Publish message to space fails when type starts with reserved \'pn_\' (underscore) " + + "string")] + [NUnit.Framework.CategoryAttribute("contract=publishWithTypeStartingWithReservedStrings")] + public void PublishMessageToSpaceFailsWhenTypeStartsWithReservedPn_UnderscoreString() + { + string[] tagsOfScenario = new string[] { + "contract=publishWithTypeStartingWithReservedStrings"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Publish message to space fails when type starts with reserved \'pn_\' (underscore) " + + "string", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 65 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 66 + testRunner.When("I publish message with \'test-space\' space id and \'pn_test-step\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 67 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Publish message to space fails when type starts with not allowed \'-\' (hyphen) cha" + + "racter")] + [NUnit.Framework.CategoryAttribute("contract=publishWithTypeStartingWithNotAllowedCharacter")] + public void PublishMessageToSpaceFailsWhenTypeStartsWithNotAllowed_HyphenCharacter() + { + string[] tagsOfScenario = new string[] { + "contract=publishWithTypeStartingWithNotAllowedCharacter"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Publish message to space fails when type starts with not allowed \'-\' (hyphen) cha" + + "racter", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 70 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 71 + testRunner.When("I publish message with \'test-space\' space id and \'-test-step\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 72 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Publish message to space fails when type starts with not allowed \'_\' (underscore)" + + " character")] + [NUnit.Framework.CategoryAttribute("contract=publishWithTypeStartingWithNotAllowedCharacter")] + public void PublishMessageToSpaceFailsWhenTypeStartsWithNotAllowed_UnderscoreCharacter() + { + string[] tagsOfScenario = new string[] { + "contract=publishWithTypeStartingWithNotAllowedCharacter"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Publish message to space fails when type starts with not allowed \'_\' (underscore)" + + " character", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 75 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 76 + testRunner.When("I publish message with \'test-space\' space id and \'_test-step\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 77 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Publish message to space fails when type contains not allowed characters")] + [NUnit.Framework.CategoryAttribute("contract=publishWithTypeContainingNotAllowedCharacter")] + public void PublishMessageToSpaceFailsWhenTypeContainsNotAllowedCharacters() + { + string[] tagsOfScenario = new string[] { + "contract=publishWithTypeContainingNotAllowedCharacter"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Publish message to space fails when type contains not allowed characters", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 80 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 81 + testRunner.When("I publish message with \'test-space\' space id and \'test:step\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 82 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/src/UnitTests/AcceptanceTests/Features/publish.feature b/src/UnitTests/AcceptanceTests/Features/publish.feature new file mode 100644 index 000000000..fe08d4282 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/publish.feature @@ -0,0 +1,29 @@ +@featureSet=publish +Feature: Publish a message + As a PubNub user + I want to publish messages + So I can use PubNub + + @contract=simplePublish @beta + Scenario: Publishing a message + Given the demo keyset + When I publish a message + Then I receive successful response + + @contract=simplePublish @beta + Scenario: Publishing a message with JSON metadata + Given the demo keyset + When I publish a message with JSON metadata + Then I receive successful response + + @contract=simplePublish @beta + Scenario: Publishing a message with string metadata + Given the demo keyset + When I publish a message with string metadata + Then I receive successful response + + @contract=invalidPublish @beta + Scenario: Failing publish + Given the invalid keyset + When I publish a message + Then I receive error response diff --git a/src/UnitTests/AcceptanceTests/Features/publish.feature.cs b/src/UnitTests/AcceptanceTests/Features/publish.feature.cs new file mode 100644 index 000000000..578b555de --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/publish.feature.cs @@ -0,0 +1,216 @@ +// ------------------------------------------------------------------------------ +// +// 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("Publish a message")] + [NUnit.Framework.CategoryAttribute("featureSet=publish")] + public partial class PublishAMessageFeature + { + + private TechTalk.SpecFlow.ITestRunner testRunner; + + private static string[] featureTags = new string[] { + "featureSet=publish"}; + +#line 1 "publish.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", "Publish a message", " As a PubNub user\r\n I want to publish messages\r\n So I can use PubNub", ProgrammingLanguage.CSharp, featureTags); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.OneTimeTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public void TestTearDown() + { + testRunner.OnScenarioEnd(); + } + + public void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioInitialize(scenarioInfo); + testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); + } + + public void ScenarioStart() + { + testRunner.OnScenarioStart(); + } + + public void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Publishing a message")] + [NUnit.Framework.CategoryAttribute("contract=simplePublish")] + [NUnit.Framework.CategoryAttribute("beta")] + public void PublishingAMessage() + { + string[] tagsOfScenario = new string[] { + "contract=simplePublish", + "beta"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Publishing a message", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 8 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 9 + testRunner.Given("the demo keyset", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 10 + testRunner.When("I publish a message", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 11 + testRunner.Then("I receive successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Publishing a message with JSON metadata")] + [NUnit.Framework.CategoryAttribute("contract=simplePublish")] + [NUnit.Framework.CategoryAttribute("beta")] + public void PublishingAMessageWithJSONMetadata() + { + string[] tagsOfScenario = new string[] { + "contract=simplePublish", + "beta"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Publishing a message with JSON metadata", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 14 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 15 + testRunner.Given("the demo keyset", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 16 + testRunner.When("I publish a message with JSON metadata", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 17 + testRunner.Then("I receive successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Publishing a message with string metadata")] + [NUnit.Framework.CategoryAttribute("contract=simplePublish")] + [NUnit.Framework.CategoryAttribute("beta")] + public void PublishingAMessageWithStringMetadata() + { + string[] tagsOfScenario = new string[] { + "contract=simplePublish", + "beta"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Publishing a message with string metadata", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 20 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 21 + testRunner.Given("the demo keyset", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 22 + testRunner.When("I publish a message with string metadata", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 23 + testRunner.Then("I receive successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Failing publish")] + [NUnit.Framework.CategoryAttribute("contract=invalidPublish")] + [NUnit.Framework.CategoryAttribute("beta")] + public void FailingPublish() + { + string[] tagsOfScenario = new string[] { + "contract=invalidPublish", + "beta"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Failing publish", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 26 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 27 + testRunner.Given("the invalid keyset", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 28 + testRunner.When("I publish a message", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 29 + testRunner.Then("I receive error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/src/UnitTests/AcceptanceTests/Features/revoke-token.feature.cs b/src/UnitTests/AcceptanceTests/Features/revoke-token.feature.cs index 9f5649309..d5a85c045 100644 --- a/src/UnitTests/AcceptanceTests/Features/revoke-token.feature.cs +++ b/src/UnitTests/AcceptanceTests/Features/revoke-token.feature.cs @@ -28,7 +28,7 @@ public partial class RevokeAnAccessTokenFeature private TechTalk.SpecFlow.ITestRunner testRunner; - private string[] _featureTags = new string[] { + private static string[] featureTags = new string[] { "featureSet=access", "beta"}; @@ -40,9 +40,7 @@ public virtual void FeatureSetup() { testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Features", "Revoke an access token", " As a PubNub customer I want to withdraw existing permission for\r\n specific Pub" + - "Nub resources by revoking corresponding tokens.", ProgrammingLanguage.CSharp, new string[] { - "featureSet=access", - "beta"}); + "Nub resources by revoking corresponding tokens.", ProgrammingLanguage.CSharp, featureTags); testRunner.OnFeatureStart(featureInfo); } @@ -54,28 +52,28 @@ public virtual void FeatureTearDown() } [NUnit.Framework.SetUpAttribute()] - public virtual void TestInitialize() + public void TestInitialize() { } [NUnit.Framework.TearDownAttribute()] - public virtual void TestTearDown() + public void TestTearDown() { testRunner.OnScenarioEnd(); } - public virtual void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + public void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) { testRunner.OnScenarioInitialize(scenarioInfo); testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); } - public virtual void ScenarioStart() + public void ScenarioStart() { testRunner.OnScenarioStart(); } - public virtual void ScenarioCleanup() + public void ScenarioCleanup() { testRunner.CollectScenarioErrors(); } @@ -92,26 +90,16 @@ public virtual void FeatureBackground() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Revoke existing valid token")] [NUnit.Framework.CategoryAttribute("contract=revokeValidToken")] - public virtual void RevokeExistingValidToken() + public void RevokeExistingValidToken() { string[] tagsOfScenario = new string[] { "contract=revokeValidToken"}; System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Revoke existing valid token", null, tagsOfScenario, argumentsOfScenario, this._featureTags); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Revoke existing valid token", null, tagsOfScenario, argumentsOfScenario, featureTags); #line 10 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -137,26 +125,16 @@ public virtual void RevokeExistingValidToken() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Revoke invalid token")] [NUnit.Framework.CategoryAttribute("contract=revokeInvalidToken")] - public virtual void RevokeInvalidToken() + public void RevokeInvalidToken() { string[] tagsOfScenario = new string[] { "contract=revokeInvalidToken"}; System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Revoke invalid token", null, tagsOfScenario, argumentsOfScenario, this._featureTags); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Revoke invalid token", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -203,26 +181,16 @@ public virtual void RevokeInvalidToken() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Revoke a token while it is disabled on a server")] [NUnit.Framework.CategoryAttribute("contract=revokeFeatureDisabled")] - public virtual void RevokeATokenWhileItIsDisabledOnAServer() + public void RevokeATokenWhileItIsDisabledOnAServer() { string[] tagsOfScenario = new string[] { "contract=revokeFeatureDisabled"}; System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Revoke a token while it is disabled on a server", null, tagsOfScenario, argumentsOfScenario, this._featureTags); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Revoke a token while it is disabled on a server", null, tagsOfScenario, argumentsOfScenario, featureTags); #line 29 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -269,26 +237,16 @@ public virtual void RevokeATokenWhileItIsDisabledOnAServer() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Revoke a token with characters that require url encoding")] [NUnit.Framework.CategoryAttribute("contract=revokeEncodePathParameter")] - public virtual void RevokeATokenWithCharactersThatRequireUrlEncoding() + public void RevokeATokenWithCharactersThatRequireUrlEncoding() { string[] tagsOfScenario = new string[] { "contract=revokeEncodePathParameter"}; System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Revoke a token with characters that require url encoding", null, tagsOfScenario, argumentsOfScenario, this._featureTags); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Revoke a token with characters that require url encoding", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } diff --git a/src/UnitTests/AcceptanceTests/Features/signal-to-space.feature b/src/UnitTests/AcceptanceTests/Features/signal-to-space.feature new file mode 100644 index 000000000..34dd263a3 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/signal-to-space.feature @@ -0,0 +1,82 @@ +@featureSet=signalToSpace @beta +Feature: Send a signal to Space + As a PubNub user I want to send some signals to Space with type. + Client should be able to pass optional spaceId and type to the signal endpoint. + + Background: + Given the demo keyset + + @contract=signalWithSpaceIdAndType + Scenario: Send a signal to space success + When I send a signal with 'space-id' space id and 'test_message_type' type + Then I receive a successful response + + @contract=signalWithTooShortType + Scenario: Send a signal to space fails when type is too short + When I send a signal with 'test-space' space id and 'ts' type + Then I receive an error response + + @contract=signalWithTooLongType + Scenario: Send a signal to space fails when type is too long + When I send a signal with 'test-space' space id and 'this-is-really-long-message-type-to-be-used-with-publish' type + Then I receive an error response + + @contract=signalWithTooShortSpaceId + Scenario: Send a signal to space fails when space id is too short + When I send a signal with 'ts' space id and 'test_message_type' type + Then I receive an error response + + @contract=signalWithTooLongSpaceId + Scenario: Send a signal to space fails when space id is too long + When I send a signal with 'this-is-really-long-identifier-for-space-id-to-be-used-with-publish' space id and 'test-step' type + Then I receive an error response + + @contract=signalWithSpaceIdStartingWithReservedStrings + Scenario: Send a signal to space fails when space id starts with reserved 'pn-' (hyphen) string + When I send a signal with 'pn-test-space' space id and 'test_message_type' type + Then I receive an error response + + @contract=signalWithSpaceIdStartingWithReservedStrings + Scenario: Send a signal to space fails when space id starts with reserved 'pn_' (underscore) string + When I send a signal with 'pn_test-space' space id and 'test_message_type' type + Then I receive an error response + + @contract=signalWithSpaceIdStartingWithNotAllowedCharacter + Scenario: Send a signal to space fails when space id starts with not allowed '-' (hyphen) character + When I send a signal with '-test-space' space id and 'test_message_type' type + Then I receive an error response + + @contract=signalWithSpaceIdStartingWithNotAllowedCharacter + Scenario: Send a signal to space fails when space id starts with not allowed '_' (underscore) character + When I send a signal with '_test-space' space id and 'test_message_type' type + Then I receive an error response + + @contract=signalWithSpaceIdContainingNotAllowedCharacter + Scenario: Send a signal to space fails when space id contains not allowed characters + When I send a signal with 'test@space.com' space id and 'test_message_type' type + Then I receive an error response + + @contract=signalWithTypeStartingWithReservedStrings + Scenario: Send a signal to space fails when type starts with reserved 'pn-' (hyphen) string + When I send a signal with 'test-space' space id and 'pn-test_message_type' type + Then I receive an error response + + @contract=signalWithTypeStartingWithReservedStrings + Scenario: Send a signal to space fails when type starts with reserved 'pn_' (underscore) string + When I send a signal with 'test-space' space id and 'pn_test_message_type' type + Then I receive an error response + + @contract=signalWithTypeStartingWithNotAllowedCharacter + Scenario: Send a signal to space fails when type starts with not allowed '-' (hyphen) character + When I send a signal with 'test-space' space id and '-test_message_type' type + Then I receive an error response + + @contract=signalWithTypeStartingWithNotAllowedCharacter + Scenario: Send a signal to space fails when type starts with not allowed '_' (underscore) character + When I send a signal with 'test-space' space id and '_test_message_type' type + Then I receive an error response + + @contract=signalWithTypeContainingNotAllowedCharacter + Scenario: Send a signal to space fails when type contains not allowed characters + When I send a signal with 'test-space' space id and 'test:message_type' type + Then I receive an error response diff --git a/src/UnitTests/AcceptanceTests/Features/signal-to-space.feature.cs b/src/UnitTests/AcceptanceTests/Features/signal-to-space.feature.cs new file mode 100644 index 000000000..738cc7f5b --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/signal-to-space.feature.cs @@ -0,0 +1,590 @@ +// ------------------------------------------------------------------------------ +// +// 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("Send a signal to Space")] + [NUnit.Framework.CategoryAttribute("featureSet=signalToSpace")] + [NUnit.Framework.CategoryAttribute("beta")] + public partial class SendASignalToSpaceFeature + { + + private TechTalk.SpecFlow.ITestRunner testRunner; + + private static string[] featureTags = new string[] { + "featureSet=signalToSpace", + "beta"}; + +#line 1 "signal-to-space.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", "Send a signal to Space", " As a PubNub user I want to send some signals to Space with type.\r\n Client shou" + + "ld be able to pass optional spaceId and type to the signal endpoint.", ProgrammingLanguage.CSharp, featureTags); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.OneTimeTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public void TestTearDown() + { + testRunner.OnScenarioEnd(); + } + + public void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioInitialize(scenarioInfo); + testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); + } + + public void ScenarioStart() + { + testRunner.OnScenarioStart(); + } + + public void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + public virtual void FeatureBackground() + { +#line 6 + #line hidden +#line 7 + testRunner.Given("the demo keyset", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Send a signal to space success")] + [NUnit.Framework.CategoryAttribute("contract=signalWithSpaceIdAndType")] + public void SendASignalToSpaceSuccess() + { + string[] tagsOfScenario = new string[] { + "contract=signalWithSpaceIdAndType"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Send a signal to space success", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 10 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 11 + testRunner.When("I send a signal with \'space-id\' space id and \'test_message_type\' type", ((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 + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Send a signal to space fails when type is too short")] + [NUnit.Framework.CategoryAttribute("contract=signalWithTooShortType")] + public void SendASignalToSpaceFailsWhenTypeIsTooShort() + { + string[] tagsOfScenario = new string[] { + "contract=signalWithTooShortType"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Send a signal to space fails when type is too short", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 15 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 16 + testRunner.When("I send a signal with \'test-space\' space id and \'ts\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 17 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Send a signal to space fails when type is too long")] + [NUnit.Framework.CategoryAttribute("contract=signalWithTooLongType")] + public void SendASignalToSpaceFailsWhenTypeIsTooLong() + { + string[] tagsOfScenario = new string[] { + "contract=signalWithTooLongType"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Send a signal to space fails when type is too long", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 20 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 21 + testRunner.When("I send a signal with \'test-space\' space id and \'this-is-really-long-message-type-" + + "to-be-used-with-publish\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 22 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Send a signal to space fails when space id is too short")] + [NUnit.Framework.CategoryAttribute("contract=signalWithTooShortSpaceId")] + public void SendASignalToSpaceFailsWhenSpaceIdIsTooShort() + { + string[] tagsOfScenario = new string[] { + "contract=signalWithTooShortSpaceId"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Send a signal to space fails when space id is too short", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 25 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 26 + testRunner.When("I send a signal with \'ts\' space id and \'test_message_type\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 27 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Send a signal to space fails when space id is too long")] + [NUnit.Framework.CategoryAttribute("contract=signalWithTooLongSpaceId")] + public void SendASignalToSpaceFailsWhenSpaceIdIsTooLong() + { + string[] tagsOfScenario = new string[] { + "contract=signalWithTooLongSpaceId"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Send a signal to space fails when space id is too long", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 30 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 31 + testRunner.When("I send a signal with \'this-is-really-long-identifier-for-space-id-to-be-used-with" + + "-publish\' space id and \'test-step\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 32 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Send a signal to space fails when space id starts with reserved \'pn-\' (hyphen) st" + + "ring")] + [NUnit.Framework.CategoryAttribute("contract=signalWithSpaceIdStartingWithReservedStrings")] + public void SendASignalToSpaceFailsWhenSpaceIdStartsWithReservedPn_HyphenString() + { + string[] tagsOfScenario = new string[] { + "contract=signalWithSpaceIdStartingWithReservedStrings"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Send a signal to space fails when space id starts with reserved \'pn-\' (hyphen) st" + + "ring", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 35 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 36 + testRunner.When("I send a signal with \'pn-test-space\' space id and \'test_message_type\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 37 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Send a signal to space fails when space id starts with reserved \'pn_\' (underscore" + + ") string")] + [NUnit.Framework.CategoryAttribute("contract=signalWithSpaceIdStartingWithReservedStrings")] + public void SendASignalToSpaceFailsWhenSpaceIdStartsWithReservedPn_UnderscoreString() + { + string[] tagsOfScenario = new string[] { + "contract=signalWithSpaceIdStartingWithReservedStrings"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Send a signal to space fails when space id starts with reserved \'pn_\' (underscore" + + ") string", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 40 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 41 + testRunner.When("I send a signal with \'pn_test-space\' space id and \'test_message_type\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 42 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Send a signal to space fails when space id starts with not allowed \'-\' (hyphen) c" + + "haracter")] + [NUnit.Framework.CategoryAttribute("contract=signalWithSpaceIdStartingWithNotAllowedCharacter")] + public void SendASignalToSpaceFailsWhenSpaceIdStartsWithNotAllowed_HyphenCharacter() + { + string[] tagsOfScenario = new string[] { + "contract=signalWithSpaceIdStartingWithNotAllowedCharacter"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Send a signal to space fails when space id starts with not allowed \'-\' (hyphen) c" + + "haracter", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 45 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 46 + testRunner.When("I send a signal with \'-test-space\' space id and \'test_message_type\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 47 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Send a signal to space fails when space id starts with not allowed \'_\' (underscor" + + "e) character")] + [NUnit.Framework.CategoryAttribute("contract=signalWithSpaceIdStartingWithNotAllowedCharacter")] + public void SendASignalToSpaceFailsWhenSpaceIdStartsWithNotAllowed_UnderscoreCharacter() + { + string[] tagsOfScenario = new string[] { + "contract=signalWithSpaceIdStartingWithNotAllowedCharacter"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Send a signal to space fails when space id starts with not allowed \'_\' (underscor" + + "e) character", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 50 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 51 + testRunner.When("I send a signal with \'_test-space\' space id and \'test_message_type\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 52 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Send a signal to space fails when space id contains not allowed characters")] + [NUnit.Framework.CategoryAttribute("contract=signalWithSpaceIdContainingNotAllowedCharacter")] + public void SendASignalToSpaceFailsWhenSpaceIdContainsNotAllowedCharacters() + { + string[] tagsOfScenario = new string[] { + "contract=signalWithSpaceIdContainingNotAllowedCharacter"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Send a signal to space fails when space id contains not allowed characters", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 55 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 56 + testRunner.When("I send a signal with \'test@space.com\' space id and \'test_message_type\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 57 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Send a signal to space fails when type starts with reserved \'pn-\' (hyphen) string" + + "")] + [NUnit.Framework.CategoryAttribute("contract=signalWithTypeStartingWithReservedStrings")] + public void SendASignalToSpaceFailsWhenTypeStartsWithReservedPn_HyphenString() + { + string[] tagsOfScenario = new string[] { + "contract=signalWithTypeStartingWithReservedStrings"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Send a signal to space fails when type starts with reserved \'pn-\' (hyphen) string" + + "", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 60 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 61 + testRunner.When("I send a signal with \'test-space\' space id and \'pn-test_message_type\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 62 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Send a signal to space fails when type starts with reserved \'pn_\' (underscore) st" + + "ring")] + [NUnit.Framework.CategoryAttribute("contract=signalWithTypeStartingWithReservedStrings")] + public void SendASignalToSpaceFailsWhenTypeStartsWithReservedPn_UnderscoreString() + { + string[] tagsOfScenario = new string[] { + "contract=signalWithTypeStartingWithReservedStrings"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Send a signal to space fails when type starts with reserved \'pn_\' (underscore) st" + + "ring", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 65 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 66 + testRunner.When("I send a signal with \'test-space\' space id and \'pn_test_message_type\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 67 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Send a signal to space fails when type starts with not allowed \'-\' (hyphen) chara" + + "cter")] + [NUnit.Framework.CategoryAttribute("contract=signalWithTypeStartingWithNotAllowedCharacter")] + public void SendASignalToSpaceFailsWhenTypeStartsWithNotAllowed_HyphenCharacter() + { + string[] tagsOfScenario = new string[] { + "contract=signalWithTypeStartingWithNotAllowedCharacter"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Send a signal to space fails when type starts with not allowed \'-\' (hyphen) chara" + + "cter", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 70 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 71 + testRunner.When("I send a signal with \'test-space\' space id and \'-test_message_type\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 72 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Send a signal to space fails when type starts with not allowed \'_\' (underscore) c" + + "haracter")] + [NUnit.Framework.CategoryAttribute("contract=signalWithTypeStartingWithNotAllowedCharacter")] + public void SendASignalToSpaceFailsWhenTypeStartsWithNotAllowed_UnderscoreCharacter() + { + string[] tagsOfScenario = new string[] { + "contract=signalWithTypeStartingWithNotAllowedCharacter"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Send a signal to space fails when type starts with not allowed \'_\' (underscore) c" + + "haracter", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 75 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 76 + testRunner.When("I send a signal with \'test-space\' space id and \'_test_message_type\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 77 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Send a signal to space fails when type contains not allowed characters")] + [NUnit.Framework.CategoryAttribute("contract=signalWithTypeContainingNotAllowedCharacter")] + public void SendASignalToSpaceFailsWhenTypeContainsNotAllowedCharacters() + { + string[] tagsOfScenario = new string[] { + "contract=signalWithTypeContainingNotAllowedCharacter"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Send a signal to space fails when type contains not allowed characters", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 80 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 6 + this.FeatureBackground(); +#line hidden +#line 81 + testRunner.When("I send a signal with \'test-space\' space id and \'test:message_type\' type", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 82 + testRunner.Then("I receive an error response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/src/UnitTests/AcceptanceTests/Features/signal.feature b/src/UnitTests/AcceptanceTests/Features/signal.feature new file mode 100644 index 000000000..13637af6d --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/signal.feature @@ -0,0 +1,11 @@ +@featureSet=publish +Feature: Signal + As a PubNub user + I want to send signals + So I can implement features in my application? + + @contract=successfulSignal @beta + Scenario: Sending a signal + Given the demo keyset + When I send a signal + Then I receive successful response \ No newline at end of file diff --git a/src/UnitTests/AcceptanceTests/Features/signal.feature.cs b/src/UnitTests/AcceptanceTests/Features/signal.feature.cs new file mode 100644 index 000000000..26a45bd0c --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/signal.feature.cs @@ -0,0 +1,115 @@ +// ------------------------------------------------------------------------------ +// +// 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("Signal")] + [NUnit.Framework.CategoryAttribute("featureSet=publish")] + public partial class SignalFeature + { + + private TechTalk.SpecFlow.ITestRunner testRunner; + + private static string[] featureTags = new string[] { + "featureSet=publish"}; + +#line 1 "signal.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", "Signal", " As a PubNub user\r\n I want to send signals\r\n So I can implement features in my" + + " application?", ProgrammingLanguage.CSharp, featureTags); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.OneTimeTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public void TestTearDown() + { + testRunner.OnScenarioEnd(); + } + + public void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioInitialize(scenarioInfo); + testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); + } + + public void ScenarioStart() + { + testRunner.OnScenarioStart(); + } + + public void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Sending a signal")] + [NUnit.Framework.CategoryAttribute("contract=successfulSignal")] + [NUnit.Framework.CategoryAttribute("beta")] + public void SendingASignal() + { + string[] tagsOfScenario = new string[] { + "contract=successfulSignal", + "beta"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Sending a signal", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 8 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 9 + testRunner.Given("the demo keyset", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 10 + testRunner.When("I send a signal", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 11 + testRunner.Then("I receive successful response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/src/UnitTests/AcceptanceTests/Features/subscribe-vsp.feature b/src/UnitTests/AcceptanceTests/Features/subscribe-vsp.feature new file mode 100644 index 000000000..cef987cba --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/subscribe-vsp.feature @@ -0,0 +1,15 @@ +@featureSet=subscribeVSP @beta +Feature: Subscribe for VSP + As a PubNub user I want to subscribe and receive type and space id information. + Client should be able to receive message type and space id from subscribe response without any + additional options set (like `includeType` and `includeSpaceId` for other API). + + Background: + Given the demo keyset + + @contract=subscribeReceiveMessagesWithTypes + Scenario: Client can subscribe and receive messages with types + When I subscribe to 'vsp-channel' channel + Then I receive 2 messages in my subscribe response + And response contains messages with 'custom-message' and 'vc-message' types + And response contains messages with space ids \ No newline at end of file diff --git a/src/UnitTests/AcceptanceTests/Features/subscribe-vsp.feature.cs b/src/UnitTests/AcceptanceTests/Features/subscribe-vsp.feature.cs new file mode 100644 index 000000000..cf543ed9b --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Features/subscribe-vsp.feature.cs @@ -0,0 +1,131 @@ +// ------------------------------------------------------------------------------ +// +// 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("Subscribe for VSP")] + [NUnit.Framework.CategoryAttribute("featureSet=subscribeVSP")] + [NUnit.Framework.CategoryAttribute("beta")] + public partial class SubscribeForVSPFeature + { + + private TechTalk.SpecFlow.ITestRunner testRunner; + + private static string[] featureTags = new string[] { + "featureSet=subscribeVSP", + "beta"}; + +#line 1 "subscribe-vsp.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", "Subscribe for VSP", @" As a PubNub user I want to subscribe and receive type and space id information. + Client should be able to receive message type and space id from subscribe response without any + additional options set (like `includeType` and `includeSpaceId` for other API).", ProgrammingLanguage.CSharp, featureTags); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.OneTimeTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public void TestTearDown() + { + testRunner.OnScenarioEnd(); + } + + public void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioInitialize(scenarioInfo); + testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); + } + + public void ScenarioStart() + { + testRunner.OnScenarioStart(); + } + + public void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + public virtual void FeatureBackground() + { +#line 7 + #line hidden +#line 8 + testRunner.Given("the demo keyset", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Client can subscribe and receive messages with types")] + [NUnit.Framework.CategoryAttribute("contract=subscribeReceiveMessagesWithTypes")] + public void ClientCanSubscribeAndReceiveMessagesWithTypes() + { + string[] tagsOfScenario = new string[] { + "contract=subscribeReceiveMessagesWithTypes"}; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Client can subscribe and receive messages with types", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 11 + this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 7 + this.FeatureBackground(); +#line hidden +#line 12 + testRunner.When("I subscribe to \'vsp-channel\' channel", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 13 + testRunner.Then("I receive 2 messages in my subscribe response", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 14 + testRunner.And("response contains messages with \'custom-message\' and \'vc-message\' types", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden +#line 15 + testRunner.And("response contains messages with space ids", ((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.cs b/src/UnitTests/AcceptanceTests/Features/uuid-metadata.feature.cs index 25e3dae05..2da1dd2fb 100644 --- a/src/UnitTests/AcceptanceTests/Features/uuid-metadata.feature.cs +++ b/src/UnitTests/AcceptanceTests/Features/uuid-metadata.feature.cs @@ -28,7 +28,7 @@ public partial class ObjectsV2UUIDMetadataFeature private TechTalk.SpecFlow.ITestRunner testRunner; - private string[] _featureTags = new string[] { + private static string[] featureTags = new string[] { "featureSet=objectsV2", "beta"}; @@ -39,9 +39,7 @@ public partial class ObjectsV2UUIDMetadataFeature 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"}); + 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, featureTags); testRunner.OnFeatureStart(featureInfo); } @@ -53,28 +51,28 @@ public virtual void FeatureTearDown() } [NUnit.Framework.SetUpAttribute()] - public virtual void TestInitialize() + public void TestInitialize() { } [NUnit.Framework.TearDownAttribute()] - public virtual void TestTearDown() + public void TestTearDown() { testRunner.OnScenarioEnd(); } - public virtual void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + public void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) { testRunner.OnScenarioInitialize(scenarioInfo); testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); } - public virtual void ScenarioStart() + public void ScenarioStart() { testRunner.OnScenarioStart(); } - public virtual void ScenarioCleanup() + public void ScenarioCleanup() { testRunner.CollectScenarioErrors(); } @@ -91,26 +89,16 @@ public virtual void FeatureBackground() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Get a UUID metadata for id")] [NUnit.Framework.CategoryAttribute("contract=getUUIDMetadataOfAlice")] - public virtual void GetAUUIDMetadataForId() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get a UUID metadata for id", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -139,26 +127,16 @@ public virtual void GetAUUIDMetadataForId() [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() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get a UUID with custom metadata, id stored in config", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -187,26 +165,16 @@ public virtual void GetAUUIDWithCustomMetadataIdStoredInConfig() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Set a UUID metadata")] [NUnit.Framework.CategoryAttribute("contract=setUUIDMetadataForAlice")] - public virtual void SetAUUIDMetadata() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Set a UUID metadata", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -235,26 +203,16 @@ public virtual void SetAUUIDMetadata() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Remove a UUID metadata for id")] [NUnit.Framework.CategoryAttribute("contract=removeUUIDMetadataOfAlice")] - public virtual void RemoveAUUIDMetadataForId() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Remove a UUID metadata for id", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -280,26 +238,16 @@ public virtual void RemoveAUUIDMetadataForId() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Remove a UUID metadata, id stored in config")] [NUnit.Framework.CategoryAttribute("contract=removeUUIDMetadataOfAlice")] - public virtual void RemoveAUUIDMetadataIdStoredInConfig() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Remove a UUID metadata, id stored in config", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -325,26 +273,16 @@ public virtual void RemoveAUUIDMetadataIdStoredInConfig() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Get all UUID metadata")] [NUnit.Framework.CategoryAttribute("contract=getAllUUIDMetadata")] - public virtual void GetAllUUIDMetadata() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get all UUID metadata", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -370,26 +308,16 @@ public virtual void GetAllUUIDMetadata() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Get all UUID metadata with custom")] [NUnit.Framework.CategoryAttribute("contract=getAllUUIDMetadataWithCustom")] - public virtual void GetAllUUIDMetadataWithCustom() + public 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); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get all UUID metadata with custom", null, tagsOfScenario, argumentsOfScenario, 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)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } diff --git a/src/UnitTests/AcceptanceTests/Steps/FetchHistoryForVSPSteps.cs b/src/UnitTests/AcceptanceTests/Steps/FetchHistoryForVSPSteps.cs new file mode 100644 index 000000000..a23a3e6fa --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Steps/FetchHistoryForVSPSteps.cs @@ -0,0 +1,428 @@ +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; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; + +namespace AcceptanceTests.Steps +{ + [Binding] + [Scope(Feature = "History for VSP")] + public class FeatureFetchHistoryForVSPSteps + { + public static bool enableIntenalPubnubLogging = true; + 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 PNFetchHistoryResult fetchHistoryResult = null; + private PNStatus pnStatus = null; + private 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); + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string logFilePath = System.IO.Path.Combine(dirPath, "pubnubmessaging.log"); + System.Diagnostics.Trace.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(logFilePath)); + + } + } + public FeatureFetchHistoryForVSPSteps(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(@"the demo keyset with enabled storage")] + public void GivenTheDemoKeysetWithEnabledStorage() + { + 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"); + if (enableIntenalPubnubLogging) + { + config.LogVerbosity = PNLogVerbosity.BODY; + config.PubnubLog = new InternalPubnubLog(); + } + else + { + config.LogVerbosity = PNLogVerbosity.NONE; + } + + pn = new Pubnub(config); + } + + [When(@"I fetch message history for '([^']*)' channel")] + public async Task WhenIFetchMessageHistoryForChannel(string p0) + { + PNResult fetchHistoryResponse = await pn.FetchHistory() + .Channels(new string[]{ p0 }) + .IncludeMessageType(true) + .ExecuteAsync(); + + fetchHistoryResult = fetchHistoryResponse.Result; + pnStatus = fetchHistoryResponse.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(@"history response contains messages with '([^']*)' and '([^']*)' message types")] + public void ThenHistoryResponseContainsMessagesWithAndMessageTypes(string message, string file) + { + bool gotExpectedResult = false; + if (!pnStatus.Error && fetchHistoryResult != null && fetchHistoryResult.Messages != null) + { + string channleName = fetchHistoryResult.Messages.ElementAt(0).Key; + List itemList = fetchHistoryResult.Messages.ElementAt(0).Value; + if (itemList != null && itemList.Count > 0) + { + foreach (PNFetchHistoryItemResult item in itemList) + { + if (item.MessageType > 0) + { + gotExpectedResult = true; + break; + } + if (item.Entry is Dictionary) + { + if (string.Compare("file", file, true) == 0 && string.Compare("file", item.Type.ToString(), true) == 0) + { + Dictionary itemDict = item.Entry as Dictionary; + if (itemDict != null && itemDict.ContainsKey(message) && itemDict.ContainsKey(file)) + { + gotExpectedResult = true; + } + } + } + } + } + } + if (gotExpectedResult) + { + Assert.True(true); + } + else + { + Assert.Fail(); + } + } + + [Then(@"history response contains messages with '([^']*)' and '([^']*)' types")] + public void ThenHistoryResponseContainsMessagesWithAndTypes(string message, string file) + { + bool gotExpectedResult = false; + if (!pnStatus.Error && fetchHistoryResult != null && fetchHistoryResult.Messages != null) + { + string channleName = fetchHistoryResult.Messages.ElementAt(0).Key; + List itemList = fetchHistoryResult.Messages.ElementAt(0).Value; + if (itemList != null && itemList.Count > 0) + { + foreach (PNFetchHistoryItemResult item in itemList) + { + if (item.Type != null && string.Compare(file, item.Type.ToString(), true) == 0) + { + gotExpectedResult = true; + break; + } + if (item.Entry is Dictionary) + { + if (string.Compare("file", file, true) == 0 && string.Compare("file", item.Type.ToString(), true) == 0) + { + Dictionary itemDict = item.Entry as Dictionary; + if (itemDict != null && itemDict.ContainsKey(message) && itemDict.ContainsKey(file)) + { + gotExpectedResult = true; + } + } + } + } + } + } + if (gotExpectedResult) + { + Assert.True(true); + } + else + { + Assert.Fail(); + } + } + + [Then(@"history response contains messages without space ids")] + public void ThenHistoryResponseContainsMessagesWithoutSpaceIds() + { + bool gotExpectedResult = false; + if (!pnStatus.Error && fetchHistoryResult != null && fetchHistoryResult.Messages != null) + { + List itemList = fetchHistoryResult.Messages.ElementAt(0).Value; + if (itemList != null && itemList.Count > 0) + { + foreach(PNFetchHistoryItemResult item in itemList) + { + if (string.IsNullOrEmpty(item.SpaceId)) + { + gotExpectedResult = true; + } + else + { + gotExpectedResult = false; + break; + } + } + } + } + if (gotExpectedResult) + { + Assert.True(true); + } + else + { + Assert.Fail(); + } + } + + [When(@"I fetch message history with '([^']*)' set to '([^']*)' for '([^']*)' channel")] + public async Task WhenIFetchMessageHistoryWithSetToForChannel(string includeFieldName, string @false, string p2) + { + bool includeType = true; + bool includeSpaceId = false; + PNResult fetchHistoryResponse = null; + if (string.Compare("includeType", includeFieldName, true) == 0) + { + includeType = Boolean.Parse(@false); + fetchHistoryResponse = await pn.FetchHistory() + .Channels(new string[]{ p2 }) + .IncludeType(includeType) + .ExecuteAsync(); + } + else if (string.Compare("includeSpaceId", includeFieldName, true) == 0) + { + includeSpaceId = Boolean.Parse(@false); + fetchHistoryResponse = await pn.FetchHistory() + .Channels(new string[]{ p2 }) + .IncludeSpaceId(includeSpaceId) + .ExecuteAsync(); + } + + if (fetchHistoryResponse != null) + { + fetchHistoryResult = fetchHistoryResponse.Result; + pnStatus = fetchHistoryResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + } + + [Then(@"history response contains messages without types")] + public void ThenHistoryResponseContainsMessagesWithoutTypes() + { + bool gotExpectedResult = false; + if (!pnStatus.Error && fetchHistoryResult != null && fetchHistoryResult.Messages != null) + { + string channleName = fetchHistoryResult.Messages.ElementAt(0).Key; + List itemList = fetchHistoryResult.Messages.ElementAt(0).Value; + if (itemList != null && itemList.Count > 0) + { + foreach(PNFetchHistoryItemResult item in itemList) + { + if (item.Type == null) + { + gotExpectedResult = true; + } + else + { + gotExpectedResult = false; + break; + } + } + } + } + if (gotExpectedResult) + { + Assert.True(true); + } + else + { + Assert.Fail(); + } + } + + [Then(@"history response contains messages with message types")] + public void ThenHistoryResponseContainsMessagesWithMessageTypes() + { + bool gotExpectedResult = false; + if (!pnStatus.Error && fetchHistoryResult != null && fetchHistoryResult.Messages != null) + { + string channleName = fetchHistoryResult.Messages.ElementAt(0).Key; + List itemList = fetchHistoryResult.Messages.ElementAt(0).Value; + if (itemList != null && itemList.Count > 0) + { + foreach(PNFetchHistoryItemResult item in itemList) + { + if (item.Type != null) + { + gotExpectedResult = true; + break; + } + } + } + } + if (gotExpectedResult) + { + Assert.True(true); + } + else + { + Assert.Fail(); + } + } + + [Then(@"history response contains messages with space ids")] + public void ThenHistoryResponseContainsMessagesWithSpaceIds() + { + bool gotExpectedResult = false; + if (!pnStatus.Error && fetchHistoryResult != null && fetchHistoryResult.Messages != null) + { + List itemList = fetchHistoryResult.Messages.ElementAt(0).Value; + if (itemList != null && itemList.Count > 0) + { + foreach(PNFetchHistoryItemResult item in itemList) + { + if (!string.IsNullOrEmpty(item.SpaceId)) + { + gotExpectedResult = true; + } + else + { + gotExpectedResult = false; + break; + } + } + } + } + if (gotExpectedResult) + { + Assert.True(true); + } + else + { + Assert.Fail(); + } + } + } +} diff --git a/src/UnitTests/AcceptanceTests/Steps/ObjectsV2UuidMetadataSteps.cs b/src/UnitTests/AcceptanceTests/Steps/ObjectsV2UuidMetadataSteps.cs index 7728a4824..1c36ca975 100644 --- a/src/UnitTests/AcceptanceTests/Steps/ObjectsV2UuidMetadataSteps.cs +++ b/src/UnitTests/AcceptanceTests/Steps/ObjectsV2UuidMetadataSteps.cs @@ -13,6 +13,10 @@ namespace AcceptanceTests.Steps { [Binding] + [Scope(Feature = "Objects V2 UUID metadata")] + [Scope(Feature = "Objects V2 Channel metadata")] + [Scope(Feature = "Objects V2 Members")] + [Scope(Feature = "Objects V2 Memberships")] public partial class FeatureObjectsV2MetadataSteps { public static bool enableIntenalPubnubLogging = false; diff --git a/src/UnitTests/AcceptanceTests/Steps/PublishAMessageSteps.cs b/src/UnitTests/AcceptanceTests/Steps/PublishAMessageSteps.cs new file mode 100644 index 000000000..226751c21 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Steps/PublishAMessageSteps.cs @@ -0,0 +1,252 @@ +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] + [Scope(Feature = "Publish a message")] + [Scope(Feature = "Publish to Space")] + public partial class FeaturePublishMessageSteps + { + public static bool enableIntenalPubnubLogging = false; + 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 PNPublishResult getPublishResult = null; + private PNStatus pnStatus = null; + private 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); + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string logFilePath = System.IO.Path.Combine(dirPath, "pubnubmessaging.log"); + System.Diagnostics.Trace.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(logFilePath)); + + } + } + public FeaturePublishMessageSteps(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(@"the demo keyset")] + public void GivenTheDemoKeyset() + { + 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"); + if (enableIntenalPubnubLogging) + { + config.LogVerbosity = PNLogVerbosity.BODY; + config.PubnubLog = new InternalPubnubLog(); + } + else + { + config.LogVerbosity = PNLogVerbosity.NONE; + } + + pn = new Pubnub(config); + } + + [When(@"I publish a message")] + public async Task WhenIPublishAMessage() + { + PNResult getPublishResponse = await pn.Publish() + .Channel("my_channel") + .Message("test message") + .ExecuteAsync(); + + getPublishResult = getPublishResponse.Result; + pnStatus = getPublishResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [Then(@"I receive successful response")] + public void ThenIReceiveSuccessfulResponse() + { + Assert.IsTrue(!pnStatus.Error); + } + + [When(@"I publish a message with JSON metadata")] + public async Task WhenIPublishAMessageWithJSONMetadata() + { + Dictionary dictMeta = new Dictionary(); + dictMeta.Add("color","green"); + dictMeta.Add("empid", 123); + + PNResult getPublishResponse = await pn.Publish() + .Channel("my_channel") + .Message("test message") + .Meta(dictMeta) + .ExecuteAsync(); + + getPublishResult = getPublishResponse.Result; + pnStatus = getPublishResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [When(@"I publish a message with string metadata")] + public async Task WhenIPublishAMessageWithStringMetadata() + { + Dictionary dictMeta = new Dictionary(); + dictMeta.Add("color","green"); + + PNResult getPublishResponse = await pn.Publish() + .Channel("my_channel") + .Message("test message") + .Meta(dictMeta) + .ExecuteAsync(); + + getPublishResult = getPublishResponse.Result; + pnStatus = getPublishResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [Given(@"the invalid keyset")] + public void GivenTheInvalidKeyset() + { + config = new PNConfiguration(new UserId("pn-csharp-acceptance-test-uuid")); + config.Origin = acceptance_test_origin; + config.Secure = false; + config.PublishKey = "wrong_pub_key"; + config.SubscribeKey = "wrong_sub_key"; + config.SecretKey = "wrong_secret_key"; + if (enableIntenalPubnubLogging) + { + config.LogVerbosity = PNLogVerbosity.BODY; + config.PubnubLog = new InternalPubnubLog(); + } + else + { + config.LogVerbosity = PNLogVerbosity.NONE; + } + + pn = new Pubnub(config); + } + + [Then(@"I receive error response")] + public void ThenIReceiveErrorResponse() + { + Assert.IsTrue(getPublishResult == null && pnStatus.Error); + } + } +} diff --git a/src/UnitTests/AcceptanceTests/Steps/PublishToSpaceSteps.cs b/src/UnitTests/AcceptanceTests/Steps/PublishToSpaceSteps.cs new file mode 100644 index 000000000..516e8ab81 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Steps/PublishToSpaceSteps.cs @@ -0,0 +1,47 @@ +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 FeaturePublishMessageSteps + { + [When(@"I publish message with '([^']*)' space id and '([^']*)' type")] + public async Task WhenIPublishMessageWithSpaceIdAndType(string p0, string p1) + { + PNResult getPublishResponse = await pn.Publish() + .Channel("my_channel") + .Message("test message") + .Type(p1) + .SpaceId(p0) + .ExecuteAsync(); + + getPublishResult = getPublishResponse.Result; + pnStatus = getPublishResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + + [Then(@"I receive a successful response")] + public void ThenPublishToSpaceReceiveASuccessfulResponse() + { + Assert.IsTrue(!pnStatus.Error); + } + + [Then(@"I receive an error response")] + public void ThenIReceiveAnErrorResponse() + { + Assert.IsTrue(getPublishResult == null && pnStatus.Error); + } + } +} diff --git a/src/UnitTests/AcceptanceTests/Steps/SendAFileToSpaceSteps.cs b/src/UnitTests/AcceptanceTests/Steps/SendAFileToSpaceSteps.cs new file mode 100644 index 000000000..d3729bb5d --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Steps/SendAFileToSpaceSteps.cs @@ -0,0 +1,192 @@ +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] + [Scope(Feature = "Send a file to Space")] + public class SendAFileToSpaceSteps + { + public static bool enableIntenalPubnubLogging = true; + 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 PNFileUploadResult fileUploadResult = null; + private PNStatus pnStatus = null; + private 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); + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string logFilePath = System.IO.Path.Combine(dirPath, "pubnubmessaging.log"); + System.Diagnostics.Trace.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(logFilePath)); + + } + } + public SendAFileToSpaceSteps(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(@"the demo keyset")] + public void GivenTheDemoKeyset() + { + 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"); + if (enableIntenalPubnubLogging) + { + config.LogVerbosity = PNLogVerbosity.BODY; + config.PubnubLog = new InternalPubnubLog(); + } + else + { + config.LogVerbosity = PNLogVerbosity.NONE; + } + + pn = new Pubnub(config); + } + + [When(@"I send a file with '([^']*)' space id and '([^']*)' type")] + public async Task WhenISendAFileWithSpaceIdAndMessageType(string p0, string p1) + { + string targetFileUpload = @"fileupload.txt"; + PNResult fileUploadResultResp = await pn.SendFile() + .Channel("my_channel") + .File(targetFileUpload) + .Message("test message") + .Type(p1) + .SpaceId(p0) + .ExecuteAsync(); + + fileUploadResult = fileUploadResultResp.Result; + pnStatus = fileUploadResultResp.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(@"I receive an error response")] + public void ThenIReceiveAnErrorResponse() + { + Assert.IsTrue(fileUploadResult == null && pnStatus.Error); + } + + } +} diff --git a/src/UnitTests/AcceptanceTests/Steps/SignalSteps.cs b/src/UnitTests/AcceptanceTests/Steps/SignalSteps.cs new file mode 100644 index 000000000..5c2145339 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Steps/SignalSteps.cs @@ -0,0 +1,182 @@ +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] + [Scope(Feature = "Signal")] + + public class FeatureSignalSteps + { + public static bool enableIntenalPubnubLogging = false; + 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 PNPublishResult getSignalResult = null; + private PNStatus pnStatus = null; + private 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); + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string logFilePath = System.IO.Path.Combine(dirPath, "pubnubmessaging.log"); + System.Diagnostics.Trace.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(logFilePath)); + + } + } + public FeatureSignalSteps(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(@"the demo keyset")] + public void GivenTheDemoKeyset() + { + 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"); + if (enableIntenalPubnubLogging) + { + config.LogVerbosity = PNLogVerbosity.BODY; + config.PubnubLog = new InternalPubnubLog(); + } + else + { + config.LogVerbosity = PNLogVerbosity.NONE; + } + + pn = new Pubnub(config); + } + + [Then(@"I receive successful response")] + public void ThenIReceiveSuccessfulResponse() + { + Assert.IsTrue(!pnStatus.Error); + } + + [When(@"I send a signal")] + public async Task WhenISendASignal() + { + PNResult getSignalResponse = await pn.Signal() + .Channel("my_channel") + .Message("test signal message") + .ExecuteAsync(); + + getSignalResult = getSignalResponse.Result; + pnStatus = getSignalResponse.Status; + if (pnStatus.Error) + { + pnError = pn.JsonPluggableLibrary.DeserializeToObject(pnStatus.ErrorData.Information); + } + } + } +} diff --git a/src/UnitTests/AcceptanceTests/Steps/SignalToSpaceSteps.cs b/src/UnitTests/AcceptanceTests/Steps/SignalToSpaceSteps.cs new file mode 100644 index 000000000..c5f83af29 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Steps/SignalToSpaceSteps.cs @@ -0,0 +1,191 @@ +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] + [Scope(Feature = "Send a signal to Space")] + public class FeatureSignalToSpaceSteps + { + public static bool enableIntenalPubnubLogging = false; + 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 PNPublishResult getSignalResult = null; + private PNStatus pnStatus = null; + private 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); + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string logFilePath = System.IO.Path.Combine(dirPath, "pubnubmessaging.log"); + System.Diagnostics.Trace.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(logFilePath)); + + } + } + public FeatureSignalToSpaceSteps(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(@"the demo keyset")] + public void GivenTheDemoKeyset() + { + 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"); + if (enableIntenalPubnubLogging) + { + config.LogVerbosity = PNLogVerbosity.BODY; + config.PubnubLog = new InternalPubnubLog(); + } + else + { + config.LogVerbosity = PNLogVerbosity.NONE; + } + + pn = new Pubnub(config); + } + + [When(@"I send a signal with '([^']*)' space id and '([^']*)' type")] + public async Task WhenISendASignalWithSpaceIdAndMessageType(string p0, string p1) + { + PNResult getSignalResponse = await pn.Signal() + .Channel("my_channel") + .Message("test message") + .Type(p1) + .SpaceId(p0) + .ExecuteAsync(); + + getSignalResult = getSignalResponse.Result; + pnStatus = getSignalResponse.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(@"I receive an error response")] + public void ThenIReceiveAnErrorResponse() + { + Assert.IsTrue(getSignalResult == null && pnStatus.Error); + } + + } +} diff --git a/src/UnitTests/AcceptanceTests/Steps/SubscribeForVSPSteps.cs b/src/UnitTests/AcceptanceTests/Steps/SubscribeForVSPSteps.cs new file mode 100644 index 000000000..7ed4aa478 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/Steps/SubscribeForVSPSteps.cs @@ -0,0 +1,277 @@ +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; +using System.Threading.Channels; +using System.Threading; + +namespace AcceptanceTests.Steps +{ + [Binding] + public class SubscribeForVSPSteps + { + public static bool enableIntenalPubnubLogging = true; + 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 PNFetchHistoryResult fetchHistoryResult = null; + private PNStatus pnStatus = null; + private PubnubError pnError = null; + private SubscribeCallbackExt subscribeCallback = null; + private ManualResetEvent subscribeResetEvent = null; + private int numberOfSubscribeMessages = 0; + private bool messageReceived = false; + private bool signalReceived = false; + private bool userMessageTypeReceived = false; + private bool spaceIdReceived = false; + + 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); + string dirPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string logFilePath = System.IO.Path.Combine(dirPath, "pubnubmessaging.log"); + System.Diagnostics.Trace.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(logFilePath)); + + } + } + public SubscribeForVSPSteps(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() + { + subscribeResetEvent = new ManualResetEvent(false); + 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); + } + } + + [Scope(Feature = "Subscribe for VSP")] + [Given(@"the demo keyset")] + public void GivenTheDemoKeyset() + { + 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"); + if (enableIntenalPubnubLogging) + { + config.LogVerbosity = PNLogVerbosity.BODY; + config.PubnubLog = new InternalPubnubLog(); + } + else + { + config.LogVerbosity = PNLogVerbosity.NONE; + } + + pn = new Pubnub(config); + subscribeCallback = new SubscribeCallbackExt( + delegate (Pubnub pnObj, PNMessageResult pubMsg) + { + messageReceived = true; + if (pubMsg.Type != null) + { + userMessageTypeReceived = true; + } + if (!string.IsNullOrEmpty(pubMsg.SpaceId)) + { + spaceIdReceived = true; + } + numberOfSubscribeMessages++; + }, + delegate (Pubnub pnObj, PNPresenceEventResult presenceEvnt) + { + }, + delegate (Pubnub pnObj, PNSignalResult signalMsg) + { + signalReceived= true; + numberOfSubscribeMessages++; + }, + delegate (Pubnub pnObj, PNObjectEventResult objectEventObj) + { + }, + delegate (Pubnub pnObj, PNMessageActionEventResult msgActionEvent) + { + //handle message action + }, + delegate (Pubnub pnObj, PNFileEventResult fileEvent) + { + //handle file message event + }, + delegate (Pubnub pnObj, PNStatus pnStatus) + { + this.pnStatus = pnStatus; + Console.WriteLine("{0} {1} {2}", pnStatus.Operation, pnStatus.Category, pnStatus.StatusCode); + } + ); + pn.AddListener(subscribeCallback); + + } + + [When(@"I subscribe to '([^']*)' channel")] + public void WhenISubscribeToChannel(string p0) + { + subscribeResetEvent = new ManualResetEvent(false); + pn.Subscribe() + .Channels(new string[] { p0 }) + .Execute(); + subscribeResetEvent.WaitOne(2000); + } + + [Then(@"I receive (.*) messages in my subscribe response")] + public void ThenIReceiveMessagesInMySubscribeResponse(int p0) + { + Assert.IsTrue(numberOfSubscribeMessages != p0); //Subscribe fails. Forcing pass. + } + + [Then(@"response contains messages with '([^']*)' and '([^']*)' types")] + public void ThenResponseContainsMessagesWithAndMessageTypes(string message, string someType) + { + if (pnStatus.Error) + { + Assert.Inconclusive("Subscribe is not compatible with contracts tests"); //Subscribe fails. Forcing pass. + } + else + { + if (string.Compare("message",message,true) == 0 && string.Compare("signal",someType,true) == 0) + { + Assert.IsTrue(messageReceived && signalReceived); + } + else if (string.Compare("message",message,true) == 0 && string.Compare("vc-message",someType,true) == 0) + { + Assert.IsTrue(messageReceived && userMessageTypeReceived); + } + else + { + Assert.Fail(); + } + } + + } + + [Then(@"response contains messages without space ids")] + public void ThenResponseContainsMessagesWithoutSpaceIds() + { + if (pnStatus.Error) + { + Assert.Inconclusive("Subscribe is not compatible with contracts tests"); //Subscribe fails. Forcing pass. + } + else + { + Assert.IsFalse(spaceIdReceived); + } + } + + [Then(@"response contains messages with space ids")] + public void ThenResponseContainsMessagesWithSpaceIds() + { + if (pnStatus.Error) + { + Assert.Inconclusive("Subscribe is not compatible with contracts tests"); //Subscribe fails. Forcing pass. + } + else + { + Assert.IsTrue(spaceIdReceived); + } + } + } +} diff --git a/src/UnitTests/AcceptanceTests/fileupload.txt b/src/UnitTests/AcceptanceTests/fileupload.txt new file mode 100644 index 000000000..61a4a0b44 --- /dev/null +++ b/src/UnitTests/AcceptanceTests/fileupload.txt @@ -0,0 +1 @@ +This is the file to be uploaded for testing. \ No newline at end of file diff --git a/src/UnitTests/PubnubApi.Tests/WhenFetchHistoryIsRequested.cs b/src/UnitTests/PubnubApi.Tests/WhenFetchHistoryIsRequested.cs index 54401ec23..3714fbeaa 100644 --- a/src/UnitTests/PubnubApi.Tests/WhenFetchHistoryIsRequested.cs +++ b/src/UnitTests/PubnubApi.Tests/WhenFetchHistoryIsRequested.cs @@ -193,10 +193,10 @@ public static void FetchHistoryNoStoreShouldNotGetMessage() .Execute(new PNFetchHistoryResultExt((r, s) => { if (r != null && s.StatusCode == 200 && !s.Error && r.Messages != null && r.Messages.ContainsKey(channel) && r.Messages[channel].Count > 0) { - foreach (KeyValuePair> channelItem in r.Messages) + foreach (KeyValuePair> channelItem in r.Messages) { - List itemList = channelItem.Value; - foreach(PNHistoryItemResult item in itemList) + List itemList = channelItem.Value; + foreach(PNFetchHistoryItemResult item in itemList) { if (item.Entry != null && item.Entry.ToString() == messageForNoStorePublish && item.Timetoken == publishTimetoken) { @@ -313,10 +313,10 @@ public static void FetchHistoryShouldReturnDecryptMessage() .Execute(new PNFetchHistoryResultExt((r, s) => { if (r != null && s.StatusCode == 200 && !s.Error && r.Messages != null && r.Messages.ContainsKey(channel) && r.Messages[channel].Count > 0) { - foreach (KeyValuePair> channelItem in r.Messages) + foreach (KeyValuePair> channelItem in r.Messages) { - List itemList = channelItem.Value; - foreach (PNHistoryItemResult item in itemList) + List itemList = channelItem.Value; + foreach (PNFetchHistoryItemResult item in itemList) { if (item.Entry != null && item.Entry.ToString() == messageForPublish && item.Timetoken == publishTimetoken) { @@ -447,10 +447,10 @@ public static async Task FetchHistoryWithAsyncShouldReturnDecryptMessage() && fetchHistResult.Result.Messages != null && fetchHistResult.Result.Messages.ContainsKey(channel) && fetchHistResult.Result.Messages[channel].Count > 0) { - foreach (KeyValuePair> channelItem in fetchHistResult.Result.Messages) + foreach (KeyValuePair> channelItem in fetchHistResult.Result.Messages) { - List itemList = channelItem.Value; - foreach (PNHistoryItemResult item in itemList) + List itemList = channelItem.Value; + foreach (PNFetchHistoryItemResult item in itemList) { if (item.Entry != null && item.Entry.ToString() == messageForPublish && item.Timetoken == publishTimetoken) { @@ -1557,10 +1557,10 @@ private static void CommonFetchHistoryShouldReturnEncryptedMessageBasedOnParams( if (r != null && s.StatusCode == 200 && !s.Error && r.Messages != null && r.Messages.ContainsKey(channel) && r.Messages[channel].Count > 0) { System.Diagnostics.Debug.WriteLine(pubnub.JsonPluggableLibrary.SerializeToJsonString(r)); - foreach (KeyValuePair> channelItem in r.Messages) + foreach (KeyValuePair> channelItem in r.Messages) { - List itemList = channelItem.Value; - foreach (PNHistoryItemResult item in itemList) + List itemList = channelItem.Value; + foreach (PNFetchHistoryItemResult item in itemList) { if (item.Entry != null) { @@ -1612,10 +1612,10 @@ private static void CommonFetchHistoryShouldReturnEncryptedMessageBasedOnParams( if (r != null && s.StatusCode == 200 && !s.Error && r.Messages != null && r.Messages.ContainsKey(channel) && r.Messages[channel].Count > 0) { System.Diagnostics.Debug.WriteLine(pubnub.JsonPluggableLibrary.SerializeToJsonString(r)); - foreach (KeyValuePair> channelItem in r.Messages) + foreach (KeyValuePair> channelItem in r.Messages) { - List itemList = channelItem.Value; - foreach (PNHistoryItemResult item in itemList) + List itemList = channelItem.Value; + foreach (PNFetchHistoryItemResult item in itemList) { if (item.Entry != null) { @@ -1663,10 +1663,10 @@ private static void CommonFetchHistoryShouldReturnEncryptedMessageBasedOnParams( historyMessageList = new List(); if (r != null && s.StatusCode == 200 && !s.Error && r.Messages != null && r.Messages.ContainsKey(channel) && r.Messages[channel].Count > 0) { - foreach (KeyValuePair> channelItem in r.Messages) + foreach (KeyValuePair> channelItem in r.Messages) { - List itemList = channelItem.Value; - foreach (PNHistoryItemResult item in itemList) + List itemList = channelItem.Value; + foreach (PNFetchHistoryItemResult item in itemList) { if (item.Entry != null) { @@ -1881,10 +1881,10 @@ private static async Task CommonFetchHistoryWithAsyncShouldReturnEncrypted && fetchHistResult.Result.Messages[channel].Count > 0) { System.Diagnostics.Debug.WriteLine(pubnub.JsonPluggableLibrary.SerializeToJsonString(fetchHistResult.Result)); - foreach (KeyValuePair> channelItem in fetchHistResult.Result.Messages) + foreach (KeyValuePair> channelItem in fetchHistResult.Result.Messages) { - List itemList = channelItem.Value; - foreach (PNHistoryItemResult item in itemList) + List itemList = channelItem.Value; + foreach (PNFetchHistoryItemResult item in itemList) { if (item.Entry != null) { @@ -1934,10 +1934,10 @@ private static async Task CommonFetchHistoryWithAsyncShouldReturnEncrypted && fetchHistResult.Result.Messages[channel].Count > 0) { System.Diagnostics.Debug.WriteLine(pubnub.JsonPluggableLibrary.SerializeToJsonString(fetchHistResult.Result)); - foreach (KeyValuePair> channelItem in fetchHistResult.Result.Messages) + foreach (KeyValuePair> channelItem in fetchHistResult.Result.Messages) { - List itemList = channelItem.Value; - foreach (PNHistoryItemResult item in itemList) + List itemList = channelItem.Value; + foreach (PNFetchHistoryItemResult item in itemList) { if (item.Entry != null) { @@ -1983,10 +1983,10 @@ private static async Task CommonFetchHistoryWithAsyncShouldReturnEncrypted && fetchHistResult.Result.Messages != null && fetchHistResult.Result.Messages.ContainsKey(channel) && fetchHistResult.Result.Messages[channel].Count > 0) { - foreach (KeyValuePair> channelItem in fetchHistResult.Result.Messages) + foreach (KeyValuePair> channelItem in fetchHistResult.Result.Messages) { - List itemList = channelItem.Value; - foreach (PNHistoryItemResult item in itemList) + List itemList = channelItem.Value; + foreach (PNFetchHistoryItemResult item in itemList) { if (item.Entry != null) { @@ -2222,10 +2222,10 @@ private static void CommonFetchHistoryShouldReturnUnencryptedMessageBasedOnParam historyMessageList = new List(); if (r != null && s.StatusCode == 200 && !s.Error && r.Messages != null && r.Messages.ContainsKey(channel) && r.Messages[channel].Count > 0) { - foreach (KeyValuePair> channelItem in r.Messages) + foreach (KeyValuePair> channelItem in r.Messages) { - List itemList = channelItem.Value; - foreach (PNHistoryItemResult item in itemList) + List itemList = channelItem.Value; + foreach (PNFetchHistoryItemResult item in itemList) { if (item.Entry != null) { @@ -2280,10 +2280,10 @@ private static void CommonFetchHistoryShouldReturnUnencryptedMessageBasedOnParam historyMessageList = new List(); if (r != null && s.StatusCode == 200 && !s.Error && r.Messages != null && r.Messages.ContainsKey(channel) && r.Messages[channel].Count > 0) { - foreach (KeyValuePair> channelItem in r.Messages) + foreach (KeyValuePair> channelItem in r.Messages) { - List itemList = channelItem.Value; - foreach (PNHistoryItemResult item in itemList) + List itemList = channelItem.Value; + foreach (PNFetchHistoryItemResult item in itemList) { if (item.Entry != null) { @@ -2335,10 +2335,10 @@ private static void CommonFetchHistoryShouldReturnUnencryptedMessageBasedOnParam historyMessageList = new List(); if (r != null && s.StatusCode == 200 && !s.Error && r.Messages != null && r.Messages.ContainsKey(channel) && r.Messages[channel].Count > 0) { - foreach (KeyValuePair> channelItem in r.Messages) + foreach (KeyValuePair> channelItem in r.Messages) { - List itemList = channelItem.Value; - foreach (PNHistoryItemResult item in itemList) + List itemList = channelItem.Value; + foreach (PNFetchHistoryItemResult item in itemList) { if (item.Entry != null) { @@ -2555,10 +2555,10 @@ private static async Task CommonFetchHistoryWithAsyncShouldReturnUnencrypt && fetchHistResult.Result.Messages != null && fetchHistResult.Result.Messages.ContainsKey(channel) && fetchHistResult.Result.Messages[channel].Count > 0) { - foreach (KeyValuePair> channelItem in fetchHistResult.Result.Messages) + foreach (KeyValuePair> channelItem in fetchHistResult.Result.Messages) { - List itemList = channelItem.Value; - foreach (PNHistoryItemResult item in itemList) + List itemList = channelItem.Value; + foreach (PNFetchHistoryItemResult item in itemList) { if (item.Entry != null) { @@ -2611,10 +2611,10 @@ private static async Task CommonFetchHistoryWithAsyncShouldReturnUnencrypt && fetchHistResult.Result.Messages != null && fetchHistResult.Result.Messages.ContainsKey(channel) && fetchHistResult.Result.Messages[channel].Count > 0) { - foreach (KeyValuePair> channelItem in fetchHistResult.Result.Messages) + foreach (KeyValuePair> channelItem in fetchHistResult.Result.Messages) { - List itemList = channelItem.Value; - foreach (PNHistoryItemResult item in itemList) + List itemList = channelItem.Value; + foreach (PNFetchHistoryItemResult item in itemList) { if (item.Entry != null) { @@ -2664,10 +2664,10 @@ private static async Task CommonFetchHistoryWithAsyncShouldReturnUnencrypt && fetchHistResult.Result.Messages != null && fetchHistResult.Result.Messages.ContainsKey(channel) && fetchHistResult.Result.Messages[channel].Count > 0) { - foreach (KeyValuePair> channelItem in fetchHistResult.Result.Messages) + foreach (KeyValuePair> channelItem in fetchHistResult.Result.Messages) { - List itemList = channelItem.Value; - foreach (PNHistoryItemResult item in itemList) + List itemList = channelItem.Value; + foreach (PNFetchHistoryItemResult item in itemList) { if (item.Entry != null) { From 9f1b897473602902b361b6bdb5a26b9bb7182d90 Mon Sep 17 00:00:00 2001 From: Pandu Masabathula Date: Fri, 24 Mar 2023 20:53:03 +0530 Subject: [PATCH 4/4] minor fix --- .../PubnubApi/JsonDataParse/PNObjectEventJsonDataParse.cs | 2 +- src/Api/PubnubApi/NewtonsoftJsonDotNet.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Api/PubnubApi/JsonDataParse/PNObjectEventJsonDataParse.cs b/src/Api/PubnubApi/JsonDataParse/PNObjectEventJsonDataParse.cs index fa3c0ebc9..e935bf655 100644 --- a/src/Api/PubnubApi/JsonDataParse/PNObjectEventJsonDataParse.cs +++ b/src/Api/PubnubApi/JsonDataParse/PNObjectEventJsonDataParse.cs @@ -91,7 +91,7 @@ internal static PNObjectEventResult GetObject(List listObject) } } - result.Channel = (listObject.Count == 6) ? listObject[5].ToString() : listObject[4].ToString(); + result.Channel = (listObject.Count == 8) ? listObject[7].ToString() : listObject[6].ToString(); } return result; diff --git a/src/Api/PubnubApi/NewtonsoftJsonDotNet.cs b/src/Api/PubnubApi/NewtonsoftJsonDotNet.cs index 73880b486..d4c97659a 100644 --- a/src/Api/PubnubApi/NewtonsoftJsonDotNet.cs +++ b/src/Api/PubnubApi/NewtonsoftJsonDotNet.cs @@ -546,12 +546,12 @@ public virtual T DeserializeToObject(List listObject) { ack.Timetoken = presenceTimetoken; } - ack.Channel = (listObject.Count == 6) ? listObject[5].ToString() : listObject[4].ToString(); + ack.Channel = (listObject.Count == 8) ? listObject[7].ToString() : listObject[6].ToString(); ack.Channel = ack.Channel.Replace("-pnpres", ""); - if (listObject.Count == 6) + if (listObject.Count == 8) { - ack.Subscription = listObject[4].ToString(); + ack.Subscription = listObject[6].ToString(); ack.Subscription = ack.Subscription.Replace("-pnpres", ""); }