FluentAssertions를 사용하여 대소 문자를 구분하지 않고 쉽게 비교할 수있는 방법은 무엇입니까? 같은FluentAssertions를 사용하여 대소 문자를 구분하지 않는 문자열을 비교하는 방법은 무엇입니까? C#
뭔가 :
symbol.Should().Be(expectedSymbol, StringComparison.InvariantCultureIgnoreCase);
편집 : 가능한 중복 코드에 대해서 : 그것은 CurrentCulture를 사용하여 비교한다 symbol.Should().BeEquivalentTo(expectedSymbol);
. 그리고 그것은 터키 문화와 같은 상황에서 브레이크가 걸릴 것입니다. Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR", false); string upper = "in".ToUpper(); // upper == "İN" "in".Should().BeEquivalentTo("In"); // It will fail
그래서 일부 "StringComparison.InvariantCultureIgnoreCase는"여기서 중요한 곳이다.
비교할 문자열에'.ToLower()'를 호출하면 어떨까요? – Glubus
@Glubus가 더 좋은 방법을 찾고 있습니다. 'ToLower()'를 사용할 때 실패하면 FluentAssertions는 변경된 값을 소트합니다 (소문자). –