Skip to content
This repository has been archived by the owner on Jun 12, 2021. It is now read-only.

Commit

Permalink
use xUnit's Reflector to convert arguments from Examples. Needed to u…
Browse files Browse the repository at this point in the history
…se strongly typed arrays in examples.
  • Loading branch information
ursenzler authored and adamralph committed Nov 21, 2015
1 parent c374742 commit 7c77502
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Expand Up @@ -4,9 +4,11 @@

namespace Xbehave.Execution.Extensions
{
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Threading.Tasks;
using Xunit.Sdk;

internal static class MethodInfoExtensions
{
Expand All @@ -15,6 +17,13 @@ public static async Task InvokeAsync(this MethodInfo method, object obj, object[
{
Guard.AgainstNullArgument("method", method);

var parameters = method.GetParameters();
var parameterTypes = new Type[parameters.Length];
for (int i = 0; i < parameters.Length; i++)
parameterTypes[i] = parameters[i].ParameterType;

Reflector.ConvertArguments(arguments, parameterTypes);

var result = method.Invoke(obj, arguments);
var task = result as Task;
if (task != null)
Expand Down
Expand Up @@ -22,8 +22,8 @@ public void BaseTypes(string s, int i, IStepContext stepContext)
}

[Scenario]
[Example(new object[] { "one", "two" }, new object[] { 1, 2 })]
public void Arrays(object[] words, object[] numbers, IStepContext stepContext)
[Example(new[] { "one", "two" }, new[] { 1, 2 })]
public void Arrays(string[] words, int[] numbers, IStepContext stepContext)
{
"When I execute a step"
.f(c => stepContext = c);
Expand Down

0 comments on commit 7c77502

Please sign in to comment.