public TheoryCommand(IMethodInfo testMethod, object[] parameters, Type[] genericTypes) : base(testMethod, MethodUtility.GetDisplayName(testMethod), MethodUtility.GetTimeoutParameter(testMethod)) { int idx; Parameters = parameters ?? new object[0]; if (genericTypes != null && genericTypes.Length > 0) { string[] typeNames = new string[genericTypes.Length]; for (idx = 0; idx < genericTypes.Length; idx++) { typeNames[idx] = ConvertToSimpleTypeName(genericTypes[idx]); } DisplayName = String.Format("{0}<{1}>", DisplayName, string.Join(", ", typeNames)); } ParameterInfo[] parameterInfos = testMethod.MethodInfo.GetParameters(); string[] displayValues = new string[Math.Max(Parameters.Length, parameterInfos.Length)]; for (idx = 0; idx < Parameters.Length; idx++) { displayValues[idx] = ParameterToDisplayValue(GetParameterName(parameterInfos, idx), Parameters[idx]); } for (; idx < parameterInfos.Length; idx++) // Fill-in any missing parameters with "???" { displayValues[idx] = parameterInfos[idx].Name + ": ???"; } DisplayName = String.Format("{0}({1})", DisplayName, string.Join(", ", displayValues)); }
public IEnumerable <ITestCommand> AssertCommands(string name, IMethodInfo method) { foreach (var assertion in _asserts) { // do not capture the iteration variable because // all tests would point to the same assertion var capturableAssertion = assertion; Action test = () => { using (SpecificationPrimitiveExecutor.Execute(_context)) { if (_do != null) { SpecificationPrimitiveExecutor.Execute(_do); } SpecificationPrimitiveExecutor.Execute(capturableAssertion); } }; string testDescription = String.Format("{0}, {1}", name, assertion.Message); yield return(new ActionTestCommand(method, testDescription, MethodUtility.GetTimeoutParameter(method), test)); } }
public void TimeoutParameter() { Type testClassType = typeof(TimeoutTestClass); MethodInfo methodInfo = testClassType.GetMethod("TestAttributeWithTimeoutParameter"); long timeout = MethodUtility.GetTimeoutParameter(Reflector.Wrap(methodInfo)); Assert.Equal <long>(1000, timeout); }
public FeatureTestCommand(IMethodInfo method, ILibrary adapter) : base(method, adapter.Name, MethodUtility.GetTimeoutParameter(method)) { this.adapter = adapter; }
public Command(MethodCall methodCall) : base(methodCall == null ? null : methodCall.Method, null, methodCall == null ? 0 : MethodUtility.GetTimeoutParameter(methodCall.Method)) { Guard.AgainstNullArgument("methodCall", methodCall); this.methodCall = methodCall; this.arguments = methodCall.Arguments.ToArray(); this.DisplayName = GetString(methodCall.Method, this.arguments, methodCall.TypeArguments.ToArray()); }
public SpecCommand(IMethodInfo method, bool liveOnly) : base(method, MethodUtility.GetDisplayName(method), MethodUtility.GetTimeoutParameter(method)) { this.LiveOnly = liveOnly; }
public ReleaseCommand(TheoryCommand theory, IMethodInfo method) : base(method, MethodUtility.GetDisplayName(method), MethodUtility.GetTimeoutParameter(method)) { this.theory = theory; }
public static IEnumerable <ITestCommand> ToTestCommands(IMethodInfo method) { try { if (exception == null && asserts.Count == 0) { try { throw new InvalidOperationException("Must have at least one Assert in each specification"); } catch (Exception ex) { exception = ex; } } if (exception == null && !context.HasValue) { try { throw new InvalidOperationException("Must have a Context in each specification"); } catch (Exception ex) { exception = ex; } } if (exception != null) { yield return(new ExceptionTestCommand(method, exception)); yield break; } string name = context.Value.Key; if (@do.HasValue) { name += " " + @do.Value.Key; } foreach (KeyValuePair <string, Action> kvp in asserts) { List <Action> actions = new List <Action>(); actions.Add(context.Value.Value); if (@do.HasValue) { actions.Add(@do.Value.Value); } actions.Add(kvp.Value); yield return(new ActionTestCommand(method, name + ", " + kvp.Key, MethodUtility.GetTimeoutParameter(method), actions)); } } finally { Reset(); } }
/// <param name="innerCommand">The <see cref="ITestCommand"/> to wrap</param> /// <param name="method">The method being used as a test</param> public IocLifetimeCommand(ITestCommand innerCommand, IMethodInfo method) : base(method, MethodUtility.GetDisplayName(method), MethodUtility.GetTimeoutParameter(method)) { _innerCommand = innerCommand; }
public FeatureTestCommand(IMethodInfo method, IFrameworkAdapter adapter) : base(method, adapter.FrameworkName, MethodUtility.GetTimeoutParameter(method)) { this.adapter = adapter; }