Convert sln and csproj to 2010
authorMichael Welch <michaelgwelch@gmail.com>
Wed, 14 Mar 2012 19:33:13 +0000 (14:33 -0500)
committerMichael Welch <michaelgwelch@gmail.com>
Wed, 14 Mar 2012 19:38:39 +0000 (14:38 -0500)
Add automated tests

csharp/BrainmessShort/BrainmessShort.csproj
csharp/BrainmessShort/BrainmessShort.sln
csharp/BrainmessShort/MainTest.cs [new file with mode: 0644]

index 56d608a..35b74b6 100644 (file)
@@ -1,5 +1,5 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+\feff<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
     <RootNamespace>BrainmessShort</RootNamespace>
     <AssemblyName>BrainmessShort</AssemblyName>
     <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+    <FileUpgradeFlags>
+    </FileUpgradeFlags>
+    <UpgradeBackupLocation>
+    </UpgradeBackupLocation>
+    <OldToolsVersion>3.5</OldToolsVersion>
+    <PublishUrl>publish\</PublishUrl>
+    <Install>true</Install>
+    <InstallFrom>Disk</InstallFrom>
+    <UpdateEnabled>false</UpdateEnabled>
+    <UpdateMode>Foreground</UpdateMode>
+    <UpdateInterval>7</UpdateInterval>
+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+    <UpdatePeriodically>false</UpdatePeriodically>
+    <UpdateRequired>false</UpdateRequired>
+    <MapFileExtensions>true</MapFileExtensions>
+    <ApplicationRevision>0</ApplicationRevision>
+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
+    <UseApplicationTrust>false</UseApplicationTrust>
+    <BootstrapperEnabled>true</BootstrapperEnabled>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
     <DebugSymbols>true</DebugSymbols>
@@ -22,6 +42,7 @@
     <PlatformTarget>x86</PlatformTarget>
     <Externalconsole>true</Externalconsole>
     <Commandlineparameters>../../../../scripts/hello.bm</Commandlineparameters>
+    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
     <DebugType>none</DebugType>
     <WarningLevel>4</WarningLevel>
     <PlatformTarget>x86</PlatformTarget>
     <Externalconsole>true</Externalconsole>
+    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="nunit.framework, Version=2.5.7.10213, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
     <Reference Include="System" />
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Main.cs" />
+    <Compile Include="MainTest.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
+      <Visible>False</Visible>
+      <ProductName>Windows Installer 3.1</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
 </Project>
\ No newline at end of file
index 635921e..716fa0b 100644 (file)
@@ -1,6 +1,6 @@
 \feff\r
-Microsoft Visual Studio Solution File, Format Version 10.00\r
-# Visual Studio 2008\r
+Microsoft Visual Studio Solution File, Format Version 11.00\r
+# Visual Studio 2010\r
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BrainmessShort", "BrainmessShort.csproj", "{D1C9257C-3C4A-4091-8CA6-38803D0D1679}"\r
 EndProject\r
 Global\r
@@ -14,6 +14,9 @@ Global
                {D1C9257C-3C4A-4091-8CA6-38803D0D1679}.Release|x86.ActiveCfg = Release|x86\r
                {D1C9257C-3C4A-4091-8CA6-38803D0D1679}.Release|x86.Build.0 = Release|x86\r
        EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
        GlobalSection(MonoDevelopProperties) = preSolution\r
                StartupItem = BrainmessShort.csproj\r
        EndGlobalSection\r
diff --git a/csharp/BrainmessShort/MainTest.cs b/csharp/BrainmessShort/MainTest.cs
new file mode 100644 (file)
index 0000000..1d0eef5
--- /dev/null
@@ -0,0 +1,70 @@
+\feffusing System;
+using System.IO;
+using System.Text;
+using NUnit.Framework;
+
+namespace BrainmessShort
+{
+    [TestFixture]
+    public class MainTest
+    {
+        [Test]
+        public void RunHelloWorld()
+        {
+            var builder = RedirectOutput();
+            Brainmess.Main(new[] {"../../../../scripts/hello.bm"});
+            Assert.AreEqual("Hello World!", builder.ToString());
+        }
+
+        [Test]
+        public void RunDoubleWith2Expect4()
+        {
+            var builder = RedirectOutput();
+            SetInput("2");
+            Brainmess.Main(new[] { "../../../../scripts/double.bm" });
+            Assert.AreEqual("4", builder.ToString());
+        }
+
+        [Test]
+        public void RunDoubleWith0Expect0()
+        {
+            var builder = RedirectOutput();
+            SetInput("0");
+            Brainmess.Main(new[] { "../../../../scripts/double.bm" });
+            Assert.AreEqual("0", builder.ToString());
+        }
+
+        [Test]
+        public void RunFibonacci()
+        {
+            var builder = RedirectOutput();
+            Brainmess.Main(new[] {"../../../../scripts/fibonacci.bm"});
+            Assert.AreEqual("1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89", builder.ToString());
+        }
+
+        /// <summary>
+        /// Redirects standard output to a StringBuilder and returns
+        /// that StringBuilder.
+        /// </summary>
+        /// <returns></returns>
+        private static StringBuilder RedirectOutput()
+        {
+            StringBuilder builder = new StringBuilder();
+            TextWriter writer = new StringWriter(builder);
+            Console.SetOut(writer);
+            return builder;
+        }
+
+        /// <summary>
+        /// Creates a text reader that is initialized with 
+        /// <paramref name="input"/>. Then sets standard input to read
+        /// from that reader.
+        /// </summary>
+        /// <param name="input"></param>
+        private static void SetInput(string input)
+        {
+            TextReader reader = new StringReader(input);
+            Console.SetIn(reader);
+        }
+    }
+}