public void TestReadBytes() { AuthRequest auth = new AuthRequest(_root); string s = auth.GetRequestString(); Console.WriteLine(s); _client.Connect(_root.Host, _root.Port); byte[] send = s.Encode(); _client.Write(send); // read auth response byte[] receive = _client.ReadBytes(11); string r = receive.Decode(); Console.Write(r); Console.WriteLine(); Assert.AreEqual("I LOVE YOU\n", r); ValidRequestsRequest request = new ValidRequestsRequest(); s = request.GetRequestString(); send = s.Encode(); _client.Write(send); r = _client.ReadLine(); Console.WriteLine(r); Assert.IsTrue(r.StartsWith("Valid-requests Root")); _client.Close(); }
public void TestTestCvsTcpClientCheckoutCommands() { AuthRequest auth = new AuthRequest(_root); string s = auth.GetRequestString(); Console.WriteLine(s); TcpClient client = new TcpClient(); client.Connect(_root.Host, _root.Port); // write auth string byte[] bbb = s.Encode(); NetworkStream stream = client.GetStream(); stream.Write(bbb, 0, bbb.Length); // read auth response byte[] rrr = new byte[1024]; stream.Read(rrr, 0, 1024); string s2 = rrr.Decode(); Console.Write(s2); Console.WriteLine(); // write valid responses string s = "Valid-responses ok error Valid-requests Checked-in New-entry Updated Created Merged Mod-time Removed Set-static-directory Clear-static-directory Set-sticky Clear-sticky Module-expansion M E MT" + _lineend; bbb = s.Encode(); stream.Write(bbb, 0, bbb.Length); stream.Flush(); // write valid requests s = "valid-requests" + _lineend; bbb = s.Encode(); stream.Write(bbb, 0, bbb.Length); stream.Flush(); // read valid requests rrr = new byte[1024]; stream.Read(rrr, 0, 1024); s = rrr.Decode(); Console.Write(s); Console.WriteLine(); // write unchanged s = "UseUnchanged" + _lineend; bbb = s.Encode(); stream.Write(bbb, 0, bbb.Length); stream.Flush(); // write root s = "Root /usr/local/cvsroot/sandbox" + _lineend; bbb = s.Encode(); stream.Write(bbb, 0, bbb.Length); stream.Flush(); // write global option s = "Global_option -q" + _lineend; bbb = s.Encode(); stream.Write(bbb, 0, bbb.Length); stream.Flush(); // write argument s = "Argument abougie" + _lineend; bbb = s.Encode(); stream.Write(bbb, 0, bbb.Length); stream.Flush(); // write directory s = "Directory ." + _lineend + "/usr/local/cvsroot/sandbox" + _lineend; bbb = s.Encode(); stream.Write(bbb, 0, bbb.Length); stream.Flush(); // expand mods s = "expand-modules" + _lineend; bbb = s.Encode(); stream.Write(bbb, 0, bbb.Length); stream.Flush(); // get expand mods response rrr = new byte[1024]; stream.Read(rrr, 0, 1024); s = rrr.Decode(); Console.Write(s); Console.WriteLine(); // arg command s = "Argument -N" + _lineend; bbb = s.Encode(); stream.Write(bbb, 0, bbb.Length); stream.Flush(); s = "Argument abougie" + _lineend; bbb = s.Encode(); stream.Write(bbb, 0, bbb.Length); stream.Flush(); s = "Directory ." + _lineend + "/usr/local/cvsroot/sandbox" + _lineend; bbb = s.Encode(); stream.Write(bbb, 0, bbb.Length); stream.Flush(); s = "co" + _lineend; bbb = s.Encode(); stream.Write(bbb, 0, bbb.Length); stream.Flush(); // read checkout response rrr = new byte[1024]; stream.Read(rrr, 0, 1024); s = rrr.Decode(); Console.Write(s); Console.WriteLine(); client.Close(); }
public void TestRTagCvsTcpClientCommand() { AuthRequest auth = new AuthRequest(_root); string send = auth.GetRequestString(); Console.WriteLine(send); TcpClient client = new TcpClient(); client.Connect(_root.Host, _root.Port); // write auth string byte[] sendBytes = send.Encode(); NetworkStream stream = client.GetStream(); stream.Write(sendBytes, 0, sendBytes.Length); // read auth response byte[] receiveBytes = new byte[1024]; stream.Read(receiveBytes, 0, 1024); string receive = receiveBytes.Decode(); Console.Write(receive); Console.WriteLine(); // write valid responses string send = "Valid-responses ok error Valid-requests Checked-in New-entry Updated Created Merged Mod-time Removed Set-static-directory Clear-static-directory Set-sticky Clear-sticky Module-expansion M E MT\n"; sendBytes = send.Encode(); stream.Write(sendBytes, 0, sendBytes.Length); stream.Flush(); // write valid requests send = "valid-requests\n"; sendBytes = send.Encode(); stream.Write(sendBytes, 0, sendBytes.Length); stream.Flush(); // read valid requests receiveBytes = new byte[1024]; stream.Read(receiveBytes, 0, 1024); receive = receiveBytes.Decode(); Console.Write(receive); Console.WriteLine(); // write unchanged send = "UseUnchanged\n"; Console.WriteLine(send); sendBytes = send.Encode(); stream.Write(sendBytes, 0, sendBytes.Length); stream.Flush(); // write root send = "Root /usr/local/cvsroot/sandbox\n"; Console.WriteLine(send); sendBytes = send.Encode(); stream.Write(sendBytes, 0, sendBytes.Length); stream.Flush(); // write global option send = "Global_option -q\n"; Console.WriteLine(send); sendBytes = send.Encode(); stream.Write(sendBytes, 0, sendBytes.Length); stream.Flush(); // tag send = "Argument v1_3\n"; Console.WriteLine(send); sendBytes = send.Encode(); stream.Write(sendBytes, 0, sendBytes.Length); stream.Flush(); // write argument send = "Argument abougie/cvstest\n"; Console.WriteLine(send); sendBytes = send.Encode(); stream.Write(sendBytes, 0, sendBytes.Length); stream.Flush(); send = "rtag\n"; Console.WriteLine(send); sendBytes = send.Encode(); stream.Write(sendBytes, 0, sendBytes.Length); stream.Flush(); // read checkout response receiveBytes = new byte[1024]; stream.Read(receiveBytes, 0, 1024); receive = receiveBytes.Decode(); Console.Write(receive); Console.WriteLine(); client.Close(); }