コード例 #1
0
ファイル: MethodDiscovererTests.cs プロジェクト: mslot/fixie
        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)");
        }
コード例 #2
0
ファイル: MethodDiscovererTests.cs プロジェクト: mslot/fixie
        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()");
        }
コード例 #3
0
        public void ShouldConsiderOnlyConcreteClasses()
        {
            var customDiscovery = new SampleDiscovery();

            DiscoveredTestClasses(customDiscovery)
            .ShouldEqual(
                typeof(StaticClass),
                typeof(DefaultConstructor),
                typeof(NoDefaultConstructor),
                typeof(NameEndsWithTests),
                typeof(String),
                typeof(InheritanceSampleBase),
                typeof(InheritanceSample));
        }
コード例 #4
0
ファイル: MethodDiscovererTests.cs プロジェクト: mslot/fixie
        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!");
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        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 }
            });
        }
コード例 #8
0
ファイル: MethodDiscovererTests.cs プロジェクト: mslot/fixie
        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()");
        }
コード例 #9
0
        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));
        }
コード例 #10
0
        public void ShouldProvideZeroSetsOfInputParametersByDefault()
        {
            var customDiscovery = new SampleDiscovery();

            DiscoveredParameters(customDiscovery).ShouldBeEmpty();
        }