public void TestSubscription() { PNConfiguration pnConfiguration = new PNConfiguration(); pnConfiguration.Origin = EditorCommon.Origin; pnConfiguration.SubscribeKey = EditorCommon.SubscribeKey; pnConfiguration.PublishKey = EditorCommon.PublishKey; pnConfiguration.CipherKey = "enigma"; pnConfiguration.LogVerbosity = PNLogVerbosity.BODY; pnConfiguration.PresenceTimeout = 60; pnConfiguration.PresenceInterval = 30; PubNubUnity pnUnity = new PubNubUnity(pnConfiguration, null, null); pnUnity.SubscriptionInstance.CleanUp(); PNLoggingMethod pnLog = new PNLoggingMethod(pnConfiguration.LogVerbosity); //Add CE with ch cg, ch-pres, cgpres, 2 awaiting connect callback with userstate List <ChannelEntity> channelEntities = EditorCommon.CreateListOfChannelEntities(true, true, true, true, pnLog); pnUnity.SubscriptionInstance.Add(channelEntities); // Test All RunAssertions(pnUnity, "{\"ch1\":{\"k\":\"v\",\"k2\":\"v2\"},\"ch2\":{\"k3\":\"v3\",\"k4\":\"v4\"},\"ch2-pnpres\":{\"k7\":\"v7\",\"k8\":\"v8\"},\"ch7\":{\"k7\":\"v7\",\"k8\":\"v8\"},\"cg1\":{\"k5\":\"v5\",\"k6\":\"v6\"},\"cg2\":{\"k7\":\"v7\",\"k8\":\"v8\"},\"cg2-pnpres\":{\"k7\":\"v7\",\"k8\":\"v8\"},\"cg8\":{\"k7\":\"v7\",\"k8\":\"v8\"}}", false, true, true, true, true, 4, 4, new string[] { "cg1", "cg2", "cg2-pnpres", "cg8" }, new string[] { "ch1", "ch2", "ch2-pnpres", "ch7" }, new string[] { "ch1", "ch2", "ch7", "cg1", "cg2", "cg8" }, new string[] { "cg2-pnpres", "ch2-pnpres" }, new string[] { "ch7", "cg8" }, new string[] { "ch1", "ch2", "ch2-pnpres", "ch7", "cg1", "cg2", "cg2-pnpres", "cg8" }); // Delete 2 ChannelEntity ce = Helpers.CreateChannelEntity("ch2", false, false, null, pnLog); pnUnity.SubscriptionInstance.Delete(ce); ChannelEntity ce2 = Helpers.CreateChannelEntity("cg2", false, true, null, pnLog); pnUnity.SubscriptionInstance.Delete(ce2); // Test All RunAssertions(pnUnity, "{\"ch1\":{\"k\":\"v\",\"k2\":\"v2\"},\"ch2-pnpres\":{\"k7\":\"v7\",\"k8\":\"v8\"},\"ch7\":{\"k7\":\"v7\",\"k8\":\"v8\"},\"cg1\":{\"k5\":\"v5\",\"k6\":\"v6\"},\"cg2-pnpres\":{\"k7\":\"v7\",\"k8\":\"v8\"},\"cg8\":{\"k7\":\"v7\",\"k8\":\"v8\"}}", false, true, true, true, true, 3, 3, new string[] { "cg1", "cg2-pnpres", "cg8" }, new string[] { "ch1", "ch2-pnpres", "ch7" }, new string[] { "ch1", "ch7", "cg1", "cg8" }, new string[] { "cg2-pnpres", "ch2-pnpres" }, new string[] { "ch7", "cg8" }, new string[] { "ch1", "ch2-pnpres", "ch7", "cg1", "cg2-pnpres", "cg8" }); // UpdateOrAddUserStateOfEntity ChannelEntity ce3 = Helpers.CreateChannelEntity("ch1", false, false, null, pnLog); var dictSMN = new Dictionary <string, object>(); dictSMN.Add("k", "v9"); pnUnity.SubscriptionInstance.TryUpdateOrAddUserStateOfEntity(ref ce3, dictSMN, true); // Test All RunAssertions(pnUnity, "{\"ch1\":{\"k\":\"v9\",\"k2\":\"v2\"},\"ch2-pnpres\":{\"k7\":\"v7\",\"k8\":\"v8\"},\"ch7\":{\"k7\":\"v7\",\"k8\":\"v8\"},\"cg1\":{\"k5\":\"v5\",\"k6\":\"v6\"},\"cg2-pnpres\":{\"k7\":\"v7\",\"k8\":\"v8\"},\"cg8\":{\"k7\":\"v7\",\"k8\":\"v8\"}}", false, true, true, true, true, 3, 3, new string[] { "cg1", "cg2-pnpres", "cg8" }, new string[] { "ch1", "ch2-pnpres", "ch7" }, new string[] { "ch1", "ch7", "cg1", "cg8" }, new string[] { "cg2-pnpres", "ch2-pnpres" }, new string[] { "ch7", "cg8" }, new string[] { "ch1", "ch2-pnpres", "ch7", "cg1", "cg2-pnpres", "cg8" }); // UpdateIsAwaitingConnectCallbacksOfEntity ChannelEntity ce4 = Helpers.CreateChannelEntity("ch7", false, false, null, pnLog); ChannelEntity ce5 = Helpers.CreateChannelEntity("cg8", false, true, null, pnLog); List <ChannelEntity> lstCE = new List <ChannelEntity>(); lstCE.Add(ce4); lstCE.Add(ce5); pnUnity.SubscriptionInstance.UpdateIsAwaitingConnectCallbacksOfEntity(lstCE, false); // Test All RunAssertions(pnUnity, "{\"ch1\":{\"k\":\"v9\",\"k2\":\"v2\"},\"ch2-pnpres\":{\"k7\":\"v7\",\"k8\":\"v8\"},\"ch7\":{\"k7\":\"v7\",\"k8\":\"v8\"},\"cg1\":{\"k5\":\"v5\",\"k6\":\"v6\"},\"cg2-pnpres\":{\"k7\":\"v7\",\"k8\":\"v8\"},\"cg8\":{\"k7\":\"v7\",\"k8\":\"v8\"}}", true, true, true, true, true, 3, 3, new string[] { "cg1", "cg2-pnpres", "cg8" }, new string[] { "ch1", "ch2-pnpres", "ch7" }, new string[] { "ch1", "ch7", "cg1", "cg8" }, new string[] { "cg2-pnpres", "ch2-pnpres" }, new string[] { "ch7", "cg8" }, new string[] { "ch1", "ch2-pnpres", "ch7", "cg1", "cg2-pnpres", "cg8" }); // CleanUp pnUnity.SubscriptionInstance.CleanUp(); // Test All RunAssertions(pnUnity, String.Empty, false, false, false, false, false, 0, 0, new string[] {}, new string[] {}, new string[] {}, new string[] {}, new string[] {}, new string[] {}); }