Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partially improve CollectionAssert message #4027

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,9 @@ private static bool CompareIEnumerable(IEnumerable? expected, IEnumerable? actua
reason = string.Format(
CultureInfo.CurrentCulture,
FrameworkMessages.ElementsAtIndexDontMatch,
position);
position,
Assert.ReplaceNulls(curExpected),
Assert.ReplaceNulls(curActual));
return false;
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@
<value>The number of elements in the collections do not match. Expected:&lt;{1}&gt;. Actual:&lt;{2}&gt;.{0}</value>
</data>
<data name="ElementsAtIndexDontMatch" xml:space="preserve">
<value>Element at index {0} do not match.</value>
<value>Element at index {0} do not match.
Expected: {1}
Actual: {2}</value>
</data>
<data name="ElementTypesAtIndexDontMatch" xml:space="preserve">
<value>Element at index {1} is not of expected type. Expected type:&lt;{2}&gt;. Actual type:&lt;{3}&gt;.{0}</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@
<note></note>
</trans-unit>
<trans-unit id="ElementsAtIndexDontMatch">
<source>Element at index {0} do not match.</source>
<target state="translated">Element na indexu {0} nesouhlasí.</target>
<note></note>
<source>Element at index {0} do not match.
Expected: {1}
Actual: {2}</source>
<target state="new">Element at index {0} do not match.
Expected: {1}
Actual: {2}</target>
<note />
</trans-unit>
<trans-unit id="ElementTypesAtIndexDontMatch">
<source>Element at index {1} is not of expected type. Expected type:&lt;{2}&gt;. Actual type:&lt;{3}&gt;.{0}</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@
<note></note>
</trans-unit>
<trans-unit id="ElementsAtIndexDontMatch">
<source>Element at index {0} do not match.</source>
<target state="translated">Die Elemente bei Index "{0}" stimmen nicht überein.</target>
<note></note>
<source>Element at index {0} do not match.
Expected: {1}
Actual: {2}</source>
<target state="new">Element at index {0} do not match.
Expected: {1}
Actual: {2}</target>
<note />
</trans-unit>
<trans-unit id="ElementTypesAtIndexDontMatch">
<source>Element at index {1} is not of expected type. Expected type:&lt;{2}&gt;. Actual type:&lt;{3}&gt;.{0}</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@
<note></note>
</trans-unit>
<trans-unit id="ElementsAtIndexDontMatch">
<source>Element at index {0} do not match.</source>
<target state="translated">El elemento del índice {0} no coincide.</target>
<note></note>
<source>Element at index {0} do not match.
Expected: {1}
Actual: {2}</source>
<target state="new">Element at index {0} do not match.
Expected: {1}
Actual: {2}</target>
<note />
</trans-unit>
<trans-unit id="ElementTypesAtIndexDontMatch">
<source>Element at index {1} is not of expected type. Expected type:&lt;{2}&gt;. Actual type:&lt;{3}&gt;.{0}</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@
<note></note>
</trans-unit>
<trans-unit id="ElementsAtIndexDontMatch">
<source>Element at index {0} do not match.</source>
<target state="translated">Les éléments à l'index {0} ne correspondent pas.</target>
<note></note>
<source>Element at index {0} do not match.
Expected: {1}
Actual: {2}</source>
<target state="new">Element at index {0} do not match.
Expected: {1}
Actual: {2}</target>
<note />
</trans-unit>
<trans-unit id="ElementTypesAtIndexDontMatch">
<source>Element at index {1} is not of expected type. Expected type:&lt;{2}&gt;. Actual type:&lt;{3}&gt;.{0}</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@
<note></note>
</trans-unit>
<trans-unit id="ElementsAtIndexDontMatch">
<source>Element at index {0} do not match.</source>
<target state="translated">L'elemento alla posizione di indice {0} non corrisponde.</target>
<note></note>
<source>Element at index {0} do not match.
Expected: {1}
Actual: {2}</source>
<target state="new">Element at index {0} do not match.
Expected: {1}
Actual: {2}</target>
<note />
</trans-unit>
<trans-unit id="ElementTypesAtIndexDontMatch">
<source>Element at index {1} is not of expected type. Expected type:&lt;{2}&gt;. Actual type:&lt;{3}&gt;.{0}</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@
<note></note>
</trans-unit>
<trans-unit id="ElementsAtIndexDontMatch">
<source>Element at index {0} do not match.</source>
<target state="translated">インデックス {0} の要素が一致しません。</target>
<note></note>
<source>Element at index {0} do not match.
Expected: {1}
Actual: {2}</source>
<target state="new">Element at index {0} do not match.
Expected: {1}
Actual: {2}</target>
<note />
</trans-unit>
<trans-unit id="ElementTypesAtIndexDontMatch">
<source>Element at index {1} is not of expected type. Expected type:&lt;{2}&gt;. Actual type:&lt;{3}&gt;.{0}</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@
<note></note>
</trans-unit>
<trans-unit id="ElementsAtIndexDontMatch">
<source>Element at index {0} do not match.</source>
<target state="translated">인덱스 {0}에 있는 요소가 일치하지 않습니다.</target>
<note></note>
<source>Element at index {0} do not match.
Expected: {1}
Actual: {2}</source>
<target state="new">Element at index {0} do not match.
Expected: {1}
Actual: {2}</target>
<note />
</trans-unit>
<trans-unit id="ElementTypesAtIndexDontMatch">
<source>Element at index {1} is not of expected type. Expected type:&lt;{2}&gt;. Actual type:&lt;{3}&gt;.{0}</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@
<note></note>
</trans-unit>
<trans-unit id="ElementsAtIndexDontMatch">
<source>Element at index {0} do not match.</source>
<target state="translated">Element w indeksie {0} nie jest zgodny.</target>
<note></note>
<source>Element at index {0} do not match.
Expected: {1}
Actual: {2}</source>
<target state="new">Element at index {0} do not match.
Expected: {1}
Actual: {2}</target>
<note />
</trans-unit>
<trans-unit id="ElementTypesAtIndexDontMatch">
<source>Element at index {1} is not of expected type. Expected type:&lt;{2}&gt;. Actual type:&lt;{3}&gt;.{0}</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@
<note></note>
</trans-unit>
<trans-unit id="ElementsAtIndexDontMatch">
<source>Element at index {0} do not match.</source>
<target state="translated">O elemento no índice {0} não corresponde.</target>
<note></note>
<source>Element at index {0} do not match.
Expected: {1}
Actual: {2}</source>
<target state="new">Element at index {0} do not match.
Expected: {1}
Actual: {2}</target>
<note />
</trans-unit>
<trans-unit id="ElementTypesAtIndexDontMatch">
<source>Element at index {1} is not of expected type. Expected type:&lt;{2}&gt;. Actual type:&lt;{3}&gt;.{0}</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@
<note></note>
</trans-unit>
<trans-unit id="ElementsAtIndexDontMatch">
<source>Element at index {0} do not match.</source>
<target state="translated">Элемент по индексу {0} не совпадает.</target>
<note></note>
<source>Element at index {0} do not match.
Expected: {1}
Actual: {2}</source>
<target state="new">Element at index {0} do not match.
Expected: {1}
Actual: {2}</target>
<note />
</trans-unit>
<trans-unit id="ElementTypesAtIndexDontMatch">
<source>Element at index {1} is not of expected type. Expected type:&lt;{2}&gt;. Actual type:&lt;{3}&gt;.{0}</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@
<note></note>
</trans-unit>
<trans-unit id="ElementsAtIndexDontMatch">
<source>Element at index {0} do not match.</source>
<target state="translated">{0} dizinindeki öğe eşleşmiyor.</target>
<note></note>
<source>Element at index {0} do not match.
Expected: {1}
Actual: {2}</source>
<target state="new">Element at index {0} do not match.
Expected: {1}
Actual: {2}</target>
<note />
</trans-unit>
<trans-unit id="ElementTypesAtIndexDontMatch">
<source>Element at index {1} is not of expected type. Expected type:&lt;{2}&gt;. Actual type:&lt;{3}&gt;.{0}</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@
<note></note>
</trans-unit>
<trans-unit id="ElementsAtIndexDontMatch">
<source>Element at index {0} do not match.</source>
<target state="translated">索引 {0} 处的元素不匹配。</target>
<note></note>
<source>Element at index {0} do not match.
Expected: {1}
Actual: {2}</source>
<target state="new">Element at index {0} do not match.
Expected: {1}
Actual: {2}</target>
<note />
</trans-unit>
<trans-unit id="ElementTypesAtIndexDontMatch">
<source>Element at index {1} is not of expected type. Expected type:&lt;{2}&gt;. Actual type:&lt;{3}&gt;.{0}</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@
<note></note>
</trans-unit>
<trans-unit id="ElementsAtIndexDontMatch">
<source>Element at index {0} do not match.</source>
<target state="translated">位於索引 {0} 的項目不符。</target>
<note></note>
<source>Element at index {0} do not match.
Expected: {1}
Actual: {2}</source>
<target state="new">Element at index {0} do not match.
Expected: {1}
Actual: {2}</target>
<note />
</trans-unit>
<trans-unit id="ElementTypesAtIndexDontMatch">
<source>Element at index {1} is not of expected type. Expected type:&lt;{2}&gt;. Actual type:&lt;{3}&gt;.{0}</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,17 @@ public void CollectionAssertAreNotEquivalent_FailsWithTwoNullsAndComparer_WithMe
Verify(ex.Message.Contains("message"));
}

public void CollectionAssertAreEqual_FailsWithGoodMessage()
{
Exception ex = VerifyThrows(() => CollectionAssert.AreEqual(new[] { 1, 2, 3 }, new[] { 1, 5, 3 }));
Assert.AreEqual(
"""
CollectionAssert.AreEqual failed. (Element at index 1 do not match.
Expected: 2
Actual: 5)
""", ex.Message);
}

#pragma warning disable CA1859 // Use concrete types when possible for improved performance

private static List<object> GenerateDeeplyNestedCollection(int depth)
Expand Down