public void StringIsWrittenWithLengthPrefix()
 {
     var testSocket = new TestSocket();
     var socketStream = new SocketStream(testSocket);
     socketStream.Write("h\u2019llo", "{0}:");
     Assert.AreEqual(new byte[] {55, 58, 104, 226, 128, 153, 108, 108, 111}, testSocket.GetBytes());
 }
 public void SimpleStringIsWritten()
 {
     var testSocket = new TestSocket();
     var socketStream = new SocketStream(testSocket);
     socketStream.Write("hello");
     Assert.AreEqual(new byte[] {104, 101, 108, 108, 111}, testSocket.GetBytes());
 }
 public void SimpleStringIsRead()
 {
     var testSocket = new TestSocket();
     var socketStream = new SocketStream(testSocket);
     testSocket.PutBytes(new byte[] {104, 101, 108, 108, 111});
     Assert.AreEqual("hello", socketStream.ReadBytes(5));
 }
 public void EncodedStringIsRead()
 {
     var testSocket = new TestSocket();
     var socketStream = new SocketStream(testSocket);
     testSocket.PutBytes(new byte[] {104, 226, 128, 153, 108, 108, 111});
     Assert.AreEqual("h\u2019llo", socketStream.ReadBytes(7));
 }
 public void StringIsReadInMultipleParts()
 {
     var testSocket = new TestSocket();
     var socketStream = new SocketStream(testSocket);
     testSocket.PutBytes(new byte[] {104, 101, 108, 108, 111});
     testSocket.PutBytes(new byte[] {32, 119,111,114,108,100});
     Assert.AreEqual("hello world", socketStream.ReadBytes(11));
 }
Beispiel #6
0
 private void RunTest(CellProcessor service, string tables)
 {
     var socket = new TestSocket();
     socket.PutByteString(Protocol.FormatInteger(tables.Length));
     socket.PutByteString(tables);
     socket.PutByteString(Protocol.FormatInteger(0));
     var server = new SocketServer(new FitSocket(socket, new NullReporter()), service, new NullReporter(), false);
     server.ProcessTestDocuments(new StoryTestStringWriter(service).ForTables(s => resultTables += s));
 }
 public void ParseExceptionIsRecorded()
 {
     var service = new Service.Service();
     const string tables = "<table>garbage</table>";
     var socket = new TestSocket();
     socket.PutByteString("0000000022");
     socket.PutByteString(tables);
     socket.PutByteString("0000000000");
     var server = new SocketServer(new FitSocket(socket, new NullReporter()), service, new NullReporter(), false);
     server.ProcessTestDocuments(new StoryTestStringWriter(service).ForTables(s => resultTables += s));
     Assert.IsTrue(resultTables.Contains("class=\"error\""), resultTables);
     Assert.IsTrue(resultTables.Contains("Unable to parse input. Input ignored."), resultTables);
 }
 public void StoryTestIsExecuted()
 {
     var service = new Service.Service();
     service.AddNamespace("fitlibrary");
     service.ApplicationUnderTest.AddAssembly("fit.dll");
     const string tables = "<table><tr><td>do</td></tr></table><table><tr><td>do</td></tr></table>";
     var socket = new TestSocket();
     socket.PutByteString("0000000070");
     socket.PutByteString(tables);
     socket.PutByteString("0000000000");
     var server = new SocketServer(new FitSocket(socket, new NullReporter()), service, new NullReporter(), false);
     server.ProcessTestDocuments(new StoryTestStringWriter(service).ForTables(s => resultTables += s));
     Assert.AreEqual(tables, resultTables);
 }