public bool Includes(ITestMethodInfo testMethod) { if (testMethod.Categories.Contains("Red")) { return(true); } return(false); }
/// <inheritdoc /> public IFixture GetFixture(ITestMethodInfo testMethodInfo) { var fixture = new Fixture(); CustomizeFixture(fixture, testMethodInfo); return(fixture); }
private bool Excluded(ITestMethodInfo testMethod) { if(_excludedCategories.IsEmpty) { return false; } var local = new Categories(); local.Add(testMethod.Categories); local.Add(testMethod.InheritedCategories); return local.Intersect(_excludedCategories).Count > 0; }
private bool IsIncluded(ITestMethodInfo testMethodInfo) { foreach (var filter in _filters) { if (!filter.Includes(testMethodInfo)) { return(false); } } return(true); }
public void MethodInfoShouldReturnTheSameInstanceAsTheDecoratedObject([Frozen] ITestMethodInfo testMethodInfo, IgnoreParametersTestMethodInfoDecorator sut) { // Arrange // Act var actual = sut.MethodInfo; // Assert Assert.AreSame(testMethodInfo.MethodInfo, actual); }
private bool Excluded(ITestMethodInfo testMethod) { if (_excludedCategories.IsEmpty) { return(false); } var local = new Categories(); local.Add(testMethod.Categories); local.Add(testMethod.InheritedCategories); return(local.Intersect(_excludedCategories).Count > 0); }
/// <summary> /// Customizes a fixture in the order that the test method parameters are defined and in the order that each of the parameter attributes are defined. /// <para>Override to change how the generated <paramref name="fixture"/> is customized from the test method parameter attributes.</para> /// </summary> /// <param name="fixture">The fixture to customize.</param> /// <param name="testMethodInfo">The test method being executed.</param> protected virtual void CustomizeFixtureByParameters(IFixture fixture, ITestMethodInfo testMethodInfo) { foreach (var parameterType in testMethodInfo.ParameterTypes) { var attributes = parameterType.GetCustomAttributes(typeof(Attribute), false); foreach (var attribute in attributes) { if (attribute is IParameterCustomizationSource parameterCustomizationSource) { parameterCustomizationSource.GetCustomization(parameterType).Customize(fixture); } } } }
public UiElementInfo(ITestAssembly ta, ITestFixtureInfo tf, ITestMethodInfo tm) { if (ta != null) { _assemblyName = ta.Name.FullName.Split(",".ToCharArray())[0]; _assemblyPathName = ta.Name.CodeBase; } _fixtureFullName = string.Empty; _methodName = string.Empty; if( tf != null ) { _fixtureFullName = tf.FullName; if( tm != null ) { _methodName = tm.Name; _methodFullName = tm.FullName; } } }
/// <summary> /// Customizes a fixture in the order that the test method attributes are defined. /// <para>Override to change how the generated <paramref name="fixture"/> is customized from the test method attributes.</para> /// </summary> /// <param name="fixture">The fixture being customized.</param> /// <param name="testMethodInfo">The test method being executed.</param> protected virtual void CustomizeFixtureByMethod(IFixture fixture, ITestMethodInfo testMethodInfo) { var attributes = testMethodInfo.MethodInfo.GetCustomAttributes(typeof(Attribute), false); foreach (var attribute in attributes) { if (attribute is ICustomization customization) { customization.Customize(fixture); } else if (attribute is ICustomizationSource customizationSource) { customizationSource.GetCustomization().Customize(fixture); } } }
public UiElementInfo(ITestAssembly ta, ITestFixtureInfo tf, ITestMethodInfo tm) { if (ta != null) { _assemblyName = ta.Name.FullName.Split(",".ToCharArray())[0]; _assemblyPathName = ta.Name.CodeBase; } _fixtureFullName = string.Empty; _methodName = string.Empty; if (tf != null) { _fixtureFullName = tf.FullName; if (tm != null) { _methodName = tm.Name; _methodFullName = tm.FullName; } } }
private static TreeNode CreateOrFindMethodNode(TreeNodeCollection nodes, ITestMethodInfo tm) { foreach (TreeNode node in nodes) { if (node.Text == tm.Name) { return(node); } } var newNode = new TreeNode(tm.Name) { Tag = new UiElementInfo(null, null, tm), ImageIndex = 3 }; nodes.Add(newNode); return(newNode); }
/// <summary> /// Generates the arguments to execute a test method. /// </summary> /// <param name="fixture">The customized fixture from which to generate arguments.</param> /// <param name="testMethodInfo">The test method being executed.</param> /// <returns>The arguments to execute a test method.</returns> public IEnumerable <object> GetTestMethodArguments(IFixture fixture, ITestMethodInfo testMethodInfo) { return(GetTestMethodArgumentsIterator(fixture, testMethodInfo)); }
public bool Includes(ITestMethodInfo testMethod) { return(IsIncluded(testMethod) && !Excluded(testMethod)); }
/// <summary> /// Customizes a fixture for test method execution. /// <para>Override to change how the generated <paramref name="fixture"/> is customized.</para> /// </summary> /// <param name="fixture">The fixture to customize.</param> /// <param name="testMethodInfo">The test method being executed.</param> protected virtual void CustomizeFixture(IFixture fixture, ITestMethodInfo testMethodInfo) { CustomizeFixtureByMethod(fixture, testMethodInfo); CustomizeFixtureByParameters(fixture, testMethodInfo); }
#pragma warning restore 67 public bool Includes(ITestMethodInfo testMethod) { return(true); }
private static SmartTreeNode CreateOrFindMethodNode(SmartTreeNodeCollection nodes, ITestMethodInfo tm) { foreach (SmartTreeNode node in nodes) { if (node.Text == tm.Name) { return(node); } } SmartTreeNode newNode = new SmartTreeNode(tm.Name); newNode.ImageIndex = 3; nodes.Add(newNode); return(newNode); }
/// <summary> /// Returns a new <see cref="ITestMethodInfo"/> instance which contains a subset of parameters from the source <paramref name="testMethodInfo"/> instance. /// </summary> /// <param name="testMethodInfo">The source <see cref="ITestMethodInfo"/> instance.</param> /// <param name="numberOfParametersToIgnore">The number of parameters to ignore from the <paramref name="testMethodInfo"/> instance.</param> /// <returns>A new <see cref="ITestMethodInfo"/> instance which contains a subset of parameters from the source <paramref name="testMethodInfo"/> instance.</returns> public static ITestMethodInfo IgnoreParameters(this ITestMethodInfo testMethodInfo, int numberOfParametersToIgnore) { return(new IgnoreParametersTestMethodInfoDecorator(testMethodInfo, numberOfParametersToIgnore)); }
/// <summary> /// Initializes a new instance of the <see cref="IgnoreParametersTestMethodInfoDecorator"/> class. /// </summary> /// <param name="testMethodInfoToDecorate">The <see cref="ITestMethodInfo"/> to decorate.</param> public IgnoreParametersTestMethodInfoDecorator(ITestMethodInfo testMethodInfoToDecorate) : this(testMethodInfoToDecorate, 0) { }
public bool Includes(ITestMethodInfo testMethod) { if(testMethod.Categories.Contains("Red")) { return true; } return false; }
#pragma warning restore 67 public bool Includes(ITestMethodInfo testMethod) { return true; }
/// <summary> /// Initializes a new instance of the <see cref="IgnoreParametersTestMethodInfoDecorator"/> class. /// </summary> /// <param name="testMethodInfoToDecorate">The <see cref="ITestMethodInfo"/> to decorate.</param> /// <param name="numberOfParametersToIgnore">The number of parameters that should be ignored when <see cref="ParameterTypes"/> is called.</param> public IgnoreParametersTestMethodInfoDecorator(ITestMethodInfo testMethodInfoToDecorate, int numberOfParametersToIgnore) { _testMethodInfoToDecorate = testMethodInfoToDecorate; NumberOfParametersToIgnore = numberOfParametersToIgnore; }
private IEnumerable <object> GetTestMethodArgumentsIterator(IFixture fixture, ITestMethodInfo testMethodInfo) { var parameterTypes = testMethodInfo.ParameterTypes; if (parameterTypes?.Any() != true) { yield break; } var specimenContext = new SpecimenContext(fixture); foreach (var parameterType in parameterTypes) { yield return(specimenContext.Resolve(parameterType)); } }
private bool IsIncluded(ITestMethodInfo testMethodInfo) { foreach(var filter in _filters) { if(!filter.Includes(testMethodInfo)) { return false; } } return true; }
public bool Includes(ITestMethodInfo testMethod) { return IsIncluded(testMethod) && !Excluded(testMethod); }
public bool Includes(ITestMethodInfo testMethod) { return(Matches(testMethod.FullName)); }