Created
July 23, 2012 22:39
-
-
Save hyrmn/3166690 to your computer and use it in GitHub Desktop.
This file contains 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 Xunit; | |
using Shouldly; | |
namespace ConsoleApplication1 | |
{ | |
public enum Decision | |
{ | |
Simple, | |
SomeOther | |
} | |
public class Convertinator | |
{ | |
private Dictionary<Decision, Func<string, string>> Converters | |
{ | |
get | |
{ | |
return new Dictionary<Decision, Func<string, string>> | |
{ | |
{ Decision.Simple, (s) => { return s; } }, | |
{ Decision.SomeOther, (s) => { return s.ToUpper(); } } | |
}; | |
} | |
} | |
public string Convert(Decision decision, string theString) | |
{ | |
return Converters[decision](theString); | |
} | |
} | |
public class when_convertinating_strings | |
{ | |
private Convertinator sut = new Convertinator(); | |
[Fact] | |
public void Simple_decisions_dont_do_a_thing() | |
{ | |
sut.Convert(Decision.Simple, "test").ShouldBe("test", Case.Sensitive); | |
} | |
[Fact] | |
public void SomeOther_decisions_capitalize_the_heck_out_of_this_shit() | |
{ | |
sut.Convert(Decision.SomeOther, "test").ShouldBe("TEST", Case.Sensitive); | |
} | |
} | |
public class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var aConvertinator = new Convertinator(); | |
var result = aConvertinator.Convert(Decision.SomeOther, "come at me, bro"); | |
Console.WriteLine(result); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment