Skip to content

Instantly share code, notes, and snippets.

@nelsonprsousa
Last active November 10, 2020 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nelsonprsousa/3009c10393412c73e34ece970bdcedfa to your computer and use it in GitHub Desktop.
Save nelsonprsousa/3009c10393412c73e34ece970bdcedfa to your computer and use it in GitHub Desktop.
namespace XUnitTestProject
{
using Xunit;
public static class SwitchStatementMapper
{
// Don't judge me, it's only for educational purposes :)
public static bool Map(string str) => str switch
{
"true" => true,
_ => false,
};
}
public class SwitchStatementMapperTests
{
[Theory]
[InlineData("true", true)]
[InlineData("false", false)]
[InlineData("dummy", false)]
public void Map_ReturnsCorrectBool(string str, bool expectedValue)
{
// Act
var result = SwitchStatementMapper.Map(str);
Assert.Equal(expectedValue, result);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment