public void TestBuildAddChannelsToChannelGroupRequestCommon(string[] channels, bool ssl, string authKey, bool sendQueryParams) { Dictionary <string, string> queryParams = new Dictionary <string, string>(); string queryParamString = ""; if (sendQueryParams) { queryParams.Add("d", "f"); queryParamString = "&d=f"; } else { queryParams = null; } string channelGroup = "channelGroup"; string uuid = "customuuid"; PNConfiguration pnConfiguration = new PNConfiguration(); pnConfiguration.Origin = EditorCommon.Origin; pnConfiguration.SubscribeKey = EditorCommon.SubscribeKey; pnConfiguration.PublishKey = EditorCommon.PublishKey; pnConfiguration.Secure = ssl; pnConfiguration.CipherKey = "enigma"; pnConfiguration.LogVerbosity = PNLogVerbosity.BODY; pnConfiguration.PresenceTimeout = 60; pnConfiguration.PresenceInterval = 30; pnConfiguration.AuthKey = authKey; pnConfiguration.UUID = uuid; PubNubUnity pnUnity = new PubNubUnity(pnConfiguration, null, null); pnConfiguration.AuthKey = authKey; string authKeyString = ""; if (!string.IsNullOrEmpty(authKey)) { authKeyString = string.Format("&auth={0}", pnConfiguration.AuthKey); } Uri uri = BuildRequests.BuildAddChannelsToChannelGroupRequest(channels, "", channelGroup, pnUnity, queryParams ); string ch = string.Join(",", channels); //http://ps.pndsn.com/v1/channel-registration/sub-key/demo-36/channel-group/channelGroup?add=addChannel1,%20addChannel2&uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityOSX%2F3.7 string expected = string.Format("http{0}://{1}/v1/channel-registration/sub-key/{2}/channel-group/{3}?add={4}&uuid={5}{6}&pnsdk={7}{8}", ssl?"s":"", pnConfiguration.Origin, EditorCommon.SubscribeKey, channelGroup, Utility.EncodeUricomponent(ch, PNOperationType.PNAddChannelsToGroupOperation, true, true), uuid, authKeyString, Utility.EncodeUricomponent(pnUnity.Version, PNOperationType.PNAddChannelsToGroupOperation, false, true), queryParamString ); string received = uri.OriginalString; EditorCommon.LogAndCompare(expected, received); }
public void TestBuildAddChannelsToChannelGroupRequestCommon(string[] channels, bool ssl, string authKey) { string channelGroup = "channelGroup"; string uuid = "customuuid"; Pubnub pubnub = new Pubnub( Common.PublishKey, Common.SubscribeKey, "", "", ssl ); pubnub.AuthenticationKey = authKey; string authKeyString = ""; if (!string.IsNullOrEmpty(authKey)) { authKeyString = string.Format("&auth={0}", pubnub.AuthenticationKey); } Uri uri = BuildRequests.BuildAddChannelsToChannelGroupRequest(channels, "", channelGroup, uuid, ssl, pubnub.Origin, pubnub.AuthenticationKey, Common.SubscribeKey ); string ch = string.Join(",", channels); //http://pubsub.pubnub.com/v1/channel-registration/sub-key/demo-36/channel-group/channelGroup?add=addChannel1,%20addChannel2&uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityOSX%2F3.7 string expected = string.Format("http{0}://{1}/v1/channel-registration/sub-key/{2}/channel-group/{3}?add={4}&uuid={5}{6}&pnsdk={7}", ssl?"s":"", pubnub.Origin, Common.SubscribeKey, channelGroup, Utility.EncodeUricomponent(ch, ResponseType.ChannelGroupAdd, true, true), uuid, authKeyString, Utility.EncodeUricomponent(PubnubUnity.Version, ResponseType.ChannelGroupAdd, false, true) ); string received = uri.OriginalString; Common.LogAndCompare(expected, received); }