Exemplo n.º 1
0
        public void ExceptionThrownIfMethodNotFound()
        {
            ScenarioWrapper scenarioWrapper = new ScenarioWrapper(typeof(MethodSearchTestsClass));

            Action action = () =>
            {
                scenarioWrapper.Given("NonExistingGivenMethod");
            };

            action.ShouldThrow <TestMethodNotFoundException>();

            action = () =>
            {
                scenarioWrapper.When("NonExistingWhenMethod");
            };

            action.ShouldThrow <TestMethodNotFoundException>();

            action = () =>
            {
                scenarioWrapper.Then("NonExistingThenMethod");
            };

            action.ShouldThrow <TestMethodNotFoundException>();
        }
        public void IntBoolDoubleTableStringParametersHavePassedCorrectly()
        {
            ScenarioWrapper scenarioWrapper = new ScenarioWrapper(typeof(MethodSearchTestsClass));

            int    expectedIntParam    = 100;
            bool   expectedBoolParam   = true;
            double expectedDoubleParam = 10.10;
            string expectedStringParam = "testString";
            string expectedTableValue  = "Value";

            Action action = () =>
            {
                scenarioWrapper
                .Given(
                    $"Int={expectedIntParam};Bool={expectedBoolParam};" +
                    $"Double={expectedDoubleParam};Table;String={expectedStringParam};ParametersMethod",
                    new Table(
                        new [] { "Column" },
                        new object[][]
                {
                    new [] { expectedTableValue }
                }
                        ))
                .Run();
            };

            action.ShouldNotThrow();
            GetResult <bool>("IntBoolDoubleTableStringParametersMethod").Should().BeTrue();
            GetResult <int>("intParam").Should().Be(expectedIntParam);
            GetResult <bool>("boolParam").Should().Be(expectedBoolParam);
            GetResult <double>("doubleParam").Should().Be(expectedDoubleParam);
            GetResult <string>("stringParam").Should().Be(expectedStringParam);
            GetResult <string>("tableColumnValue").Should().Be(expectedTableValue);
        }
Exemplo n.º 3
0
        public void ExceptionThrownWhenAmbiguousGivenMethodFound()
        {
            ScenarioWrapper scenarioWrapper = new ScenarioWrapper(typeof(MethodSearchTestsClass));

            Action action = () =>
            {
                scenarioWrapper.Given("GivenStaticMethodSearchTestsClassDuplicated");
            };

            action.ShouldThrow <AmbiguousTestMethodFoundException>();
        }
Exemplo n.º 4
0
        public void GivenMethodFoundForRegExPattern()
        {
            ScenarioWrapper scenarioWrapper = new ScenarioWrapper(typeof(MethodSearchTestsClass));

            Action action = () =>
            {
                scenarioWrapper.Given("GivenStaticMethodSearchTestsClass");
            };

            action.ShouldNotThrow();
        }