public void ThenDisableJsonEncodeShouldSendSerializedObjectMessage()
        {
            Debug.Log("Running ThenDisableJsonEncodeShouldSendSerializedObjectMessage()");
            isSerializedObjectMessagePublished = false;
            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            pubnub.EnableJsonEncodingForPublish = false;

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenAMessageIsPublished";
            unitTest.TestCaseName  = "ThenDisableJsonEncodeShouldSendSerializedObjectMessage";
            pubnub.PubnubUnitTest  = unitTest;

            string channel = "hello_my_channel";
            object message = "{\"operation\":\"ReturnData\",\"channel\":\"Mobile1\",\"sequenceNumber\":0,\"data\":[\"ping 1.0.0.1\"]}";

            serializedObjectMessageForPublish = message.ToString();

            pubnub.Publish <string>(channel, message, ReturnSuccessSerializedObjectMessageForPublishCallback, DummyErrorCallback);
            mreSerializedObjectMessageForPublish.WaitOne(310 * 1000);
            Thread.Sleep(1000);

            if (!isSerializedObjectMessagePublished)
            {
                UUnitAssert.True(isSerializedObjectMessagePublished, "Serialized Object Message Publish Failed");
            }
            else
            {
                pubnub.DetailedHistory <string>(channel, -1, serializedMessagePublishTimetoken, -1, false, CaptureSerializedMessagePublishDetailedHistoryCallback, DummyErrorCallback);
                mreSerializedMessagePublishDetailedHistory.WaitOne(310 * 1000);
                UUnitAssert.True(isSerializedObjectMessageDetailedHistory, "Unable to match the successful serialized object message Publish");
            }
        }
        public void ThenDuplicateChannelShouldReturnAlreadySubscribed()
        {
            receivedAlreadySubscribedMessage = false;
            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenSubscribedToAChannel";
            unitTest.TestCaseName  = "ThenDuplicateChannelShouldReturnAlreadySubscribed";

            pubnub.PubnubUnitTest = unitTest;


            string channel = "my/channel";

            pubnub.Subscribe <string>(channel, DummyMethodDuplicateChannelUserCallback1, DummyMethodDuplicateChannelConnectCallback);
            Thread.Sleep(100);

            pubnub.Subscribe <string>(channel, DummyMethodDuplicateChannelUserCallback2, DummyMethodDuplicateChannelConnectCallback);
            meAlreadySubscribed.WaitOne();

            pubnub.EndPendingRequests();

            UUnitAssert.True(receivedAlreadySubscribedMessage, "WhenSubscribedToAChannel --> ThenDuplicateChannelShouldReturnAlreadySubscribed Failed");
        }
        public void ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()
        {
            Debug.Log("Running ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()");
            isEncryptObjectPublished = false;
            Pubnub pubnub = new Pubnub("demo", "demo", "", "enigma", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenAMessageIsPublished";
            unitTest.TestCaseName  = "ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo";
            pubnub.PubnubUnitTest  = unitTest;

            string channel = "hello_my_channel";
            object message = new SecretCustomClass();

            messageObjectForEncryptPublish = new JsonFXDotNet().SerializeToJsonString(message);

            pubnub.Publish <string>(channel, message, ReturnSuccessEncryptObjectPublishCodeCallback, DummyErrorCallback);
            mreEncryptObjectPublish.WaitOne(310 * 1000);
            Thread.Sleep(1000);

            if (!isEncryptObjectPublished)
            {
                UUnitAssert.True(isEncryptObjectPublished, "Encrypt Object Publish Failed");
            }
            else
            {
                pubnub.DetailedHistory <string>(channel, -1, encryptObjectPublishTimetoken, -1, false, CaptureEncryptObjectDetailedHistoryCallback, DummyErrorCallback);
                mreEncryptObjectDetailedHistory.WaitOne(310 * 1000);
                UUnitAssert.True(isEncryptObjectDetailedHistory, "Unable to match the successful encrypt object Publish");
            }
        }
        public void ThenShouldReturnUnsubscribedMessage()
        {
            Debug.Log("Running ThenShouldReturnUnsubscribedMessage()");
            receivedChannelConnectedMessage = false;
            receivedUnsubscribedMessage     = false;

            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenUnsubscribedToAChannel";
            unitTest.TestCaseName  = "ThenShouldReturnUnsubscribedMessage";
            pubnub.PubnubUnitTest  = unitTest;

            string channel = "hello_my_channel";

            pubnub.Subscribe <string>(channel, DummyMethodChannelSubscribeUserCallback, DummyMethodChannelSubscribeConnectCallback, DummyErrorCallback);
            meChannelSubscribed.WaitOne();

            if (receivedChannelConnectedMessage)
            {
                pubnub.Unsubscribe <string>(channel, DummyMethodUnsubscribeChannelUserCallback, DummyMethodUnsubscribeChannelConnectCallback, DummyMethodUnsubscribeChannelDisconnectCallback, DummyErrorCallback);
                meChannelUnsubscribed.WaitOne();
            }

            pubnub.EndPendingRequests();

            UUnitAssert.True(receivedUnsubscribedMessage, "WhenUnsubscribedToAChannel --> ThenShouldReturnUnsubscribedMessage Failed");
        }
        public void ThenSubscribeShouldReturnReceivedMessage()
        {
            receivedMessage = false;
            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenSubscribedToAChannel";
            unitTest.TestCaseName  = "ThenSubscribeShouldReturnReceivedMessage";

            pubnub.PubnubUnitTest = unitTest;

            string channel = "my/channel";

            pubnub.Subscribe <string>(channel, ReceivedMessageCallbackWhenSubscribed, SubscribeDummyMethodForConnectCallback);

            pubnub.Publish <string>(channel, "Test for WhenSubscribedToAChannel ThenItShouldReturnReceivedMessage", dummyPublishCallback);
            mePublish.WaitOne(310 * 1000);

            meSubscribeNoConnect.WaitOne(310 * 1000);
            pubnub.Unsubscribe <string>(channel, dummyUnsubscribeCallback, SubscribeDummyMethodForConnectCallback, UnsubscribeDummyMethodForDisconnectCallback);

            meUnsubscribe.WaitOne(310 * 1000);

            pubnub.EndPendingRequests();

            UUnitAssert.True(receivedMessage, "WhenSubscribedToAChannel --> ThenItShouldReturnReceivedMessage Failed");
        }
Esempio n. 6
0
        public void ThenPresenceShouldReturnCustomUUID()
        {
            Debug.Log("Running ThenPresenceShouldReturnCustomUUID()");
            receivedCustomUUID = false;

            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenAClientIsPresented";
            unitTest.TestCaseName  = "ThenPresenceShouldReturnCustomUUID";
            pubnub.PubnubUnitTest  = unitTest;

            string channel = "hello_my_channel";

            pubnub.Presence <string>(channel, ThenPresenceWithCustomUUIDShouldReturnMessage, PresenceUUIDDummyMethodForConnectCallback, DummyErrorCallback);
            Thread.Sleep(1000);

            //since presence expects from stimulus from sub/unsub...
            pubnub.SessionUUID = customUUID;
            pubnub.Subscribe <string>(channel, DummyMethodForSubscribeUUID, SubscribeUUIDDummyMethodForConnectCallback, DummyErrorCallback);
            Thread.Sleep(1000);
            subscribeUUIDManualEvent.WaitOne(310 * 1000);

            presenceUUIDManualEvent.WaitOne(310 * 1000);

            pubnub.EndPendingRequests();

            UUnitAssert.True(receivedCustomUUID, "Custom UUID not received");
        }
        public void ThenMultiSubscribeShouldReturnConnectStatus()
        {
            receivedChannel1ConnectMessage = false;
            receivedChannel2ConnectMessage = false;
            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenSubscribedToAChannel";
            unitTest.TestCaseName  = "ThenMultiSubscribeShouldReturnConnectStatus";

            pubnub.PubnubUnitTest = unitTest;


            string channel1 = "my/channel1";

            pubnub.Subscribe <string>(channel1, ReceivedChannelUserCallback, ReceivedChannel1ConnectCallback);
            meChannel1SubscribeConnect.WaitOne(310 * 1000);

            string channel2 = "my/channel2";

            pubnub.Subscribe <string>(channel2, ReceivedChannelUserCallback, ReceivedChannel2ConnectCallback);
            meChannel2SubscribeConnect.WaitOne(310 * 1000);

            pubnub.EndPendingRequests();

            UUnitAssert.True(receivedChannel1ConnectMessage && receivedChannel2ConnectMessage, "WhenSubscribedToAChannel --> ThenSubscribeShouldReturnConnectStatus Failed");
        }
Esempio n. 8
0
        public void ThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo()
        {
            Debug.Log("Running ThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo()");
            isSecretEncryptPublished = false;
            Pubnub pubnub = new Pubnub("demo", "demo", "key", "enigma", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenAMessageIsPublished";
            unitTest.TestCaseName  = "ThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo";

            pubnub.PubnubUnitTest = unitTest;

            string channel = "my/channel";
            string message = messageForSecretEncryptPublish;

            pubnub.Publish <string>(channel, message, ReturnSuccessSecretEncryptPublishCodeCallback);
            mreSecretEncryptPublish.WaitOne(310 * 1000);

            if (!isSecretEncryptPublished)
            {
                UUnitAssert.True(isSecretEncryptPublished, "Secret Encrypt Publish Failed");
            }
            else
            {
                pubnub.DetailedHistory <string>(channel, -1, secretEncryptPublishTimetoken, -1, false, CaptureSecretEncryptDetailedHistoryCallback);
                mreSecretEncryptDetailedHistory.WaitOne(310 * 1000);
                UUnitAssert.True(isSecretEncryptDetailedHistory, "Unable to decrypt the successful Secret key Publish");
            }
        }
Esempio n. 9
0
        public void ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo()
        {
            Debug.Log("Running ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo()");
            isComplexObjectPublished = false;
            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenAMessageIsPublished";
            unitTest.TestCaseName  = "ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo";
            pubnub.PubnubUnitTest  = unitTest;

            string channel = "my/channel";
            object message = new PubnubDemoObject();

            messageComplexObjectForPublish = JsonConvert.SerializeObject(message);
            //Debug.Log("Serialized message in ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo() = " + messageComplexObjectForPublish);

            pubnub.Publish <string>(channel, message, ReturnSuccessComplexObjectPublishCodeCallback);
            mreComplexObjectPublish.WaitOne(310 * 1000);

            if (!isComplexObjectPublished)
            {
                UUnitAssert.True(isComplexObjectPublished, "Complex Object Publish Failed");
            }
            else
            {
                pubnub.DetailedHistory <string>(channel, -1, complexObjectPublishTimetoken, -1, false, CaptureComplexObjectDetailedHistoryCallback);
                mreComplexObjectDetailedHistory.WaitOne(310 * 1000);
                UUnitAssert.True(isComplexObjectDetailedHistory, "Unable to match the successful unencrypt object Publish");
            }
        }
        public void DetailedHistoryStartWithReverseTrue()
        {
            expectedCountAtStartTimeWithReverseTrue = 0;
            messageStartReverseTrue = false;
            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenDetailedHistoryIsRequested";
            unitTest.TestCaseName  = "DetailedHistoryStartWithReverseTrue";

            pubnub.PubnubUnitTest = unitTest;


            string channel = "my/channel";

            startTimeWithReverseTrue = Pubnub.TranslateDateTimeToPubnubUnixNanoSeconds(new DateTime(2012, 12, 1));
            for (int index = 0; index < 10; index++)
            {
                pubnub.Publish <string>(channel,
                                        string.Format("DetailedHistoryStartTimeWithReverseTrue {0}", index),
                                        DetailedHistorySamplePublishCallback);
                mrePublishStartReverseTrue.WaitOne();
            }

            Thread.Sleep(2000);

            pubnub.DetailedHistory <string>(channel, startTimeWithReverseTrue, DetailedHistoryStartWithReverseTrueCallback, true);
            Thread.Sleep(2000);
            mreMessageStartReverseTrue.WaitOne(310 * 1000);
            UUnitAssert.True(messageStartReverseTrue, "Detailed History with Start and Reverse True Failed");
        }
Esempio n. 11
0
        public void ThenPresenceShouldReturnReceivedMessage()
        {
            Debug.Log("Running ThenPresenceShouldReturnReceivedMessage()");
            receivedPresenceMessage = false;

            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenAClientIsPresented";
            unitTest.TestCaseName  = "ThenPresenceShouldReturnReceivedMessage";
            pubnub.PubnubUnitTest  = unitTest;

            string channel = "my/channel";

            pubnub.Presence <string>(channel, ThenPresenceShouldReturnMessage, PresenceDummyMethodForConnectCallback);
            Thread.Sleep(1000);

            //since presence expects from stimulus from sub/unsub...
            pubnub.Subscribe <string>(channel, DummyMethodForSubscribe, SubscribeDummyMethodForConnectCallback);
            Thread.Sleep(1000);
            subscribeManualEvent.WaitOne(2000);

            pubnub.Unsubscribe <string>(channel, DummyMethodForUnSubscribe, UnsubscribeDummyMethodForConnectCallback, UnsubscribeDummyMethodForDisconnectCallback);
            Thread.Sleep(1000);
            unsubscribeManualEvent.WaitOne(2000);

            presenceManualEvent.WaitOne(310 * 1000);

            pubnub.EndPendingRequests();

            UUnitAssert.True(receivedPresenceMessage, "Presence message not received");
        }
Esempio n. 12
0
        void JsonTimeStampHandlesAllFormats()
        {
            string       expectedJson, actualJson;
            DateTime     expectedTime;
            ObjWithTimes actualObj = new ObjWithTimes();

            for (int i = 0; i < _examples.Length; i++)
            {
                // Define the time deserialization expectation
                UUnitAssert.True(DateTime.TryParseExact(_examples[i], Util._defaultDateTimeFormats, CultureInfo.CurrentCulture, DateTimeStyles.RoundtripKind, out expectedTime), "Index: " + i + "/" + _examples.Length + ", " + _examples[i]);

                // De-serialize the time using json
                expectedJson = "{\"timestamp\":\"" + _examples[i] + "\"}"; // We are provided a json string with every random time format
                actualObj    = SimpleJson.DeserializeObject <ObjWithTimes>(expectedJson, Util.ApiSerializerStrategy);
                actualJson   = SimpleJson.SerializeObject(actualObj, Util.ApiSerializerStrategy);

                if (i == Util.DEFAULT_UTC_OUTPUT_INDEX) // This is the only case where the json input will match the json output
                {
                    UUnitAssert.StringEquals(expectedJson, actualJson);
                }

                // Verify that the times match
                double diff = (expectedTime - actualObj.timestamp).TotalSeconds; // We expect that we have parsed the time correctly according to expectations
                UUnitAssert.True(diff < 1,
                                 "\nActual time: " + actualObj.timestamp + " vs expected time: " + expectedTime + ", diff: " + diff +
                                 "\nActual json: " + actualJson + " vs expected json: " + expectedJson
                                 );
            }
        }
Esempio n. 13
0
        public void ThenPublishKeyShouldNotBeEmpty()
        {
            Debug.Log("Running ThenPublishKeyShouldNotBeEmpty()");
            bool isExpectedException = false;

            Pubnub pubnub = new Pubnub("", "demo", "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenAMessageIsPublished";
            unitTest.TestCaseName  = "ThenPublishKeyShouldNotBeEmpty";

            pubnub.PubnubUnitTest = unitTest;


            string channel = "hello_my_channel";
            string message = "Pubnub API Usage Example";

            try
            {
                pubnub.Publish <string>(channel, message, null, DummyErrorCallback);
            }
            catch (MissingFieldException)
            {
                isExpectedException = true;
            }
            catch (Exception)
            {
                isExpectedException = false;
            }

            UUnitAssert.True(isExpectedException);
        }
Esempio n. 14
0
        public void ThenUnencryptPublishShouldReturnSuccessCodeAndInfo()
        {
            Debug.Log("Running ThenUnencryptPublishShouldReturnSuccessCodeAndInfo()");
            isUnencryptPublished = false;
            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenAMessageIsPublished";
            unitTest.TestCaseName  = "ThenUnencryptPublishShouldReturnSuccessCodeAndInfo";
            pubnub.PubnubUnitTest  = unitTest;

            string channel = "hello_my_channel";
            string message = messageForUnencryptPublish;

            pubnub.Publish <string>(channel, message, ReturnSuccessUnencryptPublishCodeCallback, DummyErrorCallback);
            mreUnencryptedPublish.WaitOne(310 * 1000);
            Thread.Sleep(1000);

            if (!isUnencryptPublished)
            {
                UUnitAssert.True(isUnencryptPublished, "Unencrypt Publish Failed");
            }
            else
            {
                pubnub.DetailedHistory <string>(channel, -1, unEncryptPublishTimetoken, -1, false, CaptureUnencryptDetailedHistoryCallback, DummyErrorCallback);
                mreUnencryptDetailedHistory.WaitOne(310 * 1000);
                UUnitAssert.True(isUnencryptDetailedHistory, "Unable to match the successful unencrypt Publish");
            }
        }
Esempio n. 15
0
    public void TestRunning()
    {
        TestCaseDummy local = new TestCaseDummy("TestMethod");

        UUnitAssert.False(local.wasRun, " not wasRun");
        local.Run();
        UUnitAssert.True(local.wasRun, "wasRun");
    }
Esempio n. 16
0
    void TestSetUp()
    {
        TestCaseDummy local = new TestCaseDummy("TestMethod");

        local.Run();
        UUnitAssert.True(local.wasSetUp, "wasSetUp");
        UUnitAssert.Equals(local.log, "setUp ", "setup");
    }
Esempio n. 17
0
    public void OnDeathShouldFireAtZeroHealth()
    {
        bool fired = false;

        _enemyHealthManager.SetHealth(1);
        _enemyHealthManager.BindDeathEvent(delegate(){ fired = true; });
        _enemyHealthManager.TakeDamage(2);
        UUnitAssert.True(fired, "Death event should fire");
    }
Esempio n. 18
0
    void GetAllSceneTypeCallback(string res)
    {
        JsonData jd = JsonMapper.ToObject(res);

        UUnitAssert.True(jd.IsArray);
        SceneType sceneType = new SceneType((int)(jd[0][Param.TYPE_ID]), (string)(jd[0][Param.NAME]), (string)jd[Param.PICTURE_ID],
                                            StringUtil.StringToDateTime((string)(jd[0][Param.MODIFIED])));

        UUnitAssert.NotNull(sceneType);
    }
Esempio n. 19
0
        private void WaitForApiCalls()
        {
            DateTime expireTime = DateTime.UtcNow + TimeSpan.FromSeconds(3);

            while (PlayFabHTTP.GetPendingMessages() != 0 && DateTime.UtcNow < expireTime)
            {
                Thread.Sleep(1);               // Wait for the threaded call to be executed
                PlayFabHTTP.instance.Update(); // Invoke the callbacks for any threaded messages
            }
            UUnitAssert.True(DateTime.UtcNow < expireTime, "Request timed out");
        }
Esempio n. 20
0
        protected override void SetUp()
        {
            PlayFabSettings.TitleId = TITLE_ID;
            var task = PlayFabClientAPI.LoginWithCustomIDAsync(new LoginWithCustomIDRequest {
                CreateAccount = true, CustomId = TEST_CUSTOM_ID, TitleId = TITLE_ID
            });

            task.Wait();

            UUnitAssert.True(PlayFabClientAPI.IsClientLoggedIn(), "User login not successful: " + PlayFabUtil.GetErrorReport(task.Result.Error));
        }
    public void TestTurnOffFor2NeighborsWhenNotAlreadyOn()
    {
        Boolean turnOffCalled = false;

        CellLogic.TurnOff turnOff = (() => { turnOffCalled = true; });

        CellLogic underTest = new CellLogic(null, turnOff, false);

        underTest.checkForNeighbors(2);

        UUnitAssert.True(turnOffCalled);
    }
Esempio n. 22
0
    void GetScenesCallback(string res)
    {
        JsonData jd = JsonMapper.ToObject(res);

        UUnitAssert.True(jd.IsArray);
        Scene scene = new Scene((int)(jd[0][Param.SCENE_ID]), (string)(jd[0][Param.NAME]),
                                (int)(jd[0][Param.TYPE_ID]), (string)(jd[0][Param.PIC_URL]),
                                (string)(jd[0][Param.DETAILS]), StringUtil.StringToDateTime((string)(jd[0][Param.MODIFIED])),
                                (int)jd[Param.ASSET_ID], (string)jd[Param.PRODUCTS]);

        UUnitAssert.NotNull(scene);
    }
Esempio n. 23
0
        public void TestLegacySignature()
        {
#pragma warning disable 0618
            var expectedObj = new JsonTest {
                TestBool = true
            };
            var      actualJson = PlayFab.Json.JsonConvert.SerializeObject(expectedObj);
            JsonTest actualObj  = PlayFab.Json.JsonConvert.DeserializeObject <JsonTest>(actualJson);
            PlayFab.Json.JsonConvert.DeserializeObject(actualJson);
            UUnitAssert.True(actualObj.TestBool);
#pragma warning restore 0618
        }
    public void TestTurnOnForNeighboorsWhenAlreadyOn()
    {
        Boolean turnOnCalled = false;

        CellLogic.TurnOn turnOn = (() => { turnOnCalled = true; });

        CellLogic underTest = new CellLogic(turnOn, null, true);

        underTest.checkForNeighbors(2);

        UUnitAssert.True(turnOnCalled);
    }
Esempio n. 25
0
        public void ThenItShouldReturnTimeStamp()
        {
            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenGetRequestServerTime";
            unitTest.TestCaseName  = "ThenItShouldReturnTimeStamp";

            pubnub.PubnubUnitTest = unitTest;

            pubnub.Time <string>(ReturnTimeStampCallback);
            mreTime.WaitOne(310 * 1000);
            UUnitAssert.True(timeReceived, "time() Failed");
        }
        public void ThenNoExistChannelShouldReturnNotSubscribed()
        {
            Debug.Log("Running ThenNoExistChannelShouldReturnNotSubscribed()");
            receivedNotSubscribedMessage = false;
            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            string channel = "hello_my_channel";

            pubnub.Unsubscribe <string>(channel, DummyMethodNoExistChannelUnsubscribeChannelUserCallback, DummyMethodNoExistChannelUnsubscribeChannelConnectCallback, DummyMethodNoExistChannelUnsubscribeChannelDisconnectCallback1, DummyErrorCallback);

            meNotSubscribed.WaitOne();

            pubnub.EndPendingRequests();

            UUnitAssert.True(receivedNotSubscribedMessage, "WhenUnsubscribedToAChannel --> ThenNoExistChannelShouldReturnNotSubscribed Failed");
        }
Esempio n. 27
0
 public void TestStaticCallbacks_GeneralOnly()
 {
     EventStaticListener.Register();
     callbacks.Clear();
     PlayFabClientAPI.LoginWithCustomID(new LoginWithCustomIDRequest {
         CreateAccount = true, CustomId = "UnitySdk-UnitTest", TitleId = "6195"
     }, null, null);
     UUnitAssert.True(callbacks.Contains("OnRequest_StaticGl"), string.Join(", ", callbacks.ToArray()));
     UUnitAssert.True(callbacks.Contains("OnRequest_StaticLogin"), string.Join(", ", callbacks.ToArray()));
     UUnitAssert.IntEquals(2, callbacks.Count, string.Join(", ", callbacks.ToArray()));
     callbacks.Clear();
     WaitForApiCalls();
     UUnitAssert.True(callbacks.Contains("OnResponse_StaticGl"), string.Join(", ", callbacks.ToArray()));
     UUnitAssert.True(callbacks.Contains("OnResponse_StaticLogin"), string.Join(", ", callbacks.ToArray()));
     UUnitAssert.IntEquals(2, callbacks.Count, string.Join(", ", callbacks.ToArray()));
     EventStaticListener.Unregister();
 }
Esempio n. 28
0
    void GetProductCallback(string res)
    {
        JsonData jd = JsonMapper.ToObject(res);

        UUnitAssert.True(!jd.IsArray);
        Product product = new Product((int)(jd[Param.PRODUCT_ID]),
                                      (int)(jd[Param.PRODUCER_ID]),
                                      (string)(jd[Param.NAME]),
                                      (int)(jd[Param.CID]),
                                      (string)(jd[Param.SIZE]),
                                      (string)(jd[Param.PIC_URL]),
                                      (string)(jd[Param.DETAILS]),
                                      (int)jd[Param.ASSET_ID],
                                      StringUtil.StringToDateTime((string)(jd[Param.MODIFIED])));

        UUnitAssert.NotNull(product);
    }
Esempio n. 29
0
        public void IfHereNowIsCalledThenItShouldReturnInfo()
        {
            Debug.Log("Running IfHereNowIsCalledThenItShouldReturnInfo()");
            receivedHereNowMessage = false;

            Pubnub         pubnub   = new Pubnub("demo", "demo", "", "", false);
            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenAClientIsPresented";
            unitTest.TestCaseName  = "IfHereNowIsCalledThenItShouldReturnInfo";
            pubnub.PubnubUnitTest  = unitTest;
            string channel = "my/channel";

            pubnub.HereNow <string>(channel, ThenHereNowShouldReturnMessage);
            hereNowManualEvent.WaitOne();
            UUnitAssert.True(receivedHereNowMessage, "here_now message not received");
        }
Esempio n. 30
0
        public void DetailedHistoryStartWithReverseTrue()
        {
            Debug.Log("Running DetailedHistoryStartWithReverseTrue()");
            bool enableLocalStubTest = false;

            expectedCountAtStartTimeWithReverseTrue = 0;
            messageStartReverseTrue = false;
            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenDetailedHistoryIsRequested";
            unitTest.TestCaseName  = "DetailedHistoryStartWithReverseTrue";
            pubnub.PubnubUnitTest  = unitTest;
            if (pubnub.PubnubUnitTest is IPubnubUnitTest && pubnub.PubnubUnitTest.EnableStubTest)
            {
                enableLocalStubTest = true;
            }

            string channel = "hello_my_channel";

            if (enableLocalStubTest)
            {
                startTimeWithReverseTrue = Pubnub.TranslateDateTimeToPubnubUnixNanoSeconds(new DateTime(2012, 12, 1));
            }
            else
            {
                startTimeWithReverseTrue = Pubnub.TranslateDateTimeToPubnubUnixNanoSeconds(DateTime.UtcNow);
            }

            for (int index = 0; index < 10; index++)
            {
                pubnub.Publish <string>(channel,
                                        string.Format("DetailedHistoryStartTimeWithReverseTrue {0}", index),
                                        DetailedHistorySamplePublishCallback, DummyErrorCallback);
                mrePublishStartReverseTrue.WaitOne(310 * 1000);
            }

            Thread.Sleep(2000);

            pubnub.DetailedHistory <string>(channel, startTimeWithReverseTrue, DetailedHistoryStartWithReverseTrueCallback, DummyErrorCallback, true);
            Thread.Sleep(2000);
            mreMessageStartReverseTrue.WaitOne(310 * 1000);
            UUnitAssert.True(messageStartReverseTrue, "Detailed History with Start and Reverse True Failed");
        }