protected static void FromJson(ILogger logger, JObject testCaseJson, TestCase testCase)
        {
            testCase._name        = JsonHelpers.GetString(testCaseJson, Constants.TCJsonName);
            testCase._description = JsonHelpers.GetString(testCaseJson, Constants.TCJsonDescription);

            if (!JsonHelpers.TryGetInt(testCaseJson, Constants.TCJsonReadBackPause, out testCase._readBackPause))
            {
                testCase._readBackPause = Constants.TCJsonReadBackPauseDefault;
            }
        }
Beispiel #2
0
        public static DirectMethodTestCase FromJson(ILogger logger, JObject testCaseJson)
        {
            DirectMethodTestCase testCase = new DirectMethodTestCase();

            TestCase.FromJson(logger, testCaseJson, testCase);

            testCase._methodName = JsonHelpers.GetString(testCaseJson, Constants.JsonDirectMethodName);

            // Input
            testCase._parameters = JsonHelpers.GetObject(testCaseJson, Constants.TCJsonInput);

            // Output
            JObject output = JsonHelpers.GetObject(testCaseJson, Constants.TCJsonOutput);

            // Output - DeviceTwin
            JObject deviceTwin = null;

            if (JsonHelpers.TryGetObject(output, Constants.TCJsonMethodDeviceTwin, out deviceTwin))
            {
                if (JsonHelpers.TryGetObject(output, Constants.TCJsonOutputPresent, out testCase._expectedPresentReportedState))
                {
                    testCase._expectedPresentReportedState = (JObject)testCase._expectedPresentReportedState.DeepClone();
                }

                if (JsonHelpers.TryGetObject(output, Constants.TCJsonOutputAbsent, out testCase._expectedAbsentReportedState))
                {
                    testCase._expectedAbsentReportedState = (JObject)testCase._expectedAbsentReportedState.DeepClone();
                }
            }

            // Output - Direct Method Return
            JsonHelpers.TryGetToken(output, Constants.TCJsonMethodReturnJson, out testCase._expectedReturnJson);
            JsonHelpers.TryGetLong(output, Constants.TCJsonMethodReturnCode, out testCase._expectedReturnCode);

            return(testCase);
        }