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

Dynamic data display name #373

Merged
merged 8 commits into from
Apr 12, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Updated the exception message and added a test for public accessibility
  • Loading branch information
bstoney committed Apr 9, 2018
commit 13c83c52fb5a93398fa24de175e33a8c0077c003
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ public string GetDisplayName(MethodInfo methodInfo, object[] data)
parameters[0].ParameterType != typeof(MethodInfo) ||
parameters[1].ParameterType != typeof(object[]) ||
method.ReturnType != typeof(string) ||
!method.IsStatic)
!method.IsStatic ||
!method.IsPublic)
{
throw new ArgumentNullException(
string.Format(
Expand All @@ -176,4 +177,4 @@ public string GetDisplayName(MethodInfo methodInfo, object[] data)
return null;
}
}
}
}

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 @@ -284,6 +284,6 @@ Stack Trace: {4}</value>
<value>Value returned by property or method {0} shouldn't be null.</value>
</data>
<data name="DynamicDataDisplayName" xml:space="preserve">
Copy link
Member

@jayaranigarg jayaranigarg Mar 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please run "build.cmd -uxlf" so the string addition is localizable. You would have to commit the xlf files changes post running the script.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran this and have committed the xlf files. I'm assuming someone or some magic will do the translation?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please. We just needed modified xlf files. We will take care of the translation 😄

<value>Method {0} must match the expected signature: {1} {0}({2}).</value>
<value>Method {0} must match the expected signature: public static {1} {0}({2}).</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Trasování zásobníku: {4}</target>
<note />
</trans-unit>
<trans-unit id="DynamicDataDisplayName">
<source>Method {0} must match the expected signature: {1} {0}({2}).</source>
<source>Method {0} must match the expected signature: public static {1} {0}({2}).</source>
<target state="new">Method {0} must match the expected signature: {1} {0}({2}).</target>
<note></note>
</trans-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Stapelüberwachung: {4}</target>
<note />
</trans-unit>
<trans-unit id="DynamicDataDisplayName">
<source>Method {0} must match the expected signature: {1} {0}({2}).</source>
<source>Method {0} must match the expected signature: public static {1} {0}({2}).</source>
<target state="new">Method {0} must match the expected signature: {1} {0}({2}).</target>
<note></note>
</trans-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Seguimiento de la pila: {4}</target>
<note />
</trans-unit>
<trans-unit id="DynamicDataDisplayName">
<source>Method {0} must match the expected signature: {1} {0}({2}).</source>
<source>Method {0} must match the expected signature: public static {1} {0}({2}).</source>
<target state="new">Method {0} must match the expected signature: {1} {0}({2}).</target>
<note></note>
</trans-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Trace de la pile : {4}</target>
<note />
</trans-unit>
<trans-unit id="DynamicDataDisplayName">
<source>Method {0} must match the expected signature: {1} {0}({2}).</source>
<source>Method {0} must match the expected signature: public static {1} {0}({2}).</source>
<target state="new">Method {0} must match the expected signature: {1} {0}({2}).</target>
<note></note>
</trans-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Analisi dello stack: {4}</target>
<note />
</trans-unit>
<trans-unit id="DynamicDataDisplayName">
<source>Method {0} must match the expected signature: {1} {0}({2}).</source>
<source>Method {0} must match the expected signature: public static {1} {0}({2}).</source>
<target state="new">Method {0} must match the expected signature: {1} {0}({2}).</target>
<note></note>
</trans-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Stack Trace: {4}</source>
<note />
</trans-unit>
<trans-unit id="DynamicDataDisplayName">
<source>Method {0} must match the expected signature: {1} {0}({2}).</source>
<source>Method {0} must match the expected signature: public static {1} {0}({2}).</source>
<target state="new">Method {0} must match the expected signature: {1} {0}({2}).</target>
<note></note>
</trans-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Stack Trace: {4}</source>
<note />
</trans-unit>
<trans-unit id="DynamicDataDisplayName">
<source>Method {0} must match the expected signature: {1} {0}({2}).</source>
<source>Method {0} must match the expected signature: public static {1} {0}({2}).</source>
<target state="new">Method {0} must match the expected signature: {1} {0}({2}).</target>
<note></note>
</trans-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Komunikat o wyjątku: {3}
<note />
</trans-unit>
<trans-unit id="DynamicDataDisplayName">
<source>Method {0} must match the expected signature: {1} {0}({2}).</source>
<source>Method {0} must match the expected signature: public static {1} {0}({2}).</source>
<target state="new">Method {0} must match the expected signature: {1} {0}({2}).</target>
<note></note>
</trans-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Rastreamento de Pilha: {4}</target>
<note />
</trans-unit>
<trans-unit id="DynamicDataDisplayName">
<source>Method {0} must match the expected signature: {1} {0}({2}).</source>
<source>Method {0} must match the expected signature: public static {1} {0}({2}).</source>
<target state="new">Method {0} must match the expected signature: {1} {0}({2}).</target>
<note></note>
</trans-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Stack Trace: {4}</source>
<note />
</trans-unit>
<trans-unit id="DynamicDataDisplayName">
<source>Method {0} must match the expected signature: {1} {0}({2}).</source>
<source>Method {0} must match the expected signature: public static {1} {0}({2}).</source>
<target state="new">Method {0} must match the expected signature: {1} {0}({2}).</target>
<note></note>
</trans-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Yığın İzleme: {4}</target>
<note />
</trans-unit>
<trans-unit id="DynamicDataDisplayName">
<source>Method {0} must match the expected signature: {1} {0}({2}).</source>
<source>Method {0} must match the expected signature: public static {1} {0}({2}).</source>
<target state="new">Method {0} must match the expected signature: {1} {0}({2}).</target>
<note></note>
</trans-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Stack Trace: {4}</target>
<note></note>
</trans-unit>
<trans-unit id="DynamicDataDisplayName">
<source>Method {0} must match the expected signature: {1} {0}({2}).</source>
<source>Method {0} must match the expected signature: public static {1} {0}({2}).</source>
<target state="new">Method {0} must match the expected signature: {1} {0}({2}).</target>
<note></note>
</trans-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Stack Trace: {4}</source>
<note />
</trans-unit>
<trans-unit id="DynamicDataDisplayName">
<source>Method {0} must match the expected signature: {1} {0}({2}).</source>
<source>Method {0} must match the expected signature: public static {1} {0}({2}).</source>
<target state="new">Method {0} must match the expected signature: {1} {0}({2}).</target>
<note></note>
</trans-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Stack Trace: {4}</source>
<note />
</trans-unit>
<trans-unit id="DynamicDataDisplayName">
<source>Method {0} must match the expected signature: {1} {0}({2}).</source>
<source>Method {0} must match the expected signature: public static {1} {0}({2}).</source>
<target state="new">Method {0} must match the expected signature: {1} {0}({2}).</target>
<note></note>
</trans-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,20 @@ public void GetDisplayNameShouldThrowExceptionWithDynamicDataDisplayNameMethodNo
ActionUtility.ActionShouldThrowExceptionOfType(action, typeof(ArgumentNullException));
}

[TestFrameworkV1.TestMethod]
public void GetDisplayNameShouldThrowExceptionWithDynamicDataDisplayNameMethodPrivate()
{
Action action = () =>
{
var data = new object[] { 1, 2, 3 };

this.dynamicDataAttribute.DynamicDataDisplayName = "GetDynamicDataDisplayNamePrivate";
var displayName = this.dynamicDataAttribute.GetDisplayName(this.testMethodInfo, data);
};

ActionUtility.ActionShouldThrowExceptionOfType(action, typeof(ArgumentNullException));
}

[TestFrameworkV1.TestMethod]
public void GetDisplayNameShouldThrowExceptionWithMissingDynamicDataDisplayNameMethod()
{
Expand Down Expand Up @@ -433,6 +447,23 @@ public void TestMethod4()
public void DataRowTestMethod()
{
}

/// <summary>
/// Custom display name method that is private.
/// </summary>
/// <param name="methodInfo">
/// The method info of test method.
/// </param>
/// <param name="data">
/// The test data which is passed to test method.
/// </param>
/// <returns>
/// The <see cref="string"/>.
/// </returns>
private static string GetDynamicDataDisplayNamePrivate(MethodInfo methodInfo, object[] data)
{
throw new InvalidOperationException();
}
}

public class DummyTestClass2
Expand Down