public void BasicTest() { IRequest request = new ValidResponsesRequest(); string requestString = request.RequestString; string[] responses; // split the responses in the request into seperate strings responses = requestString.Split(null); Assert.IsTrue(responses.Length > 1); Assert.AreEqual(responses[0], "Valid-responses"); Assert.IsTrue(!request.IsResponseExpected); Assert.IsTrue(!request.DoesModifyConnection); }
public void AllResponsesSupportedTest() { IRequest request = new ValidResponsesRequest(); string requestString = request.RequestString; string[] responses; // Need to remove terminating '\n' to simplify Split() if (requestString.Length > 0 && requestString[requestString.Length - 1] == '\n') { requestString = requestString.Substring(0, requestString.Length - 1); } // split the responses in the request into seperate strings responses = requestString.Split(null); // Check that we really do support each of these responses for (int responseNum = 1; responseNum < responses.Length; responseNum++) { IResponse response = ResponseFactory.CreateResponse(responses[responseNum]); Assert.IsNotNull(response, responses[responseNum] + " not really supported"); } }
public void NoMissingResponsesTest() { IRequest request = new ValidResponsesRequest(); string requestString = request.RequestString; string[] responses; int responseClasses = 0; // Need to remove terminating '\n' to simplify Split() if (requestString.Length > 0 && requestString[requestString.Length - 1] == '\n') { requestString = requestString.Substring(0, requestString.Length - 1); } // split the responses in the request into seperate strings // remember first entry will be the response name responses = requestString.Split(null); Assembly cvsLibAssembly = Assembly.GetAssembly(request.GetType()); Assert.IsNotNull(cvsLibAssembly); Type[] types = cvsLibAssembly.GetTypes(); foreach (Type t in types) { // There are several ways of looking for the response classes. // The method chosen here is to look for all classes that // implement IResponse if (t.IsClass && t.GetInterface("IResponse") != null) { System.Console.WriteLine(t.Name); responseClasses++; } } Assert.AreEqual(responseClasses, responses.Length - 1, "Mismatch betwen response classes and the Valid-responses request"); }