public void TestConnectionClientTermination() { var connStream = new ConnectionStream(); var producerStream = new ProducerStream(connStream); var consumerStream = new ConsumerStream(connStream); var t = new Task(() => { var streamWriter = new StreamWriter(producerStream); for (int i = 0; i < 1000; i++) { streamWriter.WriteLine("mother f*****g stream crap " + i); } streamWriter.Close(); }); t.Start(); // Thread.Sleep(1000); var sr = new StreamReader(consumerStream); sr.Close(); Task.WaitAll(t); }
public void TestConnectionStreamLotsOfDataAndCheckAllReads() { var connStream = new ConnectionStream(); var producerStream = new ProducerStream(connStream); var consumerStream = new ConsumerStream(connStream); var t = new Task(() => { var streamWriter = new StreamWriter(producerStream); for (int i = 0; i < 1000; i++) { streamWriter.WriteLine("mother f*****g stream crap " + i); } streamWriter.Close(); }); t.Start(); Thread.Sleep(1000); int j = 0; using (var sr = new StreamReader(consumerStream)) { var result = sr.ReadLine(); Assert.AreEqual(result, "mother f*****g stream crap " + j); j++; } Task.WaitAll(t); }
public void TestConnectionStreamBuffering() { var connStream = new ConnectionStream(); var producerStream = new ProducerStream(connStream); var consumerStream = new ConsumerStream(connStream); var t = new Task(() => { var streamWriter = new StreamWriter(producerStream); for (int i = 0; i < 1000; i++) { streamWriter.WriteLine("mother f*****g stream crap " + i); } streamWriter.Close(); }); t.Start(); Task.WaitAll(t); using (var sr = new StreamReader(consumerStream)) { // read one line var line = sr.ReadLine(); Assert.AreEqual("mother f*****g stream crap 0", line); } }
public void TestConnectionStreamLotsOfData() { var connStream = new ConnectionStream(); var producerStream = new ProducerStream(connStream); var consumerStream = new ConsumerStream(connStream); var t = new Task(() => { var streamWriter = new StreamWriter(producerStream); for (int i = 0; i < 1000; i++) { streamWriter.WriteLine("mother f*****g stream crap " + i); } streamWriter.Close(); }); t.Start(); Thread.Sleep(1000); var sr = new StreamReader(consumerStream); var result = sr.ReadToEnd(); Assert.IsTrue(result.StartsWith("mother f*****g stream crap 0")); Assert.IsTrue(result.EndsWith("mother f*****g stream crap 999\r\n")); Task.WaitAll(t); }
public void TestConnectionStream() { var connStream = new ConnectionStream(); var producerStream = new ProducerStream(connStream); var consumerStream = new ConsumerStream(connStream); var t = new Task(() => { var streamWriter = new StreamWriter(producerStream); streamWriter.WriteLine("mother f*****g stream crap"); streamWriter.Close(); }); t.Start(); var sr = new StreamReader(consumerStream); var result = sr.ReadToEnd(); Assert.AreEqual("mother f*****g stream crap\r\n", result); Task.WaitAll(t); }