Start to write StringExtensions methods
authorMichael Welch <michaelgwelch@gmail.com>
Wed, 14 Mar 2012 21:36:15 +0000 (16:36 -0500)
committerMichael Welch <michaelgwelch@gmail.com>
Wed, 14 Mar 2012 21:36:15 +0000 (16:36 -0500)
csharp/BrainmessShort/BrainmessShort.csproj
csharp/BrainmessShort/StringExtensionsTests.cs [new file with mode: 0644]

index 7907c46..14d0bea 100644 (file)
@@ -63,6 +63,7 @@
     <Compile Include="Main.cs" />
     <Compile Include="MainTest.cs" />
     <Compile Include="StringExtensions.cs" />
+    <Compile Include="StringExtensionsTests.cs" />
   </ItemGroup>
   <ItemGroup>
     <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
diff --git a/csharp/BrainmessShort/StringExtensionsTests.cs b/csharp/BrainmessShort/StringExtensionsTests.cs
new file mode 100644 (file)
index 0000000..8464f5c
--- /dev/null
@@ -0,0 +1,51 @@
+\feffusing NUnit.Framework;
+
+namespace BrainmessShort
+{
+    [TestFixture]
+    public class StringExtensionsTests
+    {
+        [Test]
+        public void FindMatch_WithSmallestValidStringStartingWithLeftBracket()
+        {
+            // Arrange
+            const string program = "[]";
+
+            // Act
+            var actual = program.FindMatch(0);
+
+            // Assert
+            const int expected = 1;
+            Assert.AreEqual(expected, actual);
+        }
+
+        [Test]
+        public void FindMatch_WithSmallestValidStringStartingWithRightBracket()
+        {
+            // Arrange
+            const string program = "[]";
+
+            // Act
+            var actual = program.FindMatch(1);
+
+            // Assert
+            const int expected = 0;
+            Assert.AreEqual(expected, actual);
+        }
+
+        [Test]
+        public void FindMatch_WithSinglePairOfBracketsInAStringStartingWithLeftBracket()
+        {
+            // Arrange
+            //                      012345678901234 
+            const string program = "++++[>>>>>>]...";
+
+            // Act
+            var actual = program.FindMatch(4);
+
+            // Assert
+            const int expected = 11;
+            Assert.AreEqual(expected, actual);
+        }
+    }
+}