Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hyrmn
Created July 23, 2012 22:39
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 hyrmn/3166690 to your computer and use it in GitHub Desktop.
Save hyrmn/3166690 to your computer and use it in GitHub Desktop.
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