From: <dr...@us...> - 2003-11-05 08:33:56
|
Update of /cvsroot/sharpcvslib/sharpcvslib/src/ICSharpCode.Tests/SharpCvsLib/Requests In directory sc8-pr-cvs1:/tmp/cvs-serv24683/src/ICSharpCode.Tests/SharpCvsLib/Requests Modified Files: OtherRequestsTest.cs ValidResponsesRequestTest.cs Log Message: Code reformat. Index: OtherRequestsTest.cs =================================================================== RCS file: /cvsroot/sharpcvslib/sharpcvslib/src/ICSharpCode.Tests/SharpCvsLib/Requests/OtherRequestsTest.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OtherRequestsTest.cs 10 Oct 2003 14:07:30 -0000 1.1 --- OtherRequestsTest.cs 5 Nov 2003 08:07:36 -0000 1.2 *************** *** 44,538 **** namespace ICSharpCode.SharpCvsLib.Requests { /// <summary> ! /// Test any remaining Requests that do not have their own test fixture. ! /// ! /// Many of the requests are so trivial, it seems madness to add ! /// add a test class for each file. ! /// ! /// cvsclient.info from the 1.11.6 release of cvs (http://ccvs.cvshome.org) ! /// was used as the basis for these tests. [...961 lines suppressed...] + private void MyAssertStringEquals(string requestString, string command, string data) + { + string expectedRequest = String.Format("{0} {1}\n", command, data); + + Assertion.AssertEquals(requestString, expectedRequest); + } + + /// <summary> + /// This asserts that the request string has a command of the given value, + /// and a single argument of value + /// Trailing whitespace is ignored. + /// </summary> + private void MyAssertStringEquals(string requestString, string command, string data, string nextLine) + { + string expectedRequest = String.Format("{0} {1}\n{2}\n", command, data, nextLine); + + Assertion.AssertEquals(requestString, expectedRequest); + } + } } Index: ValidResponsesRequestTest.cs =================================================================== RCS file: /cvsroot/sharpcvslib/sharpcvslib/src/ICSharpCode.Tests/SharpCvsLib/Requests/ValidResponsesRequestTest.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ValidResponsesRequestTest.cs 17 Oct 2003 01:14:08 -0000 1.2 --- ValidResponsesRequestTest.cs 5 Nov 2003 08:07:36 -0000 1.3 *************** *** 45,146 **** namespace ICSharpCode.SharpCvsLib.Requests { /// <summary> ! /// Test ValidResponsesRequest ! /// ! /// cvsclient.info from the 1.11.6 release of cvs (http://ccvs.cvshome.org) ! /// was used as the basis for these tests. /// </summary> ! [TestFixture] ! public class ValidResponsesRequestTest { ! private static readonly ILog LOGGER = ! LogManager.GetLogger (typeof (ValidResponsesRequestTest)); ! ! /// <summary> ! /// Just tests the request name and virtual boolean values. ! /// </summary> ! [Test] ! 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); ! ! Assertion.Assert(responses.Length > 1); ! Assertion.AssertEquals(responses[0], "Valid-responses"); ! ! Assertion.Assert(!request.IsResponseExpected); ! Assertion.Assert(!request.DoesModifyConnection); ! } ! ! /// <summary> ! /// Tests that the responses that we say we support ! /// in this message really are supported. ! /// ! /// We determine if a message is supported or not ! /// by whether the ResponseFactory can create the response class or not. ! /// ! /// TODO: Check if there are any responses that we want to tell the server ! /// that we support, but can safely ignore if the server actually ! /// sends them to us. ! /// </summary> ! [Test] ! public void AllResponsesSupportedTest() ! { ! IRequest request = new ValidResponsesRequest(); ! string requestString = request.RequestString; ! string[] responses; ! ! // 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]); ! Assertion.AssertNotNull(responses[responseNum] + " not really supported", response); ! } } ! ! /// <summary> ! /// The idea here is to check that when a new response class is written ! /// it is also added into the Valid-responses request. ! /// ! /// We can easily look in the assembly to find the response classes ! /// but what we can't do is from this class fins its corresponding ! /// request string as this is hard coded in the factory. ! /// ! /// So instead we just check that the counts match. ! /// </summary> ! [Test] ! public void NoMissingResponsesTest() ! { ! IRequest request = new ValidResponsesRequest(); ! string requestString = request.RequestString; ! string[] responses; ! int responseClasses = 0; ! ! // 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()); ! Assertion.AssertNotNull("Can't load sharpcvslib assembly", 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++; ! } } - - Assertion.AssertEquals("Mismatch betwen response classes and the Valid-responses request", - responseClasses, responses.Length - 1); } } } --- 45,146 ---- namespace ICSharpCode.SharpCvsLib.Requests { + /// <summary> + /// Test ValidResponsesRequest + /// + /// cvsclient.info from the 1.11.6 release of cvs (http://ccvs.cvshome.org) + /// was used as the basis for these tests. + /// </summary> + [TestFixture] + public class ValidResponsesRequestTest { + private static readonly ILog LOGGER = + LogManager.GetLogger (typeof (ValidResponsesRequestTest)); + /// <summary> ! /// Just tests the request name and virtual boolean values. /// </summary> ! [Test] ! 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); ! ! Assertion.Assert(responses.Length > 1); ! Assertion.AssertEquals(responses[0], "Valid-responses"); ! ! Assertion.Assert(!request.IsResponseExpected); ! Assertion.Assert(!request.DoesModifyConnection); ! } ! ! /// <summary> ! /// Tests that the responses that we say we support ! /// in this message really are supported. ! /// ! /// We determine if a message is supported or not ! /// by whether the ResponseFactory can create the response class or not. ! /// ! /// TODO: Check if there are any responses that we want to tell the server ! /// that we support, but can safely ignore if the server actually ! /// sends them to us. ! /// </summary> ! [Test] ! public void AllResponsesSupportedTest() ! { ! IRequest request = new ValidResponsesRequest(); ! string requestString = request.RequestString; ! string[] responses; ! ! // 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]); ! Assertion.AssertNotNull(responses[responseNum] + " not really supported", response); } ! } ! ! /// <summary> ! /// The idea here is to check that when a new response class is written ! /// it is also added into the Valid-responses request. ! /// ! /// We can easily look in the assembly to find the response classes ! /// but what we can't do is from this class fins its corresponding ! /// request string as this is hard coded in the factory. ! /// ! /// So instead we just check that the counts match. ! /// </summary> ! [Test] ! public void NoMissingResponsesTest() ! { ! IRequest request = new ValidResponsesRequest(); ! string requestString = request.RequestString; ! string[] responses; ! int responseClasses = 0; ! ! // 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()); ! Assertion.AssertNotNull("Can't load sharpcvslib assembly", 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++; } } + + Assertion.AssertEquals("Mismatch betwen response classes and the Valid-responses request", + responseClasses, responses.Length - 1); } + } } |