public void TestAddingParametersFromTestURL()
        {
            string           testCase           = "http://www.somesite.com/api/students/{id}/grades/?min={minValue}";
            Result           expected           = new Result();
            List <Parameter> expectedParameters = new List <Parameter>();

            expectedParameters.Add(new Parameter("id", new Path()));
            expectedParameters.Add(new Parameter("minValue", new QueryString()));
            expected.parameters = expectedParameters;

            APICompleter completer = new APICompleter();
            Result       result    = completer.CreateParameterFromString(testCase);

            List <int> expectedComparison = new List <int>();

            for (int i = 0; i < 2; i++)
            {
                expectedComparison.Add(0);
            }

            List <int> comparisonResults = new List <int>();

            comparisonResults.Add(expected.parameters[0].CompareTo(result.parameters[0]));
            comparisonResults.Add(expected.parameters[1].CompareTo(result.parameters[1]));

            CollectionAssert.AreEqual(expectedComparison, comparisonResults);
        }
        public void AddPathParameterAndQueryStringParameterToList()
        {
            string           testCase           = "{ID} ?Empty Space {Name}";
            Result           expected           = new Result();
            List <Parameter> expectedParameters = new List <Parameter>();

            expectedParameters.Add(new Parameter("ID", new Path()));
            expectedParameters.Add(new Parameter("Name", new QueryString()));
            expected.parameters = expectedParameters;

            APICompleter completer = new APICompleter();

            Result     result             = completer.CreateParameterFromString(testCase);
            List <int> expectedComparison = new List <int>();

            for (int i = 0; i < 2; i++)
            {
                expectedComparison.Add(0);
            }

            List <int> comparisonResults = new List <int>();

            comparisonResults.Add(expected.parameters[0].CompareTo(result.parameters[0]));
            comparisonResults.Add(expected.parameters[1].CompareTo(result.parameters[1]));
            CollectionAssert.AreEqual(expectedComparison, comparisonResults);
        }
        public void NullOrEmptyStringReturnsNull()
        {
            string testCase = "";
            Result expected = new Result();

            APICompleter completer = new APICompleter();

            Result result = completer.CreateParameterFromString(testCase);

            Assert.AreEqual(null, result);
        }
        public void NoParametersButStringHasTextReturnsEmptyList()
        {
            string           testCase           = "ID";
            Result           expected           = new Result();
            List <Parameter> expectedParameters = new List <Parameter>();

            expected.parameters = expectedParameters;

            APICompleter completer = new APICompleter();

            Result result = completer.CreateParameterFromString(testCase);

            CollectionAssert.AreEqual(expected.parameters, result.parameters);
        }
        public void AddQueryStringParameterToList()
        {
            string           testCase           = "?{ID}";
            Result           expected           = new Result();
            List <Parameter> expectedParameters = new List <Parameter>();

            expectedParameters.Add(new Parameter("ID", new QueryString()));
            expected.parameters = expectedParameters;

            APICompleter completer = new APICompleter();

            Result result = completer.CreateParameterFromString(testCase);

            Assert.AreEqual(0, expected.parameters[0].CompareTo(result.parameters[0]));
        }
        public void OnePathParameterInMiddleOfStringGetAddedToList()
        {
            string           testCase           = "Empty Space {ID} More Empty Space";
            Result           expected           = new Result();
            List <Parameter> expectedParameters = new List <Parameter>();

            expectedParameters.Add(new Parameter("ID", new Path()));
            expected.parameters = expectedParameters;

            APICompleter completer = new APICompleter();

            Result result = completer.CreateParameterFromString(testCase);

            Assert.AreEqual(0, expected.parameters[0].CompareTo(result.parameters[0]));
        }
        public void TwoPathParameterGetAddedToList()
        {
            string           testCase           = "{ID} Empty Space {Name}";
            Result           expected           = new Result();
            List <Parameter> expectedParameters = new List <Parameter>();

            expectedParameters.Add(new Parameter("ID", new Path()));
            expectedParameters.Add(new Parameter("Name", new Path()));
            expected.parameters = expectedParameters;

            APICompleter completer = new APICompleter();

            Result result = completer.CreateParameterFromString(testCase);

            Assert.AreEqual(0, expected.parameters[1].CompareTo(result.parameters[1]));
        }