-
-
Notifications
You must be signed in to change notification settings - Fork 808
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Format method parameter type list more accurately
This ensures that `in`, `ref`, `out`, and `params` modifiers are in- cluded in the formatting of parameter type lists.
- Loading branch information
Showing
4 changed files
with
101 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) 2007, Clarius Consulting, Manas Technology Solutions, InSTEDD. | ||
// All rights reserved. Licensed under the BSD 3-Clause License; see License.txt. | ||
|
||
using System.Text; | ||
|
||
using Xunit; | ||
|
||
namespace Moq.Tests | ||
{ | ||
public class StringBuilderExtensionsFixture | ||
{ | ||
[Theory] | ||
[InlineData(nameof(IMethods.Empty), "")] | ||
[InlineData(nameof(IMethods.Int), "int")] | ||
[InlineData(nameof(IMethods.IntAndString), "int, string")] | ||
[InlineData(nameof(IMethods.InInt), "in int")] | ||
[InlineData(nameof(IMethods.RefInt), "ref int")] | ||
[InlineData(nameof(IMethods.OutInt), "out int")] | ||
[InlineData(nameof(IMethods.BoolAndParamsString), "bool, params string[]")] | ||
public void AppendParameterList_formats_parameter_lists_correctly(string methodName, string expected) | ||
{ | ||
var actual = GetFormattedParameterListOf(methodName); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
private string GetFormattedParameterListOf(string methodName) | ||
{ | ||
var stringBuilder = new StringBuilder(); | ||
var method = typeof(IMethods).GetMethod(methodName); | ||
stringBuilder.AppendParameterTypeList(method.GetParameters()); | ||
return stringBuilder.ToString(); | ||
} | ||
|
||
public interface IMethods | ||
{ | ||
void Empty(); | ||
void Int(int arg1); | ||
void IntAndString(int arg1, string arg2); | ||
void InInt(in int arg1); | ||
void RefInt(ref int arg1); | ||
void OutInt(out int arg1); | ||
void BoolAndParamsString(bool arg1, params string[] arg2); | ||
} | ||
} | ||
} |