# HG changeset patch # User IBBoard # Date 1299423085 0 # Node ID f876a4e8eb1bbd492fd306decd21f3390abea6b8 # Parent 4d9c0cc7c4a3a8719e8030cbb16af988cbd6b42f * Add basic tests for new stream handling utilities no-open-ticket diff -r 4d9c0cc7c4a3 -r f876a4e8eb1b IBBoard.Tests.csproj --- a/IBBoard.Tests.csproj Wed Jan 26 20:23:19 2011 +0000 +++ b/IBBoard.Tests.csproj Sun Mar 06 14:51:25 2011 +0000 @@ -1,5 +1,5 @@ - - + + Debug AnyCPU @@ -72,6 +72,7 @@ + @@ -127,7 +128,7 @@ - + @@ -163,4 +164,7 @@ PreserveNewest + + + \ No newline at end of file diff -r 4d9c0cc7c4a3 -r f876a4e8eb1b IO/StreamUtilTests.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IO/StreamUtilTests.cs Sun Mar 06 14:51:25 2011 +0000 @@ -0,0 +1,33 @@ +// This file (StreamUtilTests.cs) is a part of the IBBoard.Tests project and is copyright 2011 IBBoard +// +// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU LGPL, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. +using System; +using NUnit.Framework; +using System.IO; +using NUnit.Framework.SyntaxHelpers; + +namespace IBBoard.IO +{ + [TestFixture()] + public class StreamUtilTests + { + [Test()] + public void TestCopyStream() + { + byte[] data = new byte[]{1, 2, 3, 4, 5, 6}; + MemoryStream fromStream = new MemoryStream(data); + MemoryStream toStream = new MemoryStream(); + StreamUtil.CopyStream(fromStream, toStream); + Assert.That(toStream.ToArray(), Is.EqualTo(data)); + } + + [Test()] + public void TestToBytesMethod() + { + byte[] data = new byte[]{1, 2, 3, 4, 5, 6}; + MemoryStream fromStream = new MemoryStream(data); + byte[] bytes = StreamUtil.ToBytes(fromStream); + Assert.That(bytes, Is.EqualTo(data)); + } + } +}