changeset 33:f876a4e8eb1b

* Add basic tests for new stream handling utilities no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Sun, 06 Mar 2011 14:51:25 +0000
parents 4d9c0cc7c4a3
children de7c3ee39362
files IBBoard.Tests.csproj IO/StreamUtilTests.cs
diffstat 2 files changed, 40 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -72,6 +72,7 @@
     <Compile Include="Limits\CompositeMaximumLimitTest.cs" />
     <Compile Include="ArraysTests.cs" />
     <Compile Include="EqualityCheckerTests.cs" />
+    <Compile Include="IO\StreamUtilTests.cs" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="System" />
@@ -127,7 +128,7 @@
       <Properties>
         <Policies>
           <DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="FileFormatDefault" />
-          <StandardHeader Text=" This file (${FileName}) is a part of the ${ProjectName} project and is copyright ${Year} ${CopyrightHolder}&#xA;&#xA; 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." inheritsSet="Apache2License" />
+          <StandardHeader Text=" This file (${FileName}) is a part of the ${ProjectName} project and is copyright ${Year} ${CopyrightHolder}&#xA;&#xA; 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." IncludeInNewFiles="True" />
         </Policies>
       </Properties>
     </MonoDevelop>
@@ -163,4 +164,7 @@
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
   </ItemGroup>
+  <ItemGroup>
+    <Folder Include="IO\" />
+  </ItemGroup>
 </Project>
\ No newline at end of file
--- /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));
+		}
+	}
+}