Skip to content

Instantly share code, notes, and snippets.

@richlander
Forked from nelsonprsousa/SwitchStatementMapper.cs
Last active November 10, 2020 20:08
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 richlander/e7d0b062a655d086acf90f9d74c918c5 to your computer and use it in GitHub Desktop.
Save richlander/e7d0b062a655d086acf90f9d74c918c5 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