Exemplo n.º 1
0
        public async Task TestObjectHash()
        {
            //given
            await FHClient.Init();

            var testObject = new JObject();

            testObject["testKey"]     = "Test Data";
            testObject["testBoolKey"] = true;
            testObject["testNumKey"]  = 10;
            var arr = new JArray {
                "obj1", "obj2"
            };

            testObject["testArrayKey"] = arr;
            var obj = new JObject();

            obj["obj3key"]            = "obj3";
            obj["obj4key"]            = "obj4";
            testObject["testDictKey"] = obj;

            //when
            var hash = FHSyncUtils.GenerateSHA1Hash(testObject);

            //then
            Assert.AreEqual("5f4675723d658919ede35fac62fade8c6397df1d", hash);
        }
Exemplo n.º 2
0
        public void TestGenerateHashWithUnderscoreInKey()
        {
            // given
            var data = new JObject();

            data["COMMENTS"]    = "";
            data["FHID"]        = "2553C7ED-9025-48F9-A346-EBE3E3AF943B";
            data["QUESTION_ID"] = 22;
            data["QUES_VALUE"]  = "NO";
            data["VISIT_ID"]    = 100220;
            data["TEST1_ttt"]   = "test";
            data["TEST11_ttt"]  = "test2";

            // when
            var hash = FHSyncUtils.GenerateSHA1Hash(data);

            // then
            Assert.AreEqual("824d6ded431d16fe8f2ab02b0744ca06822a3fff", hash, "Hashvalue generated by dotnet SDK doesn't match JS SDK");
        }
Exemplo n.º 3
0
        public async Task TestGenerateHashWithUnderscoreInKey()
        {
            // given
            await FHClient.Init();

            var data = new JObject();

            data["COMMENTS"]    = "";
            data["FHID"]        = "2553C7ED-9025-48F9-A346-EBE3E3AF943B";
            data["QUESTION_ID"] = 22;
            data["QUES_VALUE"]  = "NO";
            data["VISIT_ID"]    = 100220;
            data["TEST1_ttt"]   = "test";
            data["TEST11_ttt"]  = "test2";

            // when
            var hash = FHSyncUtils.GenerateSHA1Hash(data);

            // then
            Assert.AreEqual("824d6ded431d16fe8f2ab02b0744ca06822a3fff", hash);
        }
Exemplo n.º 4
0
        public void TestObjectHash()
        {
            var testObject = new JObject();

            testObject["testKey"]     = "Test Data";
            testObject["testBoolKey"] = true;
            testObject["testNumKey"]  = 10;
            var arr = new JArray();

            arr.Add("obj1");
            arr.Add("obj2");
            testObject["testArrayKey"] = arr;
            var obj = new JObject();

            obj["obj3key"]            = "obj3";
            obj["obj4key"]            = "obj4";
            testObject["testDictKey"] = obj;
            var hash = FHSyncUtils.GenerateSHA1Hash(testObject);

            Debug.WriteLine("Got hash value = {0}", hash);
            var expected = "5f4675723d658919ede35fac62fade8c6397df1d";

            Assert.IsTrue(expected.Equals(hash));
        }