Created
March 27, 2013 14:34
-
-
Save FernandoVezzali/5254626 to your computer and use it in GitHub Desktop.
MemoryStream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static byte[] Foo() | |
{ | |
using (var memStream = new MemoryStream()) | |
using (var streamWriter = new StreamWriter(memStream)) | |
{ | |
for (int i = 0; i < 6; i++) | |
streamWriter.WriteLine("TEST"); | |
streamWriter.Flush(); | |
return memStream.ToArray(); | |
} | |
} | |
[Test] | |
public void TestStreamRowCount() | |
{ | |
var bytes = Foo(); | |
using (var stream = new MemoryStream(bytes)) | |
using (var reader = new StreamReader(stream)) | |
{ | |
var collection = new List<string>(); | |
string input; | |
while ((input = reader.ReadLine()) != null) | |
collection.Add(input); | |
Assert.AreEqual(6, collection.Count); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment