Skip to content

Instantly share code, notes, and snippets.

@JamesBender
Created September 19, 2013 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesBender/6629375 to your computer and use it in GitHub Desktop.
Save JamesBender/6629375 to your computer and use it in GitHub Desktop.
using System;
using System.Linq;
using NUnit.Framework;
namespace ThirtyDaysOfTDD.UnitTests
{
[TestFixture]
public class StringUtilsTest
{
[Test]
public void ShouldBeAbleToCountNumberOfLettersInSimpleSentence()
{
var sentenceToScan = "TDD is awesome!";
var characterToScanFor = "e";
var expectedResult = 2;
var stringUtils = new StringUtils();
int result = stringUtils.FindNumberOfOccurences(sentenceToScan, characterToScanFor);
Assert.AreEqual(expectedResult, result);
}
[Test]
public void ShouldBeAbleToCountNumberOfLettersInAComplexSentence()
{
var sentenceToScan = "Once is unique, twice is a coincidence, three times is a pattern.";
var characterToScanFor = "n";
var expectedResult = 5;
var stringUtils = new StringUtils();
int result = stringUtils.FindNumberOfOccurences(sentenceToScan, characterToScanFor);
Assert.AreEqual(expectedResult, result);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment