Forked from nelsonprsousa/SwitchStatementMapper.cs
Last active
November 10, 2020 20:08
-
-
Save richlander/e7d0b062a655d086acf90f9d74c918c5 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