Exemplo n.º 1
0
        public void TestMyObjectEncryption()
        {
            Debug.Log("Running TestMyObjectEncryption()");
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //create an object of the custom class
            CustomClass cc = new CustomClass();
            //serialize it
            string result = new JsonFXDotNet().SerializeToJsonString(cc);  //JsonConvert.SerializeObject(cc);
            //encrypt it
            string encryptedMessage = pc.Encrypt(result);

            UUnitAssert.Equals("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=", encryptedMessage);
        }
Exemplo n.º 2
0
        public void TestPubNubDecryption2()
        {
            Debug.Log("Running TestPubNubDecryption2()");
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //Deserialized string
            string message = "f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=";
            //Decrypt
            string decryptedMessage = pc.Decrypt(message);

            //Deserialize
            message = new JsonFXDotNet().DeserializeToObject(decryptedMessage) as string; //JsonConvert.DeserializeObject<string>(decryptedMessage);
            UUnitAssert.Equals("Pubnub Messaging API 2", message);
        }
Exemplo n.º 3
0
        public void TestPubNubEncryption1()
        {
            Debug.Log("Running TestPubNubEncryption1()");
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //non serialized string
            string message = "Pubnub Messaging API 1";

            //serialize
            message = JsonConvert.SerializeObject(message);
            //encrypt
            string encryptedMessage = pc.Encrypt(message);

            UUnitAssert.Equals("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=", encryptedMessage);
        }
Exemplo n.º 4
0
        public void TestObjectEncryption()
        {
            Debug.Log("Running TestObjectEncryption()");
            PubnubCrypto pc = new PubnubCrypto("enigma");

            //create an object
            System.Object obj = new System.Object();
            //serialize
            string serializedObject = JsonConvert.SerializeObject(obj);
            //encrypt
            string encryptedMessage = pc.Encrypt(serializedObject);

            UUnitAssert.Equals("IDjZE9BHSjcX67RddfCYYg==", encryptedMessage);
        }
Exemplo n.º 5
0
        public void TestGermanCharsDecryption()
        {
            Debug.Log("Running TestGermanCharsDecryption()");
            PubnubCrypto pc      = new PubnubCrypto("enigma");
            string       message = "stpgsG1DZZxb44J7mFNSzg==";

            //decrypt
            string decryptedMessage = pc.Decrypt(message);

            //deserialize
            message = (decryptedMessage != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject <string>(decryptedMessage) : "";

            UUnitAssert.Equals("ÜÖ", message);
        }
Exemplo n.º 6
0
        public void TestArrayEncryption()
        {
            Debug.Log("Running TestArrayEncryption()");
            PubnubCrypto pc = new PubnubCrypto("enigma");

            //create an empty array object
            object[] emptyArray = { };
            //serialize
            string serializedArray = JsonConvert.SerializeObject(emptyArray);
            //Encrypt
            string encryptedMessage = pc.Encrypt(serializedArray);

            UUnitAssert.Equals("Ns4TB41JjT2NCXaGLWSPAQ==", encryptedMessage);
        }
Exemplo n.º 7
0
        public void TestUnicodeCharsDecryption()
        {
            Debug.Log("Running TestUnicodeCharsDecryption()");
            PubnubCrypto pc      = new PubnubCrypto("enigma");
            string       message = "+BY5/miAA8aeuhVl4d13Kg==";
            //decrypt
            string decryptedMessage = pc.Decrypt(message);

            //deserialize
            //message = (decryptedMessage != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(decryptedMessage) : "";
            message = (decryptedMessage != "**DECRYPT ERROR**") ? (string)(new JsonFXDotNet().DeserializeToObject(decryptedMessage)) : "";

            UUnitAssert.Equals("漢語", message);
        }
Exemplo n.º 8
0
        public void TestPubNubEncryption2()
        {
            Debug.Log("Running TestPubNubEncryption2()");
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //Deserialized
            string message = "Pubnub Messaging API 2";

            //serialize the message
            message = JsonConvert.SerializeObject(message);
            //encrypt
            string encryptedMessage = pc.Encrypt(message);

            UUnitAssert.Equals("f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=", encryptedMessage);
        }
Exemplo n.º 9
0
        public void TestPubNubDecryption1()
        {
            Debug.Log("Running TestPubNubDecryption1()");
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //deserialized string
            string message = "f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=";
            //decrypt
            string decryptedMessage = pc.Decrypt(message);

            //deserialize
            //message = (decryptedMessage != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(decryptedMessage) : "";
            message = (decryptedMessage != "**DECRYPT ERROR**") ? (string)(new JsonFXDotNet().DeserializeToObject(decryptedMessage)) : "";
            UUnitAssert.Equals("Pubnub Messaging API 1", message);
        }
Exemplo n.º 10
0
        public void TestYayEncryption()
        {
            Debug.Log("Running TestYayEncryption()");
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //deserialized string
            string message = "yay!";

            //serialize the string
            message = JsonConvert.SerializeObject(message);
            Console.WriteLine(message);
            //Encrypt
            string enc = pc.Encrypt(message);

            UUnitAssert.Equals("Wi24KS4pcTzvyuGOHubiXg==", enc);
        }
Exemplo n.º 11
0
        public void TestMyObjectDecryption()
        {
            Debug.Log("Running TestMyObjectDecryption()");
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //Deserialized
            string message = "Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=";
            //Decrypt
            string decryptedMessage = pc.Decrypt(message);
            //create an object of the custom class
            CustomClass cc = new CustomClass();
            //Serialize it
            string result = JsonConvert.SerializeObject(cc);

            UUnitAssert.Equals(result, decryptedMessage);
        }
Exemplo n.º 12
0
        public void TestArrayDecryption()
        {
            Debug.Log("Running TestArrayDecryption()");
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //Input the deserialized string
            string message = "Ns4TB41JjT2NCXaGLWSPAQ==";
            //decrypt
            string decryptedMessage = pc.Decrypt(message);

            //create a serialized object
            object[] emptyArrayObject = { };
            string   result           = JsonConvert.SerializeObject(emptyArrayObject);

            //compare the serialized object and the return of the Decrypt method
            UUnitAssert.Equals(result, decryptedMessage);
        }
Exemplo n.º 13
0
    public void lerpHalfwayToPlane()
    {
        Debug.Log(" === lerp 1/2 way to plane test === ");

        // test point
        Vector3 p = new Vector3(0, 10, 0);

        // test mesh is plane at z = 0
        GameObject pl = GameObject.CreatePrimitive(PrimitiveType.Plane);
        MeshFilter mf = pl.GetComponent <MeshFilter>();

        Vector3 expected = new Vector3(0, 5, 0);
        Vector3 result   = lerpNearestOnMesh.lerpNearest(p, mf, 0.5f);

        UUnitAssert.Equals(expected, result);
    }
Exemplo n.º 14
0
        public void TestObjectDecryption()
        {
            Debug.Log("Running TestObjectDecryption()");
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //Deserialized
            string message = "IDjZE9BHSjcX67RddfCYYg==";
            //Decrypt
            string decryptedMessage = pc.Decrypt(message);

            //create an object
            System.Object obj = new System.Object();
            //Serialize the object
            string result = JsonConvert.SerializeObject(obj);

            UUnitAssert.Equals(result, decryptedMessage);
        }
Exemplo n.º 15
0
        public void TestYayDecryption()
        {
            Debug.Log("Running TestYayDecryption()");
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //string strMessage= "\"q/xJqqN6qbiZMXYmiQC1Fw==\"";
            //Non deserialized string
            string message = "\"Wi24KS4pcTzvyuGOHubiXg==\"";

            //Deserialize
            message = JsonConvert.DeserializeObject <string>(message);
            //decrypt
            string decryptedMessage = pc.Decrypt(message);

            //deserialize again
            message = JsonConvert.DeserializeObject <string>(decryptedMessage);
            UUnitAssert.Equals("yay!", message);
        }
Exemplo n.º 16
0
    public void nearestPointOnPrimitivePlane_is_projectedVertex()
    {
        Debug.Log(" === known PrimitiveType.Plane-projected vertex test === ");

        // test point @ origin
        Vector3 p = new Vector3(1, 1, 1);

        // test mesh is 1x1 plane at z = 1
        //GameObject pl = new GameObject("testPlane");
        GameObject pl = GameObject.CreatePrimitive(PrimitiveType.Plane);
        MeshFilter mf = pl.GetComponent <MeshFilter>();

        Vector3 projection = new Vector3(1, 0, 1);
        Vector3 result     = NearestPointOnMesh.getNearestPointOnMesh(p, mf);

        UUnitAssert.Equals(projection, result);
    }
Exemplo n.º 17
0
    public void shouldCalculateNumberOfNeighborsOnForWeirdCase()
    {
        FieldLogic underTest = new FieldLogic(3, 3);

        underTest.AddCellAt(new CellLogic(null, null, cellOn), 0, 0);
        underTest.AddCellAt(new CellLogic(null, null, cellOn), 0, 1);
        underTest.AddCellAt(new CellLogic(null, null, cellOn), 0, 2);
        underTest.AddCellAt(new CellLogic(null, null, cellOn), 1, 0);
        underTest.AddCellAt(new CellLogic(null, null, cellOn), 1, 1);
        underTest.AddCellAt(new CellLogic(null, null, cellOn), 1, 2);
        underTest.AddCellAt(new CellLogic(null, null, cellOn), 2, 0);
        underTest.AddCellAt(new CellLogic(null, null, cellOff), 2, 1);
        underTest.AddCellAt(new CellLogic(null, null, cellOn), 2, 2);

        int neighbors = underTest.NeighborsOnAt(1, 1);

        UUnitAssert.Equals(7, neighbors);
    }
Exemplo n.º 18
0
    public void shouldCallAllCells()
    {
        FieldLogic underTest          = new FieldLogic(3, 3);
        int        timesTurnOffCalled = 0;

        CellLogic.TurnOff testTurnOff = () => { timesTurnOffCalled++; };
        underTest.AddCellAt(new CellLogic(emptyTurnOn, testTurnOff, cellOn), 0, 0);
        underTest.AddCellAt(new CellLogic(emptyTurnOn, testTurnOff, cellOff), 0, 1);
        underTest.AddCellAt(new CellLogic(emptyTurnOn, testTurnOff, cellOn), 0, 2);
        underTest.AddCellAt(new CellLogic(emptyTurnOn, testTurnOff, cellOff), 1, 0);
        underTest.AddCellAt(new CellLogic(emptyTurnOn, testTurnOff, cellOff), 1, 1);
        underTest.AddCellAt(new CellLogic(emptyTurnOn, testTurnOff, cellOff), 1, 2);
        underTest.AddCellAt(new CellLogic(emptyTurnOn, testTurnOff, cellOn), 2, 0);
        underTest.AddCellAt(new CellLogic(emptyTurnOn, testTurnOff, cellOff), 2, 1);
        underTest.AddCellAt(new CellLogic(emptyTurnOn, testTurnOff, cellOn), 2, 2);

        underTest.Iterate();

        UUnitAssert.Equals(9, timesTurnOffCalled);
    }
Exemplo n.º 19
0
        void EnumConversionTest()
        {
            string expectedJson, actualJson;
            EnumConversionTestClass expectedObj = new EnumConversionTestClass(), actualObj = new EnumConversionTestClass();

            expectedObj.enumList = new List <testRegion>()
            {
                testRegion.USEast, testRegion.USCentral, testRegion.Japan
            };
            expectedObj.enumArray = new testRegion[] { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumValue = testRegion.Australia;

            expectedJson = "{\"enumList\":[\"USEast\",\"USCentral\",\"Japan\"],\"enumArray\":[\"USEast\",\"USCentral\",\"Japan\"],\"enumValue\":\"Australia\"}";

            JsonConvert.PopulateObject(expectedJson, actualObj, Util.JsonSettings);
            actualJson = JsonConvert.SerializeObject(actualObj, Util.JsonFormatting, Util.JsonSettings);

            UUnitAssert.Equals(expectedJson.Replace(" ", "").Replace("\n", ""), actualJson.Replace(" ", "").Replace("\n", ""));
            UUnitAssert.ObjEquals(expectedObj, actualObj);
        }
Exemplo n.º 20
0
    public void nearestPointOnScaledCube_is_scaled()
    {
        // ensures that a point at 1,0,0 moves to a point at .5,0,0 if cube at origin w/ scale .5,.5,.5
        Debug.Log(" === scaled cube test === ");


        Vector3 p = new Vector3(1, 2, 2);

        GameObject cu = GameObject.CreatePrimitive(PrimitiveType.Cube);

        cu.transform.localScale = new Vector3(0.5f, 2f, 2f);
        MeshFilter mf = cu.GetComponent <MeshFilter>();

        Vector3 expected = new Vector3(.5f, 2f, 2f);
        Vector3 result   = NearestPointOnMesh.getNearestPointOnMesh(p, mf);

        Debug.Log(expected.ToString() + "=?=" + result.ToString());

        UUnitAssert.Equals(expected, result);
    }
Exemplo n.º 21
0
    public void nearestPointOnPlane_is_projectedVertex_if_pointBetweenPlaneAndOrigin()
    {
        Debug.Log(" === known plane-projected vertex test for point(0,0,10) === ");

        // test point @ origin
        Vector3 p = new Vector3(0, 0, 5);

        // test mesh is 1x1 plane at z = 1
        GameObject plane = new GameObject("testPlane");
        MeshFilter mf    = (MeshFilter)plane.AddComponent(typeof(MeshFilter));

        Vector3[] pl = new Vector3[] { new Vector3(10, 10, 10),
                                       new Vector3(10, -10, 10),
                                       new Vector3(-10, 10, 10),
                                       new Vector3(-10, -10, 10) };

        mf.mesh = CreateMesh(pl);

        Vector3 projection = new Vector3(0, 0, 10);
        Vector3 result     = NearestPointOnMesh.getNearestPointOnMesh(p, mf);

        UUnitAssert.Equals(projection, result);
    }
Exemplo n.º 22
0
 public void HealthShouldNotGoBelowZero()
 {
     _playerHealthManager.SetHealth(1);
     _playerHealthManager.TakeDamage(2);
     UUnitAssert.Equals(_playerHealthManager.GetHealth(), 0, "Health should not go below zero");
 }
Exemplo n.º 23
0
 public void NoteMissShouldBreakCombo()
 {
     _scoreController.NoteHit(1);
     _scoreController.NoteMissed();
     UUnitAssert.Equals(_comboManager.GetCombo(), 0, "Combo not broken after miss");
 }