public void ShouldConsiderOnlyPublicMethods() { var customDiscovery = new SampleDiscovery(); DiscoveredTestMethods <Sample>(customDiscovery) .ShouldBe( "PublicInstanceNoArgsVoid()", "PublicInstanceNoArgsWithReturn()", "PublicInstanceWithArgsVoid(x)", "PublicInstanceWithArgsWithReturn(x)", "PublicStaticNoArgsVoid()", "PublicStaticNoArgsWithReturn()", "PublicStaticWithArgsVoid(x)", "PublicStaticWithArgsWithReturn(x)"); DiscoveredTestMethods <AsyncSample>(customDiscovery) .ShouldBe( "PublicInstanceNoArgsVoid()", "PublicInstanceNoArgsWithReturn()", "PublicInstanceWithArgsVoid(x)", "PublicInstanceWithArgsWithReturn(x)", "PublicStaticNoArgsVoid()", "PublicStaticNoArgsWithReturn()", "PublicStaticWithArgsVoid(x)", "PublicStaticWithArgsWithReturn(x)"); }
public void ShouldDiscoverMethodsSatisfyingAllSpecifiedConditions() { var customDiscovery = new SampleDiscovery(); customDiscovery .Methods .Where(x => x.Name.Contains("Void")) .Where(x => x.Name.Contains("No")) .Where(x => !x.IsStatic); DiscoveredTestMethods <Sample>(customDiscovery) .ShouldBe("PublicInstanceNoArgsVoid()"); }
public void ShouldConsiderOnlyConcreteClasses() { var customDiscovery = new SampleDiscovery(); DiscoveredTestClasses(customDiscovery) .ShouldEqual( typeof(StaticClass), typeof(DefaultConstructor), typeof(NoDefaultConstructor), typeof(NameEndsWithTests), typeof(String), typeof(InheritanceSampleBase), typeof(InheritanceSample)); }
public void ShouldFailWithClearExplanationWhenAnyGivenConditionThrows() { var customDiscovery = new SampleDiscovery(); customDiscovery .Methods .Where(x => throw new Exception("Unsafe method-discovery predicate threw!")); Action attemptFaultyDiscovery = () => DiscoveredTestMethods <Sample>(customDiscovery); var exception = attemptFaultyDiscovery.ShouldThrow <Exception>( "Exception thrown while attempting to run a custom method-discovery predicate. " + "Check the inner exception for more details."); exception.InnerException.Message.ShouldBe("Unsafe method-discovery predicate threw!"); }
public void ShouldDiscoverClassesSatisfyingAllSpecifiedConditions() { var customDiscovery = new SampleDiscovery(); customDiscovery .Classes .Where(x => x.IsInNamespace("Fixie.Tests")) .Where(x => x.Name.Contains("i")) .Where(x => !x.IsStatic()); DiscoveredTestClasses(customDiscovery) .ShouldEqual( typeof(NameEndsWithTests), typeof(InheritanceSampleBase), typeof(InheritanceSample)); }
public void ShouldNotConsiderDiscoveryAndExecutionCustomizationClasses() { var customDiscovery = new SampleDiscovery(); DiscoveredTestClasses(customDiscovery, typeof(SampleDiscovery), typeof(SampleExecution)) .ShouldEqual( typeof(StaticClass), typeof(DefaultConstructor), typeof(NoDefaultConstructor), typeof(NameEndsWithTests), typeof(String), typeof(InheritanceSampleBase), typeof(InheritanceSample)); }
public void ShouldProvideSetsOfInputsGeneratedByInstantiatedParameterSources() { var customDiscovery = new SampleDiscovery(); customDiscovery .Parameters .Add(new FirstParameterSource()) .Add(new SecondParameterSource()); DiscoveredParameters(customDiscovery) .ShouldBe(new[] { new object[] { "ParameterizedMethod", 0, false }, new object[] { "ParameterizedMethod", 1, true }, new object[] { "ParameterizedMethod", 2, false }, new object[] { "ParameterizedMethod", 3, true } }); }
public void ShouldNotConsiderIDisposableDisposeMethod() { var customDiscovery = new SampleDiscovery(); DiscoveredTestMethods <DisposableSample>(customDiscovery) .ShouldBe( "Dispose(disposing)", "NotNamedDispose()"); DiscoveredTestMethods <NonDisposableSample>(customDiscovery) .ShouldBe( "Dispose()", "Dispose(disposing)", "NotNamedDispose()"); DiscoveredTestMethods <NonDisposableByReturnTypeSample>(customDiscovery) .ShouldBe( "Dispose()", "Dispose(disposing)", "NotNamedDispose()"); }
public void ShouldNotConsiderCompilerGeneratedClosureClasses() { var nested = typeof(ClassThatCausesCompilerGeneratedNestedClosureClass) .GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance) .Single(); //Confirm that a nested closure class has actually been generated. nested.Has <CompilerGeneratedAttribute>().ShouldBeTrue(); //Confirm that the nested closure class is omitted from test class discovery. var customDiscovery = new SampleDiscovery(); DiscoveredTestClasses(customDiscovery, nested) .ShouldEqual( typeof(StaticClass), typeof(DefaultConstructor), typeof(NoDefaultConstructor), typeof(NameEndsWithTests), typeof(String), typeof(InheritanceSampleBase), typeof(InheritanceSample)); }
public void ShouldProvideZeroSetsOfInputParametersByDefault() { var customDiscovery = new SampleDiscovery(); DiscoveredParameters(customDiscovery).ShouldBeEmpty(); }