Last active
November 10, 2020 19:58
-
-
Save nelsonprsousa/3009c10393412c73e34ece970bdcedfa to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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