Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 32 additions & 11 deletions src/TestFramework/TestFramework/Assertions/Assert.AreSame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,13 @@ internal void ComputeAssertion(string expectedExpression, string actualExpressio
public readonly struct AssertAreNotSameInterpolatedStringHandler<TArgument>
{
private readonly StringBuilder? _builder;
private readonly TArgument? _notExpected;
private readonly TArgument? _actual;

public AssertAreNotSameInterpolatedStringHandler(int literalLength, int formattedCount, TArgument? notExpected, TArgument? actual, out bool shouldAppend)
{
_notExpected = notExpected;
_actual = actual;
shouldAppend = IsAreNotSameFailing(notExpected, actual);
if (shouldAppend)
{
Expand All @@ -95,7 +99,7 @@ internal void ComputeAssertion(string notExpectedExpression, string actualExpres
if (_builder is not null)
{
_builder.Insert(0, string.Format(CultureInfo.CurrentCulture, FrameworkMessages.CallerArgumentExpressionTwoParametersMessage, "notExpected", notExpectedExpression, "actual", actualExpression) + " ");
ThrowAssertAreNotSameFailed(_builder.ToString());
ThrowAssertAreNotSameFailed(_notExpected, _actual, _builder.ToString());
}
}

Expand Down Expand Up @@ -187,14 +191,22 @@ private static bool IsAreSameFailing<T>(T? expected, T? actual)
[DoesNotReturn]
private static void ThrowAssertAreSameFailed<T>(T? expected, T? actual, string userMessage)
{
string finalMessage = userMessage;
if (expected is ValueType && actual is ValueType)
{
finalMessage = string.Format(
string finalMessage = expected is null
? string.Format(
CultureInfo.CurrentCulture,
FrameworkMessages.AreSameGivenValues,
userMessage);
}
FrameworkMessages.AreSameExpectedIsNull,
userMessage)
: actual is null
? string.Format(
CultureInfo.CurrentCulture,
FrameworkMessages.AreSameActualIsNull,
userMessage)
: expected is ValueType && actual is ValueType
? string.Format(
CultureInfo.CurrentCulture,
FrameworkMessages.AreSameGivenValues,
userMessage)
: userMessage;

ThrowAssertFailed("Assert.AreSame", finalMessage);
}
Expand Down Expand Up @@ -240,14 +252,23 @@ public static void AreNotSame<T>(T? notExpected, T? actual, string? message = ""
{
if (IsAreNotSameFailing(notExpected, actual))
{
ThrowAssertAreNotSameFailed(BuildUserMessageForNotExpectedExpressionAndActualExpression(message, notExpectedExpression, actualExpression));
ThrowAssertAreNotSameFailed(notExpected, actual, BuildUserMessageForNotExpectedExpressionAndActualExpression(message, notExpectedExpression, actualExpression));
}
}

private static bool IsAreNotSameFailing<T>(T? notExpected, T? actual)
=> object.ReferenceEquals(notExpected, actual);

[DoesNotReturn]
private static void ThrowAssertAreNotSameFailed(string userMessage)
=> ThrowAssertFailed("Assert.AreNotSame", userMessage);
private static void ThrowAssertAreNotSameFailed<T>(T? notExpected, T? actual, string userMessage)
{
string finalMessage = notExpected is null && actual is null
? string.Format(
CultureInfo.CurrentCulture,
FrameworkMessages.AreNotSameBothNull,
userMessage)
: userMessage;

ThrowAssertFailed("Assert.AreNotSame", finalMessage);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,18 @@
<data name="AreNotEqualDeltaFailMsg" xml:space="preserve">
<value>Expected a difference greater than &lt;{3}&gt; between expected value &lt;{1}&gt; and actual value &lt;{2}&gt;. {0}</value>
</data>
<data name="AreSameExpectedIsNull" xml:space="preserve">
<value>Expected is &lt;null&gt;. {0}</value>
</data>
<data name="AreSameActualIsNull" xml:space="preserve">
<value>Actual is &lt;null&gt;. {0}</value>
</data>
<data name="AreSameGivenValues" xml:space="preserve">
<value>Do not pass value types to AreSame(). Values converted to Object will never be the same. Consider using AreEqual(). {0}</value>
</data>
<data name="AreNotSameBothNull" xml:space="preserve">
<value>Both values are &lt;null&gt;. {0}</value>
</data>
<data name="BothCollectionsEmpty" xml:space="preserve">
<value>Both collections are empty. {0}</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@
<target state="translated">Očekáván rozdíl, který je větší jak &lt;{3}&gt; mezi očekávanou hodnotou &lt;{1}&gt; a aktuální hodnotou &lt;{2}&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotSameBothNull">
<source>Both values are &lt;null&gt;. {0}</source>
<target state="new">Both values are &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameActualIsNull">
<source>Actual is &lt;null&gt;. {0}</source>
<target state="new">Actual is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameExpectedIsNull">
<source>Expected is &lt;null&gt;. {0}</source>
<target state="new">Expected is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameGivenValues">
<source>Do not pass value types to AreSame(). Values converted to Object will never be the same. Consider using AreEqual(). {0}</source>
<target state="translated">Nevkládejte hodnotu typů do AreSame(). Hodnoty převedené do typu Object už nebudou nikdy stejné. Zvažte použití AreEqual(). {0}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@
<target state="translated">Es wurde eine Differenz größer als &lt;{3}&gt; zwischen dem erwarteten Wert &lt;{1}&gt; und dem tatsächlichen Wert &lt;{2}&gt; erwartet. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotSameBothNull">
<source>Both values are &lt;null&gt;. {0}</source>
<target state="new">Both values are &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameActualIsNull">
<source>Actual is &lt;null&gt;. {0}</source>
<target state="new">Actual is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameExpectedIsNull">
<source>Expected is &lt;null&gt;. {0}</source>
<target state="new">Expected is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameGivenValues">
<source>Do not pass value types to AreSame(). Values converted to Object will never be the same. Consider using AreEqual(). {0}</source>
<target state="translated">Übergeben Sie keine Werttypen an AreSame(). In ein Objekt konvertierte Werte sind niemals identisch. Verwenden Sie stattdessen AreEqual(). {0}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@
<target state="translated">Se esperaba una diferencia mayor que &lt;{3}&gt; entre el valor esperado &lt;{1}&gt; y el valor actual &lt;{2}&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotSameBothNull">
<source>Both values are &lt;null&gt;. {0}</source>
<target state="new">Both values are &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameActualIsNull">
<source>Actual is &lt;null&gt;. {0}</source>
<target state="new">Actual is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameExpectedIsNull">
<source>Expected is &lt;null&gt;. {0}</source>
<target state="new">Expected is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameGivenValues">
<source>Do not pass value types to AreSame(). Values converted to Object will never be the same. Consider using AreEqual(). {0}</source>
<target state="translated">No pase tipos de valor a AreSame(). Los valores convertidos a Object no serán nunca iguales. Considere el uso de AreEqual(). {0}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@
<target state="translated">Différence attendue supérieure à &lt;{3}&gt; comprise entre la valeur attendue &lt;{1}&gt; et la valeur réelle &lt;{2}&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotSameBothNull">
<source>Both values are &lt;null&gt;. {0}</source>
<target state="new">Both values are &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameActualIsNull">
<source>Actual is &lt;null&gt;. {0}</source>
<target state="new">Actual is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameExpectedIsNull">
<source>Expected is &lt;null&gt;. {0}</source>
<target state="new">Expected is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameGivenValues">
<source>Do not pass value types to AreSame(). Values converted to Object will never be the same. Consider using AreEqual(). {0}</source>
<target state="translated">Ne passez pas de types valeur à AreSame(). Les valeurs converties en Object ne seront plus jamais les mêmes. Si possible, utilisez AreEqual(). {0}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@
<target state="translated">Prevista una differenza maggiore di &lt;{3}&gt; tra il valore previsto &lt;{1}&gt; e il valore effettivo &lt;{2}&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotSameBothNull">
<source>Both values are &lt;null&gt;. {0}</source>
<target state="new">Both values are &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameActualIsNull">
<source>Actual is &lt;null&gt;. {0}</source>
<target state="new">Actual is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameExpectedIsNull">
<source>Expected is &lt;null&gt;. {0}</source>
<target state="new">Expected is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameGivenValues">
<source>Do not pass value types to AreSame(). Values converted to Object will never be the same. Consider using AreEqual(). {0}</source>
<target state="translated">Non passare tipi valore a AreSame(). I valori convertiti in Object non saranno mai uguali. Usare AreEqual(). {0}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@
<target state="translated">指定する値 &lt;{1}&gt; と実際の値 &lt;{2}&gt; との間には、&lt;{3}&gt; を超える差が必要です。{0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotSameBothNull">
<source>Both values are &lt;null&gt;. {0}</source>
<target state="new">Both values are &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameActualIsNull">
<source>Actual is &lt;null&gt;. {0}</source>
<target state="new">Actual is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameExpectedIsNull">
<source>Expected is &lt;null&gt;. {0}</source>
<target state="new">Expected is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameGivenValues">
<source>Do not pass value types to AreSame(). Values converted to Object will never be the same. Consider using AreEqual(). {0}</source>
<target state="translated">AreSame() には値型を渡すことはできません。オブジェクトに変換された値が同じにはなりません。AreEqual() を使用することを検討してください。{0}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@
<target state="translated">예상 값 &lt;{1}&gt;과(와) 실제 값 &lt;{2}&gt;의 차이가 &lt;{3}&gt;보다 커야 합니다. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotSameBothNull">
<source>Both values are &lt;null&gt;. {0}</source>
<target state="new">Both values are &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameActualIsNull">
<source>Actual is &lt;null&gt;. {0}</source>
<target state="new">Actual is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameExpectedIsNull">
<source>Expected is &lt;null&gt;. {0}</source>
<target state="new">Expected is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameGivenValues">
<source>Do not pass value types to AreSame(). Values converted to Object will never be the same. Consider using AreEqual(). {0}</source>
<target state="translated">AreSame()에 값 형식을 전달하면 안 됩니다. Object로 변환된 값은 동일한 값으로 간주되지 않습니다. AreEqual()을 사용해 보세요. {0}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@
<target state="translated">Oczekiwano różnicy większej niż &lt;{3}&gt; pomiędzy oczekiwaną wartością &lt;{1}&gt; a rzeczywistą wartością &lt;{2}&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotSameBothNull">
<source>Both values are &lt;null&gt;. {0}</source>
<target state="new">Both values are &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameActualIsNull">
<source>Actual is &lt;null&gt;. {0}</source>
<target state="new">Actual is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameExpectedIsNull">
<source>Expected is &lt;null&gt;. {0}</source>
<target state="new">Expected is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameGivenValues">
<source>Do not pass value types to AreSame(). Values converted to Object will never be the same. Consider using AreEqual(). {0}</source>
<target state="translated">Nie przekazuj typów wartości do metody AreSame(). Wartości przekonwertowane na typ Object nigdy nie będą takie same. Rozważ użycie metody AreEqual(). {0}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@
<target state="translated">Esperada uma diferença maior que &lt;{3}&gt; entre o valor esperado &lt;{1}&gt; e o valor real &lt;{2}&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotSameBothNull">
<source>Both values are &lt;null&gt;. {0}</source>
<target state="new">Both values are &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameActualIsNull">
<source>Actual is &lt;null&gt;. {0}</source>
<target state="new">Actual is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameExpectedIsNull">
<source>Expected is &lt;null&gt;. {0}</source>
<target state="new">Expected is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameGivenValues">
<source>Do not pass value types to AreSame(). Values converted to Object will never be the same. Consider using AreEqual(). {0}</source>
<target state="translated">Não passe tipos de valores para AreSame(). Os valores convertidos para Object nunca serão os mesmos. Considere usar AreEqual(). {0}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@
<target state="translated">Между ожидаемым значением &lt;{1}&gt; и фактическим значением &lt;{2}&gt; требуется разница более чем &lt;{3}&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotSameBothNull">
<source>Both values are &lt;null&gt;. {0}</source>
<target state="new">Both values are &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameActualIsNull">
<source>Actual is &lt;null&gt;. {0}</source>
<target state="new">Actual is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameExpectedIsNull">
<source>Expected is &lt;null&gt;. {0}</source>
<target state="new">Expected is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameGivenValues">
<source>Do not pass value types to AreSame(). Values converted to Object will never be the same. Consider using AreEqual(). {0}</source>
<target state="translated">Не передавайте типы значений в функцию AreSame(). Значения, преобразованные в Object, никогда не будут одинаковыми. Попробуйте использовать AreEqual(). {0}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@
<target state="translated">Beklenen değer &lt;{1}&gt; ile gerçek değer &lt;{2}&gt; arasında, şundan büyük olan fark bekleniyor: &lt;{3}&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotSameBothNull">
<source>Both values are &lt;null&gt;. {0}</source>
<target state="new">Both values are &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameActualIsNull">
<source>Actual is &lt;null&gt;. {0}</source>
<target state="new">Actual is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameExpectedIsNull">
<source>Expected is &lt;null&gt;. {0}</source>
<target state="new">Expected is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameGivenValues">
<source>Do not pass value types to AreSame(). Values converted to Object will never be the same. Consider using AreEqual(). {0}</source>
<target state="translated">AreSame()'e değer türleri geçirmeyin. Object olarak dönüştürülen değerler asla aynı olamayacak. AreEqual() kullanmayı düşün. {0}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@
<target state="translated">预期值 &lt;{1}&gt; 和实际值 &lt;{2}&gt; 之间的差应大于 &lt;{3}&gt;。{0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotSameBothNull">
<source>Both values are &lt;null&gt;. {0}</source>
<target state="new">Both values are &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameActualIsNull">
<source>Actual is &lt;null&gt;. {0}</source>
<target state="new">Actual is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameExpectedIsNull">
<source>Expected is &lt;null&gt;. {0}</source>
<target state="new">Expected is &lt;null&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreSameGivenValues">
<source>Do not pass value types to AreSame(). Values converted to Object will never be the same. Consider using AreEqual(). {0}</source>
<target state="translated">不要向 AreSame() 传递值类型。转换为 Object 的值将永远不会相等。请考虑使用 AreEqual()。{0}</target>
Expand Down
Loading