public void GivenStringWithAllTheParemetersAndDictionaryReturnResponseWithParametersAndWithCompletionStatus() { string testCase = "http://www.somesite.com/api/students/{id}/grades/?min={minValue}"; Dictionary <string, string> parameterValue = new Dictionary <string, string>(); parameterValue.Add("id", "1070890"); parameterValue.Add("minValue", "90"); 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.CompleteURL(testCase, parameterValue); List <int> expectedComparison = new List <int>(); for (int i = 0; i < 3; 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])); comparisonResults.Add(true.CompareTo(result.isComplete)); CollectionAssert.AreEqual(expectedComparison, comparisonResults); }
public void GivenStringWithOutAllTheParemetersAndDictionaryReturnResponseWithParametersAndWithCompletionStatusAndWithoutFinalURL() { string testCase = "http://www.somesite.com/api/students/{id}/grades/"; string completeURL = ""; Dictionary <string, string> parameterValue = new Dictionary <string, string>(); parameterValue.Add("id", "1070890"); parameterValue.Add("minValue", "90"); 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.CompleteURL(testCase, parameterValue); List <int> expectedComparison = new List <int>(); for (int i = 0; i < (expectedParameters.Count + 2); i++) { expectedComparison.Add(0); } List <int> comparisonResults = new List <int>(); for (int i = 0; i < expected.parameters.Count; i++) { comparisonResults.Add(expected.parameters[i].CompareTo(result.parameters[i])); } comparisonResults.Add(false.CompareTo(result.isComplete)); comparisonResults.Add(completeURL.CompareTo(result.completedURL)); CollectionAssert.AreEqual(expectedComparison, comparisonResults); }