Ejemplo n.º 1
0
        public void FailureSamplesTest(string template, string[] results, TestSet.TestCase testCase)
        {
            var uriTemplate = new UriTemplate(template);

            foreach (var variable in testCase.TestSet.Variables)
            {
                uriTemplate.SetParameter(variable.Key, variable.Value);
            }

            string            result = null;
            ArgumentException aex    = null;

            try
            {
                result = uriTemplate.Resolve();
            }
            catch (ArgumentException ex)
            {
                aex = ex;
            }

            if (results[0] == "False")
            {
                Assert.NotNull(aex);
            }
            else
            {
                Assert.Contains(results, x => x == result);
            }
        }
Ejemplo n.º 2
0
        public void SpecSamplesTest(string template, string[] results, TestSet.TestCase testCase)
        {
            var uriTemplate = new UriTemplate(template);

            foreach (var variable in testCase.TestSet.Variables)
            {
                uriTemplate.SetParameter(variable.Key, variable.Value);
            }

            string result = null;

            result = uriTemplate.Resolve();

            Assert.Contains(results, x => x == result);
        }
Ejemplo n.º 3
0
        private static TestSet.TestCase CreateTestCase(TestSet testSet, JToken testcase)
        {
            var testCase = new TestSet.TestCase(testSet);

            testCase.Template = testcase[0].Value <string>();

            if (testcase[1].Type == JTokenType.Array)
            {
                var results = (JArray)testcase[1];
                testCase.Result = results.Select(jv => jv.Value <string>()).ToArray();
            }
            else
            {
                testCase.Result    = new string[1];
                testCase.Result[0] = testcase[1].Value <string>();
            }
            return(testCase);
        }
Ejemplo n.º 4
0
        private static TestSet.TestCase CreateTestCase(TestSet testSet, JToken testcase)
        {
            var testCase = new TestSet.TestCase(testSet);

            testCase.Template = testcase[0].Value<string>();

            if (testcase[1].Type == JTokenType.Array)
            {
                var results = (JArray)testcase[1];
                testCase.Result = results.Select(jv => jv.Value<string>()).ToArray();
            }
            else
            {
                testCase.Result = new string[1];
                testCase.Result[0] = testcase[1].Value<string>();
            }
            return testCase;
        }