From 5ab0b0a1aa220c1fe0585ef335d61c719524d31f Mon Sep 17 00:00:00 2001 From: "PUBNUB\\jakub.grzesiowski" Date: Mon, 23 Sep 2024 16:11:14 +0200 Subject: [PATCH] change to PAM v3 in WhenObjectChannelMetadata --- .../WhenObjectChannelMetadata.cs | 321 ++++++++++-------- 1 file changed, 184 insertions(+), 137 deletions(-) diff --git a/src/UnitTests/PubnubApi.Tests/WhenObjectChannelMetadata.cs b/src/UnitTests/PubnubApi.Tests/WhenObjectChannelMetadata.cs index 18d9a23db..d398517e8 100644 --- a/src/UnitTests/PubnubApi.Tests/WhenObjectChannelMetadata.cs +++ b/src/UnitTests/PubnubApi.Tests/WhenObjectChannelMetadata.cs @@ -14,11 +14,11 @@ public class WhenObjectChannelMetadata : TestHarness private static int manualResetEventWaitTimeout = 310 * 1000; private static Pubnub pubnub; private static Server server; - private static string authKey = "myauth"; - private static string authToken = ""; + private static string authToken; + private static string channelMetadataId = "pandu-ut-sid"; [SetUp] - public static void Init() + public static async Task Init() { UnitTestLog unitLog = new Tests.UnitTestLog(); unitLog.LogLevel = MockServer.LoggingMethod.Level.Verbose; @@ -26,59 +26,57 @@ public static void Init() MockServer.LoggingMethod.MockServerLog = unitLog; if (PubnubCommon.EnableStubTest) { - server.Start(); + server.Start(); } - if (!PubnubCommon.PAMServerSideGrant) { return; } - - bool receivedGrantMessage = false; - string channelMetadataId = "pandu-ut-sid"; + if (!PubnubCommon.PAMServerSideGrant) + { + return; + } PNConfiguration config = new PNConfiguration(new UserId("mytestuuid")) { PublishKey = PubnubCommon.PublishKey, SubscribeKey = PubnubCommon.SubscribeKey, SecretKey = PubnubCommon.SecretKey, - AuthKey = authKey, Secure = false }; server.RunOnHttps(false); pubnub = createPubNubInstance(config); - ManualResetEvent grantManualEvent = new ManualResetEvent(false); - pubnub.Grant().Channels(new[] { channelMetadataId }).AuthKeys(new[] { authKey }).Read(true).Write(true).Manage(true).Update(true).Delete(true).Get(true).TTL(20) - .Execute(new PNAccessManagerGrantResultExt( - (r, s) => - { - try - { - Debug.WriteLine("PNStatus={0}", pubnub.JsonPluggableLibrary.SerializeToJsonString(s)); - if (r != null) - { - Debug.WriteLine("PNAccessManagerGrantResult={0}", pubnub.JsonPluggableLibrary.SerializeToJsonString(r)); - if (r.Channels != null && r.Channels.Count > 0) - { - var read = r.Channels[channelMetadataId][authKey].ReadEnabled; - var write = r.Channels[channelMetadataId][authKey].WriteEnabled; - if (read && write) { receivedGrantMessage = true; } - } - } - } - catch { /* ignore */ } - finally - { - grantManualEvent.Set(); - } - })); - if (!PubnubCommon.EnableStubTest) Thread.Sleep(1000); - - grantManualEvent.WaitOne(); + var grantResult = await pubnub.GrantToken().TTL(20).AuthorizedUuid(config.UserId).Resources( + new PNTokenResources() + { + Channels = new Dictionary() + { + { + channelMetadataId, new PNTokenAuthValues() + { + Read = true, + Write = true, + Create = true, + Get = true, + Delete = true, + Join = true, + Update = true, + Manage = true + } + } + } + }).ExecuteAsync(); + if (!PubnubCommon.EnableStubTest) + { + await Task.Delay(3000); + } + + authToken = grantResult.Result?.Token; pubnub.Destroy(); pubnub.PubnubUnitTest = null; pubnub = null; - Assert.IsTrue(receivedGrantMessage, "WhenObjectChannelMetadata Grant access failed."); + Assert.IsTrue(grantResult.Result != null && grantResult.Status.Error == false, + "WhenObjectChannelMetadata Grant access failed."); } [TearDown] @@ -90,6 +88,7 @@ public static void Exit() pubnub.PubnubUnitTest = null; pubnub = null; } + server.Stop(); } @@ -106,8 +105,6 @@ public static void ThenChannelMetadataCRUDShouldReturnSuccessCodeAndInfo() bool receivedMessage = false; - string channelMetadataId = "pandu-ut-sid"; - PNConfiguration config = new PNConfiguration(new UserId("mytestuuid")) { PublishKey = PubnubCommon.PublishKey, @@ -118,61 +115,69 @@ public static void ThenChannelMetadataCRUDShouldReturnSuccessCodeAndInfo() { config.SecretKey = PubnubCommon.SecretKey; } - else if (!string.IsNullOrEmpty(authKey) && !PubnubCommon.SuppressAuthKey) - { - config.AuthKey = authKey; - } + server.RunOnHttps(false); pubnub = createPubNubInstance(config); + pubnub.SetAuthToken(authToken); ManualResetEvent manualEvent = new ManualResetEvent(false); manualResetEventWaitTimeout = 310 * 1000; System.Diagnostics.Debug.WriteLine("pubnub.DeleteSpace() STARTED"); pubnub.RemoveChannelMetadata().Channel(channelMetadataId).Execute(new PNRemoveChannelMetadataResultExt( - delegate (PNRemoveChannelMetadataResult result, PNStatus status) { })); + delegate(PNRemoveChannelMetadataResult result, PNStatus status) { })); manualEvent.WaitOne(2000); manualEvent = new ManualResetEvent(false); + #region "CreateSpace" + System.Diagnostics.Debug.WriteLine("pubnub.CreateSpace() STARTED"); pubnub.SetChannelMetadata().Channel(channelMetadataId).Name("pandu-ut-spname") - .Execute(new PNSetChannelMetadataResultExt((r, s) => + .Execute(new PNSetChannelMetadataResultExt((r, s) => + { + if (r != null && s.StatusCode == 200 && !s.Error) { - if (r != null && s.StatusCode == 200 && !s.Error) + pubnub.JsonPluggableLibrary.SerializeToJsonString(r); + if (channelMetadataId == r.Channel) { - pubnub.JsonPluggableLibrary.SerializeToJsonString(r); - if (channelMetadataId == r.Channel) - { - receivedMessage = true; - } + receivedMessage = true; } - manualEvent.Set(); - })); + } + + manualEvent.Set(); + })); + #endregion + manualEvent.WaitOne(manualResetEventWaitTimeout); if (receivedMessage) { receivedMessage = false; manualEvent = new ManualResetEvent(false); + #region "SetChannelMetadata" + System.Diagnostics.Debug.WriteLine("pubnub.SetChannelMetadata() STARTED"); pubnub.SetChannelMetadata().Channel(channelMetadataId).Name("pandu-ut-spname-upd") .Description("pandu-ut-spdesc") .Custom(new Dictionary() { { "color", "red" } }) - .Execute(new PNSetChannelMetadataResultExt((r, s) => + .Execute(new PNSetChannelMetadataResultExt((r, s) => + { + if (r != null && s.StatusCode == 200 && !s.Error) { - if (r != null && s.StatusCode == 200 && !s.Error) + pubnub.JsonPluggableLibrary.SerializeToJsonString(r); + if (channelMetadataId == r.Channel) { - pubnub.JsonPluggableLibrary.SerializeToJsonString(r); - if (channelMetadataId == r.Channel) - { - receivedMessage = true; - } + receivedMessage = true; } - manualEvent.Set(); - })); + } + + manualEvent.Set(); + })); + #endregion + manualEvent.WaitOne(manualResetEventWaitTimeout); } @@ -180,7 +185,9 @@ public static void ThenChannelMetadataCRUDShouldReturnSuccessCodeAndInfo() { receivedMessage = false; manualEvent = new ManualResetEvent(false); + #region "GetChannelMetadata" + System.Diagnostics.Debug.WriteLine("pubnub.GetChannelMetadata() STARTED"); pubnub.GetChannelMetadata().Channel(channelMetadataId).IncludeCustom(true) .Execute(new PNGetChannelMetadataResultExt((r, s) => @@ -193,9 +200,12 @@ public static void ThenChannelMetadataCRUDShouldReturnSuccessCodeAndInfo() receivedMessage = true; } } + manualEvent.Set(); })); + #endregion + manualEvent.WaitOne(manualResetEventWaitTimeout); } @@ -203,7 +213,9 @@ public static void ThenChannelMetadataCRUDShouldReturnSuccessCodeAndInfo() { receivedMessage = false; manualEvent = new ManualResetEvent(false); + #region "GetAllChannelMetadata" + System.Diagnostics.Debug.WriteLine("pubnub.GetAllChannelMetadata() STARTED"); pubnub.GetAllChannelMetadata().IncludeCount(true) .Execute(new PNGetAllChannelMetadataResultExt((r, s) => @@ -212,17 +224,21 @@ public static void ThenChannelMetadataCRUDShouldReturnSuccessCodeAndInfo() { pubnub.JsonPluggableLibrary.SerializeToJsonString(r); List spaceList = r.Channels; - if (spaceList != null && spaceList.Count > 0 && spaceList.Find(x => x.Channel == channelMetadataId) != null) + if (spaceList != null && spaceList.Count > 0 && + spaceList.Find(x => x.Channel == channelMetadataId) != null) { receivedMessage = true; } } + manualEvent.Set(); })); + #endregion + manualEvent.WaitOne(manualResetEventWaitTimeout); } - + Debug.WriteLine("---TEST---"); if (!receivedMessage) @@ -240,7 +256,7 @@ public static void ThenChannelMetadataCRUDShouldReturnSuccessCodeAndInfo() public static void ThenWithAsyncChannelMetadataCRUDShouldReturnSuccessCodeAndInfo() #else public static async Task ThenWithAsyncChannelMetadataCRUDShouldReturnSuccessCodeAndInfo() -#endif +#endif { server.ClearRequests(); @@ -264,12 +280,10 @@ public static async Task ThenWithAsyncChannelMetadataCRUDShouldReturnSuccessCode { config.SecretKey = PubnubCommon.SecretKey; } - else if (!string.IsNullOrEmpty(authKey) && !PubnubCommon.SuppressAuthKey) - { - config.AuthKey = authKey; - } + server.RunOnHttps(false); pubnub = createPubNubInstance(config); + pubnub.SetAuthToken(authToken); System.Diagnostics.Debug.WriteLine("pubnub.RemoveChannelMetadata() STARTED"); #if NET40 @@ -279,13 +293,17 @@ public static async Task ThenWithAsyncChannelMetadataCRUDShouldReturnSuccessCode #endif #region "SetChannelMetadata" + System.Diagnostics.Debug.WriteLine("pubnub.SetChannelMetadata() STARTED"); #if NET40 - PNResult createSpaceResult = Task.Factory.StartNew(async () => await pubnub.SetChannelMetadata().Channel(channelMetadataId).Name("pandu-ut-spname").ExecuteAsync()).Result.Result; + PNResult createSpaceResult = + Task.Factory.StartNew(async () => await pubnub.SetChannelMetadata().Channel(channelMetadataId).Name("pandu-ut-spname").ExecuteAsync()).Result.Result; #else - PNResult createSpaceResult = await pubnub.SetChannelMetadata().Channel(channelMetadataId).Name("pandu-ut-spname").ExecuteAsync(); + PNResult createSpaceResult = await pubnub.SetChannelMetadata() + .Channel(channelMetadataId).Name("pandu-ut-spname").ExecuteAsync(); #endif - if (createSpaceResult.Result != null && createSpaceResult.Status.StatusCode == 200 && !createSpaceResult.Status.Error) + if (createSpaceResult.Result != null && createSpaceResult.Status.StatusCode == 200 && + !createSpaceResult.Status.Error) { pubnub.JsonPluggableLibrary.SerializeToJsonString(createSpaceResult.Result); if (channelMetadataId == createSpaceResult.Result.Channel) @@ -293,25 +311,31 @@ public static async Task ThenWithAsyncChannelMetadataCRUDShouldReturnSuccessCode receivedMessage = true; } } + #endregion if (receivedMessage) { receivedMessage = false; + #region "SetChannelMetadata" + System.Diagnostics.Debug.WriteLine("pubnub.SetChannelMetadata() STARTED"); #if NET40 - PNResult updateSpaceResult = Task.Factory.StartNew(async () => await pubnub.SetChannelMetadata().Channel(channelMetadataId).Name("pandu-ut-spname-upd") + PNResult updateSpaceResult = + Task.Factory.StartNew(async () => await pubnub.SetChannelMetadata().Channel(channelMetadataId).Name("pandu-ut-spname-upd") .Description("pandu-ut-spdesc") .Custom(new Dictionary() { { "color", "red" } }) .ExecuteAsync()).Result.Result; #else - PNResult updateSpaceResult = await pubnub.SetChannelMetadata().Channel(channelMetadataId).Name("pandu-ut-spname-upd") + PNResult updateSpaceResult = await pubnub.SetChannelMetadata() + .Channel(channelMetadataId).Name("pandu-ut-spname-upd") .Description("pandu-ut-spdesc") .Custom(new Dictionary() { { "color", "red" } }) .ExecuteAsync(); #endif - if (updateSpaceResult.Result != null && updateSpaceResult.Status.StatusCode == 200 && !updateSpaceResult.Status.Error) + if (updateSpaceResult.Result != null && updateSpaceResult.Status.StatusCode == 200 && + !updateSpaceResult.Status.Error) { pubnub.JsonPluggableLibrary.SerializeToJsonString(updateSpaceResult.Result); if (channelMetadataId == updateSpaceResult.Result.Channel) @@ -319,22 +343,28 @@ public static async Task ThenWithAsyncChannelMetadataCRUDShouldReturnSuccessCode receivedMessage = true; } } + #endregion } if (receivedMessage) { receivedMessage = false; + #region "GetSpace" + System.Diagnostics.Debug.WriteLine("pubnub.GetChannelMetadata() STARTED"); #if NET40 - PNResult getSpaceResult = Task.Factory.StartNew(async () => await pubnub.GetChannelMetadata().Channel(channelMetadataId).IncludeCustom(true) + PNResult getSpaceResult = + Task.Factory.StartNew(async () => await pubnub.GetChannelMetadata().Channel(channelMetadataId).IncludeCustom(true) .ExecuteAsync()).Result.Result; #else - PNResult getSpaceResult = await pubnub.GetChannelMetadata().Channel(channelMetadataId).IncludeCustom(true) + PNResult getSpaceResult = await pubnub.GetChannelMetadata() + .Channel(channelMetadataId).IncludeCustom(true) .ExecuteAsync(); #endif - if (getSpaceResult.Result != null && getSpaceResult.Status.StatusCode == 200 && !getSpaceResult.Status.Error) + if (getSpaceResult.Result != null && getSpaceResult.Status.StatusCode == 200 && + !getSpaceResult.Status.Error) { pubnub.JsonPluggableLibrary.SerializeToJsonString(getSpaceResult.Result); if (channelMetadataId == getSpaceResult.Result.Channel) @@ -342,28 +372,36 @@ public static async Task ThenWithAsyncChannelMetadataCRUDShouldReturnSuccessCode receivedMessage = true; } } + #endregion } if (receivedMessage) { receivedMessage = false; + #region "GetSpaces" + System.Diagnostics.Debug.WriteLine("pubnub.GetAllChannelMetadata() STARTED"); #if NET40 - PNResult getSpacesResult = Task.Factory.StartNew(async () => await pubnub.GetAllChannelMetadata().IncludeCount(true).ExecuteAsync()).Result.Result; + PNResult getSpacesResult = + Task.Factory.StartNew(async () => await pubnub.GetAllChannelMetadata().IncludeCount(true).ExecuteAsync()).Result.Result; #else - PNResult getSpacesResult = await pubnub.GetAllChannelMetadata().IncludeCount(true).ExecuteAsync(); + PNResult getSpacesResult = + await pubnub.GetAllChannelMetadata().IncludeCount(true).ExecuteAsync(); #endif - if (getSpacesResult.Result != null && getSpacesResult.Status.StatusCode == 200 && !getSpacesResult.Status.Error) + if (getSpacesResult.Result != null && getSpacesResult.Status.StatusCode == 200 && + !getSpacesResult.Status.Error) { pubnub.JsonPluggableLibrary.SerializeToJsonString(getSpacesResult.Result); List spaceList = getSpacesResult.Result.Channels; - if (spaceList != null && spaceList.Count > 0 && spaceList.Find(x => x.Channel == channelMetadataId) != null) + if (spaceList != null && spaceList.Count > 0 && + spaceList.Find(x => x.Channel == channelMetadataId) != null) { receivedMessage = true; } } + #endregion } @@ -396,9 +434,10 @@ public static void ThenChannelMetadataSetDeleteShouldReturnEventInfo() manualResetEventWaitTimeout = 310 * 1000; SubscribeCallbackExt eventListener = new SubscribeCallbackExt( - delegate (Pubnub pnObj, PNObjectEventResult eventResult) + delegate(Pubnub pnObj, PNObjectEventResult eventResult) { - System.Diagnostics.Debug.WriteLine("EVENT:" + pubnub.JsonPluggableLibrary.SerializeToJsonString(eventResult)); + System.Diagnostics.Debug.WriteLine("EVENT:" + + pubnub.JsonPluggableLibrary.SerializeToJsonString(eventResult)); if (eventResult.Type.ToLowerInvariant() == "channel") { if (eventResult.Event.ToLowerInvariant() == "set") @@ -411,29 +450,23 @@ public static void ThenChannelMetadataSetDeleteShouldReturnEventInfo() } } }, - delegate (Pubnub pnObj, PNStatus status) - { - - } - ); + delegate(Pubnub pnObj, PNStatus status) { } + ); PNConfiguration config = new PNConfiguration(new UserId("mytestuuid")) { PublishKey = PubnubCommon.PublishKey, SubscribeKey = PubnubCommon.SubscribeKey, Secure = false, - AuthKey = "myauth" }; if (PubnubCommon.PAMServerSideRun) { config.SecretKey = PubnubCommon.SecretKey; } - else if (!string.IsNullOrEmpty(authKey) && !PubnubCommon.SuppressAuthKey) - { - config.AuthKey = authKey; - } + server.RunOnHttps(false); pubnub = createPubNubInstance(config); + pubnub.SetAuthToken(authToken); pubnub.AddListener(eventListener); ManualResetEvent manualEvent = new ManualResetEvent(false); @@ -443,50 +476,60 @@ public static void ThenChannelMetadataSetDeleteShouldReturnEventInfo() manualEvent = new ManualResetEvent(false); System.Diagnostics.Debug.WriteLine("pubnub.RemoveChannelMetadata() STARTED"); pubnub.RemoveChannelMetadata().Channel(channelMetadataId).Execute(new PNRemoveChannelMetadataResultExt( - delegate (PNRemoveChannelMetadataResult result, PNStatus status) { })); + delegate(PNRemoveChannelMetadataResult result, PNStatus status) { })); manualEvent.WaitOne(2000); manualEvent = new ManualResetEvent(false); + #region "SetChannelMetadata" + System.Diagnostics.Debug.WriteLine("pubnub.SetChannelMetadata() STARTED"); pubnub.SetChannelMetadata().Channel(channelMetadataId).Name("pandu-ut-spname") - .Execute(new PNSetChannelMetadataResultExt((r, s) => + .Execute(new PNSetChannelMetadataResultExt((r, s) => + { + if (r != null && s.StatusCode == 200 && !s.Error) { - if (r != null && s.StatusCode == 200 && !s.Error) + pubnub.JsonPluggableLibrary.SerializeToJsonString(r); + if (channelMetadataId == r.Channel) { - pubnub.JsonPluggableLibrary.SerializeToJsonString(r); - if (channelMetadataId == r.Channel) - { - receivedMessage = true; - } + receivedMessage = true; } - manualEvent.Set(); - })); + } + + manualEvent.Set(); + })); + #endregion + manualEvent.WaitOne(manualResetEventWaitTimeout); if (receivedMessage) { receivedMessage = false; manualEvent = new ManualResetEvent(false); + #region "SetChannelMetadata" + System.Diagnostics.Debug.WriteLine("pubnub.SetChannelMetadata() STARTED"); pubnub.SetChannelMetadata().Channel(channelMetadataId).Name("pandu-ut-spname-upd") .Description("pandu-ut-spdesc") .Custom(new Dictionary() { { "color", "red" } }) - .Execute(new PNSetChannelMetadataResultExt((r, s) => + .Execute(new PNSetChannelMetadataResultExt((r, s) => + { + if (r != null && s.StatusCode == 200 && !s.Error) { - if (r != null && s.StatusCode == 200 && !s.Error) + pubnub.JsonPluggableLibrary.SerializeToJsonString(r); + if (channelMetadataId == r.Channel) { - pubnub.JsonPluggableLibrary.SerializeToJsonString(r); - if (channelMetadataId == r.Channel) - { - receivedMessage = true; - } + receivedMessage = true; } - manualEvent.Set(); - })); + } + + manualEvent.Set(); + })); + #endregion + manualEvent.WaitOne(manualResetEventWaitTimeout); } @@ -495,7 +538,7 @@ public static void ThenChannelMetadataSetDeleteShouldReturnEventInfo() manualEvent = new ManualResetEvent(false); System.Diagnostics.Debug.WriteLine("pubnub.RemoveChannelMetadata() 2 STARTED"); pubnub.RemoveChannelMetadata().Channel(channelMetadataId).Execute(new PNRemoveChannelMetadataResultExt( - delegate (PNRemoveChannelMetadataResult result, PNStatus status) { })); + delegate(PNRemoveChannelMetadataResult result, PNStatus status) { })); manualEvent.WaitOne(2000); } @@ -509,7 +552,6 @@ public static void ThenChannelMetadataSetDeleteShouldReturnEventInfo() pubnub.Destroy(); pubnub.PubnubUnitTest = null; pubnub = null; - } [Test] @@ -517,7 +559,7 @@ public static void ThenChannelMetadataSetDeleteShouldReturnEventInfo() public static void ThenWithAsyncChannelMetadataUpdateDeleteShouldReturnEventInfo() #else public static async Task ThenWithAsyncChannelMetadataUpdateDeleteShouldReturnEventInfo() -#endif +#endif { server.ClearRequests(); @@ -535,9 +577,10 @@ public static async Task ThenWithAsyncChannelMetadataUpdateDeleteShouldReturnEve manualResetEventWaitTimeout = 310 * 1000; SubscribeCallbackExt eventListener = new SubscribeCallbackExt( - delegate (Pubnub pnObj, PNObjectEventResult eventResult) + delegate(Pubnub pnObj, PNObjectEventResult eventResult) { - System.Diagnostics.Debug.WriteLine("EVENT:" + pubnub.JsonPluggableLibrary.SerializeToJsonString(eventResult)); + System.Diagnostics.Debug.WriteLine("EVENT:" + + pubnub.JsonPluggableLibrary.SerializeToJsonString(eventResult)); if (eventResult.Type.ToLowerInvariant() == "channel") { if (eventResult.Event.ToLowerInvariant() == "set") @@ -550,29 +593,23 @@ public static async Task ThenWithAsyncChannelMetadataUpdateDeleteShouldReturnEve } } }, - delegate (Pubnub pnObj, PNStatus status) - { - - } - ); + delegate(Pubnub pnObj, PNStatus status) { } + ); PNConfiguration config = new PNConfiguration(new UserId("mytestuuid")) { PublishKey = PubnubCommon.PublishKey, SubscribeKey = PubnubCommon.SubscribeKey, Secure = false, - AuthKey = "myauth" }; if (PubnubCommon.PAMServerSideRun) { config.SecretKey = PubnubCommon.SecretKey; } - else if (!string.IsNullOrEmpty(authKey) && !PubnubCommon.SuppressAuthKey) - { - config.AuthKey = authKey; - } + server.RunOnHttps(false); pubnub = createPubNubInstance(config); + pubnub.SetAuthToken(authToken); pubnub.AddListener(eventListener); ManualResetEvent manualEvent = new ManualResetEvent(false); @@ -587,13 +624,17 @@ public static async Task ThenWithAsyncChannelMetadataUpdateDeleteShouldReturnEve #endif #region "SetChannelMetadata" + System.Diagnostics.Debug.WriteLine("pubnub.SetChannelMetadata() STARTED"); #if NET40 - PNResult createSpaceResult = Task.Factory.StartNew(async () => await pubnub.SetChannelMetadata().Channel(channelMetadataId).Name("pandu-ut-spname").ExecuteAsync()).Result.Result; + PNResult createSpaceResult = + Task.Factory.StartNew(async () => await pubnub.SetChannelMetadata().Channel(channelMetadataId).Name("pandu-ut-spname").ExecuteAsync()).Result.Result; #else - PNResult createSpaceResult = await pubnub.SetChannelMetadata().Channel(channelMetadataId).Name("pandu-ut-spname").ExecuteAsync(); + PNResult createSpaceResult = await pubnub.SetChannelMetadata() + .Channel(channelMetadataId).Name("pandu-ut-spname").ExecuteAsync(); #endif - if (createSpaceResult.Result != null && createSpaceResult.Status.StatusCode == 200 && !createSpaceResult.Status.Error) + if (createSpaceResult.Result != null && createSpaceResult.Status.StatusCode == 200 && + !createSpaceResult.Status.Error) { pubnub.JsonPluggableLibrary.SerializeToJsonString(createSpaceResult.Result); if (channelMetadataId == createSpaceResult.Result.Channel) @@ -601,25 +642,31 @@ public static async Task ThenWithAsyncChannelMetadataUpdateDeleteShouldReturnEve receivedMessage = true; } } + #endregion if (receivedMessage) { receivedMessage = false; + #region "SetChannelMetadata" + System.Diagnostics.Debug.WriteLine("pubnub.SetChannelMetadata() STARTED"); #if NET40 - PNResult updateSpaceResult = Task.Factory.StartNew(async () => await pubnub.SetChannelMetadata().Channel(channelMetadataId).Name("pandu-ut-spname-upd") + PNResult updateSpaceResult = + Task.Factory.StartNew(async () => await pubnub.SetChannelMetadata().Channel(channelMetadataId).Name("pandu-ut-spname-upd") .Description("pandu-ut-spdesc") .Custom(new Dictionary() { { "color", "red" } }) .ExecuteAsync()).Result.Result; #else - PNResult updateSpaceResult = await pubnub.SetChannelMetadata().Channel(channelMetadataId).Name("pandu-ut-spname-upd") + PNResult updateSpaceResult = await pubnub.SetChannelMetadata() + .Channel(channelMetadataId).Name("pandu-ut-spname-upd") .Description("pandu-ut-spdesc") .Custom(new Dictionary() { { "color", "red" } }) .ExecuteAsync(); #endif - if (updateSpaceResult.Result != null && updateSpaceResult.Status.StatusCode == 200 && !updateSpaceResult.Status.Error) + if (updateSpaceResult.Result != null && updateSpaceResult.Status.StatusCode == 200 && + !updateSpaceResult.Status.Error) { pubnub.JsonPluggableLibrary.SerializeToJsonString(updateSpaceResult.Result); if (channelMetadataId == updateSpaceResult.Result.Channel) @@ -627,6 +674,7 @@ public static async Task ThenWithAsyncChannelMetadataUpdateDeleteShouldReturnEve receivedMessage = true; } } + #endregion } @@ -650,7 +698,6 @@ public static async Task ThenWithAsyncChannelMetadataUpdateDeleteShouldReturnEve pubnub.Destroy(); pubnub.PubnubUnitTest = null; pubnub = null; - } } -} +} \ No newline at end of file