Created
July 10, 2009 21:08
-
-
Save jcbozonier/144816 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using Machine.Specifications; | |
using NUnit.Framework.SyntaxHelpers; | |
namespace StringManipulationTests | |
{ | |
[Subject("String Manipulation")] | |
public class when_parsing_a_list_of_strings_using_ForEach : StringManipulation | |
{ | |
Establish context = | |
() => | |
{ | |
TestList = TestString.Split(',').ToList(); | |
}; | |
Because of = () => TestList.ForEach(x => x = x.Trim('\'')); | |
It should_remove_single_quotes = | |
() => TestList.ForEach(x => x.ShouldNotContain('\'')); | |
} | |
[Subject("String Manipulation")] | |
public class when_parsing_a_list_of_strings_using_Select : StringManipulation | |
{ | |
Because of = () => TestList = TestString.Split(',') | |
.Select(s => s.Trim('\'')).ToList(); | |
It should_remove_single_quotes = | |
() => TestList.ForEach(x => x.ShouldNotContain('\'')); | |
} | |
public class StringManipulation | |
{ | |
public static String TestString = "'foo','bar','baz'"; | |
public static List<String> TestList; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment