Skip to content

Instantly share code, notes, and snippets.

@jcbozonier
Created July 10, 2009 21:08
Show Gist options
  • Save jcbozonier/144816 to your computer and use it in GitHub Desktop.
Save jcbozonier/144816 to your computer and use it in GitHub Desktop.
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