├── .gitignore ├── .paket ├── Paket.Restore.targets ├── paket.exe └── paket.targets ├── README.md ├── build.cmd ├── build.fsx ├── build.sh ├── nuget ├── ReSharper.feature ├── Resharper.scripts │ ├── Install.ps1 │ └── UnInstall.ps1 ├── Samples │ ├── Calculator.cs.pp │ ├── FluentExampleWithImplementationInBaseClass.cs.pp │ ├── FluentExampleWithImplementationInHelperClass.cs.pp │ ├── FluentExampleWithInlineImplementation.cs.pp │ ├── Gherkin │ │ ├── EmbeddedExample.cs.pp │ │ ├── Examples.cs.pp │ │ ├── Examples.feature │ │ ├── GameOfLife.cs.pp │ │ ├── GameOfLife.feature │ │ ├── GameOfLifeSteps.cs.pp │ │ ├── Language.cs.pp │ │ ├── Language.feature │ │ ├── Simple.cs.pp │ │ ├── Simple.feature │ │ ├── Tables.cs.pp │ │ └── Tables.feature │ ├── SpecExample.cs.pp │ └── __ReadMe__.txt ├── VsPlugin.feature ├── VsPlugin.scripts │ ├── Install.ps1 │ └── UnInstall.ps1 ├── nbehave.fluent.mbunit.nuspec ├── nbehave.fluent.mstest.nuspec ├── nbehave.fluent.nunit.nuspec ├── nbehave.fluent.xunit.nuspec ├── nbehave.nuspec ├── nbehave.resharper71.nuspec ├── nbehave.resharper711.nuspec ├── nbehave.resharper712.nuspec ├── nbehave.resharper80.nuspec ├── nbehave.runners.nuspec ├── nbehave.samples.nuspec ├── nbehave.spec.mbunit.nuspec ├── nbehave.spec.mstest.nuspec ├── nbehave.spec.nunit.nuspec ├── nbehave.spec.xunit.nuspec └── nbehave.vsplugin.nuspec ├── paket.dependencies ├── paket.lock └── src ├── CommonAssemblyInfo.cs ├── NBehave.Console.Specifications ├── CommandLineParserSpec.cs ├── ConsoleOptionsSpec.cs ├── GreetingSystem.scenario ├── NBehave.Console.Specifications.csproj ├── ProgramFixture.cs ├── Properties │ └── AssemblyInfo.cs └── paket.references ├── NBehave.Console ├── CommandLineParser.cs ├── ConsoleOptions.cs ├── NBehave.Console.csproj ├── NBehaveConsoleRunner.cs ├── Properties │ └── AssemblyInfo.cs └── paket.references ├── NBehave.Fluent.Framework.Specifications ├── MbUnit_ScenarioDrivenSpecBaseSpecs.cs ├── Mocks │ └── StrictMockSpec.cs ├── MsTest_ScenarioDrivenSpecBaseSpecs.cs ├── NBehave.Fluent.Framework.Specifications.csproj ├── NUnit_ScenarioDrivenSpecBaseSpecs.cs ├── Properties │ └── AssemblyInfo.cs ├── ScenarioBuilderSpec.cs ├── ScenarioDrivenSpecBaseSpecs.cs ├── ScenarioDrivenSpecStepRunnerTests.cs ├── XUnit_ScenarioDrivenSpecBaseSpecs.cs └── paket.references ├── NBehave.Fluent.Framework ├── ActionStepStepResolver.cs ├── DictionaryStepResolver.cs ├── Extensions │ └── FeatureExtensions.cs ├── IAsAFragment.cs ├── IGivenFragment.cs ├── IIWantFragment.cs ├── IScenarioBuilderStart.cs ├── IScenarioBuilderStartWithHelperObject.cs ├── IScenarioFragmentBase.cs ├── ISoThatFragment.cs ├── IStepResolver.cs ├── IThenFragment.cs ├── IWhenFragment.cs ├── MSTest │ └── ScenarioDrivenSpecBase.cs ├── MbUnit │ └── ScenarioDrivenSpecBase.cs ├── NBehave.Fluent.Framework.csproj ├── NUnit │ └── ScenarioDrivenSpecBase.cs ├── Properties │ └── AssemblyInfo.cs ├── ReflectedMethodStepResolver.cs ├── ScenarioBuilder.cs ├── ScenarioDrivenSpecBase.cs ├── ScenarioDrivenSpecStepRunner.cs ├── StoryBuilder.cs ├── Xunit │ └── ScenarioDrivenSpecBase.cs └── paket.references ├── NBehave.ReSharper.Plugin ├── Extensions.cs ├── NBehave.ReSharper.Plugin.csproj ├── NBehave.ReSharper7.1.Plugin.csproj ├── NBehave.Resharper8.0.Plugin.csproj ├── Properties │ ├── AssemblyInfo7.1.cs │ └── AssemblyInfo8.0.cs ├── Resource │ └── nbehave.png ├── UnitTestProvider │ ├── FeatureMapper.cs │ ├── IdentityGenerator.cs │ ├── MetadataExplorer.cs │ ├── NBehaveBackgroundTestElement.cs │ ├── NBehaveExampleParentTestElement.cs │ ├── NBehaveExampleTestElement.cs │ ├── NBehaveFeatureTestElement.cs │ ├── NBehaveScenarioTestElement.cs │ ├── NBehaveStepTestElement.cs │ ├── NBehaveUnitTestElementBase.cs │ ├── NBehaveUnitTestElementBase7.1.cs │ ├── NBehaveUnitTestElementBase8.0.cs │ ├── Presenter.cs │ ├── TestProvider.cs │ ├── TestProvider7.1.cs │ ├── TestProvider8.0.cs │ ├── TestTreePresenter.cs │ ├── UnitTestMetadataExplorer.cs │ ├── UnitTestMetadataExplorer7.1.cs │ └── UnitTestMetadataExplorer8.0.cs ├── UnitTestRunner │ ├── NBehaveAssemblyTask.cs │ ├── NBehaveBackgroundTask.cs │ ├── NBehaveExampleParentTask.cs │ ├── NBehaveExampleTask.cs │ ├── NBehaveFeatureTask.cs │ ├── NBehaveScenarioTask.cs │ ├── NBehaveStepTask.cs │ ├── NBehaveTaskRunner.cs │ ├── NBehaveTaskRunner7.1.cs │ ├── NBehaveTaskRunnerListener.cs │ ├── ResharperResultPublisher.cs │ └── TaskExecutionNodeExtensions.cs ├── __ReadMe__.txt └── paket.references ├── NBehave.Spec.MSTest.Specifications ├── ExtensionsSpecs.cs ├── NBehave.Spec.MSTest.Specifications.csproj ├── Properties │ └── AssemblyInfo.cs ├── SpecBaseSpecs.cs └── paket.references ├── NBehave.Spec.MSTest ├── Extensions.cs ├── NBehave.Spec.MSTest.csproj ├── Properties │ └── AssemblyInfo.cs ├── SpecBase.cs ├── SpecBase_generic.cs └── paket.references ├── NBehave.Spec.MbUnit.Specifications ├── ExtensionsSpecs.cs ├── NBehave.Spec.MbUnit.Specifications.csproj ├── Properties │ └── AssemblyInfo.cs ├── SpecBaseSpecs.cs └── paket.references ├── NBehave.Spec.MbUnit ├── Extensions.cs ├── NBehave.Spec.MbUnit.csproj ├── Properties │ └── AssemblyInfo.cs ├── SpecBase.cs ├── SpecBase_generic.cs ├── SpecificationAttribute.cs └── paket.references ├── NBehave.Spec.NUnit.Specifications ├── ExtensionsSpecs.cs ├── NBehave.Spec.NUnit.Specifications.csproj ├── Properties │ └── AssemblyInfo.cs ├── SpecBaseSpecs.cs └── paket.references ├── NBehave.Spec.NUnit ├── Extensions.cs ├── NBehave.Spec.NUnit.csproj ├── Properties │ └── AssemblyInfo.cs ├── SpecBase.cs ├── SpecBase_generic.cs ├── SpecificationAttribute.cs └── paket.references ├── NBehave.Spec.Xunit.Specifications ├── ExtensionsSpecs.cs ├── NBehave.Spec.Xunit.Specifications.csproj ├── Properties │ └── AssemblyInfo.cs ├── SpecBaseSpecs.cs └── paket.references ├── NBehave.Spec.Xunit ├── Extensions.cs ├── NBehave.Spec.Xunit.csproj ├── Properties │ └── AssemblyInfo.cs ├── SpecBase.cs ├── SpecBase_generic.cs ├── SpecificationAttribute.cs └── paket.references ├── NBehave.Spec ├── ActionSpecification.cs ├── IActionSpecification.cs ├── SpecBase.cs ├── SpecBase_generic.cs └── ThrowingAction.cs ├── NBehave.Specifications ├── ActionCatalogSpec.cs ├── ActionStepAttributeSpec.cs ├── ActionStepCodeGeneratorSpec.cs ├── ActionStepParserSpec.cs ├── ConfigurationNoAppDomain.cs ├── Domain │ ├── ActionMethodInfoSpec.cs │ ├── ExampleBuilderSpec.cs │ ├── ExampleTableFormatterSpec.cs │ ├── FeatureSpec.cs │ ├── ScenarioSpec.cs │ └── StringTableStepSpec.cs ├── EmbeddedRunnerSpec.cs ├── EventListeners │ ├── CodeGenEventListenerSpec.cs │ ├── ColorfulConsoleOutputEventListenerSpec.cs │ ├── FailSpecResultEventListenerSpec.cs │ ├── MultiOutputEventListenerSpec.cs │ ├── XmlOutputEventListenerSpec.cs │ └── XmlOutputWriterSpec.cs ├── ExampleSpec.cs ├── Extensions │ ├── ActionStepConverterExtensionsSpec.cs │ └── StoryRunnerFilterExtensionsSpec.cs ├── Features │ ├── FeatureInSwedish.feature │ ├── FeatureNamedStory.feature │ ├── FeatureWithCommentOnLastRow.feature │ ├── FeatureWithFailingStep.feature │ ├── FeatureWithLowerCaseSteps.feature │ ├── FeatureWithManyScenarios.feature │ ├── FeatureWithNewLineInGivenClause.feature │ ├── FeatureWithPendingStep.feature │ ├── FeatureWithTags.feature │ ├── FeaturesAndScenarios.feature │ ├── ScenarioWithExamples.feature │ ├── ScenarioWithNoActionSteps.feature │ ├── ScenarioWithTables.feature │ ├── ScenariosWithoutFeature.feature │ └── TestFeatures.cs ├── HooksSpec.cs ├── IgnoreSpaceAndUnderScoreMatcherSpec.cs ├── Internal │ ├── ContextHandlerSpec.cs │ └── FeatureRunnerSpec.cs ├── LoadAndParseScenarioFilesSpec.cs ├── NBehave.Specifications.csproj ├── ParameterConverterSpec.cs ├── Properties │ └── AssemblyInfo.cs ├── RemotableStoryRunnerSpec.cs ├── ScenarioContextSpec.cs ├── ScenarioParserSpec.cs ├── ScenarioResultSpec.cs ├── ScenarioStepRunnerSpec.cs ├── StoryRunnerFilterSpecs.cs ├── StringExtensionsSpec.cs ├── StringStepRunnerSpec.cs ├── StringStepSpec.cs ├── SummaryWriterSpec.cs ├── System.Specs │ ├── Backgrounds │ │ ├── Background.feature │ │ └── WhenRunningAScenarioWithABackgroundSection.cs │ ├── Examples │ │ ├── Examples.feature │ │ ├── ExamplesWithPendingSteps.feature │ │ ├── WhenRunningAScenarioWithExamples.cs │ │ └── WhenRunningAScenarioWithExamplesButNoActionSteps.cs │ ├── ExamplesWithTables │ │ ├── ExamplesWithTables.feature │ │ └── WhenRunningAScenarioWithExamples.cs │ ├── Scenarios │ │ ├── Scenario.feature │ │ ├── ScenarioWithArguments.feature │ │ ├── ScenarioWithFailingStep.feature │ │ ├── ScenarioWithoutFeature.feature │ │ ├── WhenRunningAScenario.cs │ │ ├── WhenRunningAScenarioWithAFailingStep.cs │ │ ├── WhenRunningAScenarioWithArguments.cs │ │ └── WhenRunningAScenarioWithoutAFeature.cs │ ├── SystemTestContext.cs │ ├── Tables │ │ ├── TableScenario.feature │ │ └── WhenRunningATableScenario.cs │ └── Tags │ │ ├── Tags.feature │ │ └── WhenRunningAScenario.cs ├── Text │ ├── ExampleColumnsSpec.cs │ └── ExampleSpec.cs ├── TextParsing │ ├── GroupEventsByTagSpec.cs │ ├── StepBuilderSpec.cs │ ├── TagFilterBuilderSpec.cs │ └── TagFilterSpec.cs ├── TextRunnerSpec.cs └── paket.references ├── NBehave.sln ├── NBehave.snk ├── NBehave ├── Attributes │ ├── ActionStepAttribute.cs │ ├── ActionStepsAttribute.cs │ ├── GivenAttribute.cs │ ├── ThenAttribute.cs │ └── WhenAttribute.cs ├── Configuration │ └── NBehaveConfiguration.cs ├── Contracts │ ├── IFileMatcher.cs │ └── IMatchFiles.cs ├── Domain │ ├── ActionMethodInfo.cs │ ├── BackgroundStepResult.cs │ ├── ColumnValues.cs │ ├── Example.cs │ ├── ExampleBuilder.cs │ ├── ExampleColumn.cs │ ├── ExampleColumns.cs │ ├── ExampleTableFormatter.cs │ ├── Feature.cs │ ├── FeatureResult.cs │ ├── Result.cs │ ├── Scenario.cs │ ├── ScenarioExampleResult.cs │ ├── ScenarioResult.cs │ ├── StepResult.cs │ ├── StringStep.cs │ ├── StringTableStep.cs │ ├── TypeOfStep.cs │ └── WrappedException.cs ├── EmbeddedRunner.cs ├── EventListeners │ ├── BackgroundWriter.cs │ ├── CodeGeneration │ │ ├── ActionStepCodeGenerator.cs │ │ └── CodeGenEventListener.cs │ ├── ConsoleWriter.cs │ ├── EventListener.cs │ ├── EventListeners.cs │ ├── FailSpecResultEventListener.cs │ ├── IEventListener.cs │ ├── IOutputWriter.cs │ ├── MultiOutputEventListener.cs │ ├── NullEventListener.cs │ ├── OutputEventListener.cs │ ├── SummaryWriter.cs │ ├── TextWriterEventListener.cs │ └── Xml │ │ ├── EventReceived.cs │ │ ├── EventType.cs │ │ ├── StoryResultsEventReceived.cs │ │ ├── XmlOutputEventListener.cs │ │ └── XmlOutputWriter.cs ├── Extensions │ ├── ActionStepConverterExtensions.cs │ ├── EnumerableExtensions.cs │ ├── NBehaveConfigurationExtensions.cs │ ├── ReflectionExtensions.cs │ ├── StoryRunnerFilterExtensions.cs │ └── StringExtensions.cs ├── FeatureContext.cs ├── Hooks │ ├── AfterFeatureAttribute.cs │ ├── AfterRunAttribute.cs │ ├── AfterScenarioAttribute.cs │ ├── AfterStepAttribute.cs │ ├── BeforeFeatureAttribute.cs │ ├── BeforeRunAttribute.cs │ ├── BeforeScenarioAttribute.cs │ ├── BeforeStepAttribute.cs │ ├── HookAttribute.cs │ ├── HooksAttribute.cs │ ├── HooksHandler.cs │ ├── HooksParser.cs │ └── LoadHooks.cs ├── IgnoreSpaceAndUnderScoreMatcher.cs ├── Internal │ ├── ActionCatalog.cs │ ├── ActionStepParser.cs │ ├── ContextHandler.cs │ ├── EventArgs.cs │ ├── ExampleRunner.cs │ ├── FeatureRunner.cs │ ├── Gherkin │ │ ├── GherkinListener.cs │ │ ├── IListener.cs │ │ ├── LineInFile.cs │ │ ├── ParseException.cs │ │ ├── Parser.cs │ │ ├── StepKind.cs │ │ └── Token.cs │ ├── IContextHandler.cs │ ├── IFeatureRunner.cs │ ├── IRunContext.cs │ ├── IRunContextEvents.cs │ ├── IRunner.cs │ ├── IStringStepRunner.cs │ ├── LoadScenarioFiles.cs │ ├── MethodWithAttributeFinder.cs │ ├── NBehaveContext.cs │ ├── NBehaveInitializer.cs │ ├── ParameterConverter.cs │ ├── ParseScenarioFiles.cs │ ├── PlainTextOutput.cs │ ├── ResharperCodeAnnotations.cs │ ├── RunContext.cs │ ├── RunnerFactory.cs │ ├── StoryRunnerFilter.cs │ ├── StringStepRunner.cs │ ├── TextRunner.cs │ └── TypeConverter.cs ├── MatchAllFiles.cs ├── NBehave.csproj ├── Properties │ └── AssemblyInfo.cs ├── Remoting │ ├── AppDomainBootstrapper.cs │ ├── AppDomainRunner.cs │ └── RemotableStoryRunner.cs ├── ScenarioContext.cs ├── StepContext.cs ├── TextParsing │ ├── GherkinEvent.cs │ ├── GherkinScenarioParser.cs │ ├── GroupEventsByFeature.cs │ ├── GroupEventsByTag.cs │ ├── ModelBuilders │ │ ├── ExamplesBuilder.cs │ │ ├── FeatureBuilder.cs │ │ └── StepBuilder.cs │ ├── TagFilter │ │ └── TagFilter.cs │ └── TagFilterBuilder.cs └── paket.references ├── TestLib ├── ConfigFileActionSteps.fs ├── GreetingSystemSteps.fs ├── HelloSteps.fs ├── TestLib.fsproj └── paket.references └── xsl └── NBehaveResults.xsl /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | obj 3 | build 4 | packages 5 | 6 | _NCrunch_* 7 | *.ncrunchproject 8 | *.ncrunchsolution 9 | 10 | *_ReSharper* 11 | 12 | *.suo 13 | *.user 14 | 15 | TestResult.xml 16 | 7.1.96 17 | 8.0.* 18 | 19 | ### VisualStudioCode ### 20 | .vscode 21 | 22 | # Paket dependency manager 23 | .paket/paket.exe 24 | paket-files/ 25 | 26 | # FAKE - F# Make 27 | .fake/ 28 | 29 | -------------------------------------------------------------------------------- /.paket/paket.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nbehave/NBehave/b671008dc814f59ed15272e02e88421c543ae773/.paket/paket.exe -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | NBehave 2 | ======= 3 | NBehave is a framework for behaviour-driven development (BDD). 4 | 5 | BDD is an evolution of test-driven development (TDD) and acceptance-test driven design, and it is intended to make these practices more accessible and intuitive to newcomers and experts alike. 6 | 7 | It shifts the vocabulary from being test-based to behaviour-based and positions itself as a design philosophy. 8 | 9 | * [Project web site](http://nbehave.org) 10 | * [Documentation](https://github.com/nbehave/NBehave/wiki/Documentation) 11 | 12 | 13 | Build status 14 | ============ 15 | 16 | current build status 17 | 18 | 19 | 20 | Contribute 21 | ======= 22 | We would love your help. Send us patches, report/fix bugs, request features, etc. 23 | 24 | If you want to edit the Visual Studio extension you need to install these: 25 | [Visual Studio 2012 SDK](http://www.microsoft.com/en-us/download/confirmation.aspx?id=30668) 26 | [Visual Studio 2010 SP1 SDK](http://visualstudiogallery.msdn.microsoft.com/25622469-19d8-4959-8e5c-4025d1c9183d) 27 | 28 | 29 | Licence 30 | ======= 31 | NBehave is licensed under [BSD 3](http://opensource.org/licenses/BSD-3-Clause) 32 | -------------------------------------------------------------------------------- /build.cmd: -------------------------------------------------------------------------------- 1 | @REM ******** 2 | @REM To pass parameters 3 | @REM .\buildframework\FAKE\tools\FAKE.exe build.fsx Compile 4 | @REM ******** 5 | @echo off 6 | cls 7 | 8 | .paket\paket.exe install 9 | if errorlevel 1 ( 10 | exit /b %errorlevel% 11 | ) 12 | 13 | packages\FAKE\tools\FAKE.exe build.fsx %* 14 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if test "$OS" = "Windows_NT" 3 | then 4 | # use .Net 5 | .paket/paket.exe install 6 | exit_code=$? 7 | if [ $exit_code -ne 0 ]; then 8 | exit $exit_code 9 | fi 10 | 11 | packages/FAKE/tools/FAKE.exe $@ --fsiargs build.fsx 12 | else 13 | # use mono 14 | mono .paket/paket.exe install 15 | exit_code=$? 16 | if [ $exit_code -ne 0 ]; then 17 | exit $exit_code 18 | fi 19 | mono packages/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx 20 | fi 21 | -------------------------------------------------------------------------------- /nuget/ReSharper.feature: -------------------------------------------------------------------------------- 1 | Feature: dummy 2 | This file is here (almost) only to trigger install.ps1 for nuget, feel free to delete it. 3 | You may also try to run this file with the plugin installed, just right click in it (or on it in solution explorer) and then click on "Run Unit Tests" 4 | 5 | Scenario: dummy 6 | Given this file 7 | When you right click it and then click "Run Unit Tests" 8 | Then this file is "executed" 9 | And you should see 4 pending steps in R#'s testrunner -------------------------------------------------------------------------------- /nuget/Resharper.scripts/Install.ps1: -------------------------------------------------------------------------------- 1 | param($installPath, $toolsPath, $package, $project) 2 | 3 | $userProfileDir = get-content env:UserProfile 4 | $pluginDir = "$userProfileDir\AppData\Local\JetBrains\ReSharper\v%version%\Plugins\NBehave" 5 | New-Item $pluginDir -type directory 6 | Copy-Item "$toolsPath\ReSharper" -Destination $pluginDir -Recurse 7 | 8 | Write-Host "You need to restart Visual Studio for the R# plugin to be loaded." -BackgroundColor Black -ForegroundColor Yellow 9 | 10 | #$file = $project.ProjectItems.Item("Resharper.feature") 11 | #$file.Open() 12 | #$project.DTE.ItemOperations.OpenFile($file.Document.FullName, [EnvDTE.Constants]::vsDocumentKindText) 13 | -------------------------------------------------------------------------------- /nuget/Resharper.scripts/UnInstall.ps1: -------------------------------------------------------------------------------- 1 | param($installPath, $toolsPath, $package, $project) 2 | $userProfileDir = get-content env:UserProfile 3 | 4 | Write-Host "IMPORTANT! To uninstall this plugin you have to remove some files manually because Visual Studio and/or R# locks them." -BackgroundColor Black -ForegroundColor Yellow 5 | Write-Host "After this script has finished, the package is uninstalled but not the plugin." -BackgroundColor Black -ForegroundColor Yellow 6 | Write-Host "If you want to uninstall the plugin you have to manually delete the folder '$userProfileDir\AppData\Local\JetBrains\ReSharper\v%version%\Plugins\NBehave'" -BackgroundColor Black -ForegroundColor Yellow 7 | Write-Host "Press any key to uninstall package" -BackgroundColor Black -ForegroundColor Yellow 8 | 9 | $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") -------------------------------------------------------------------------------- /nuget/Samples/Calculator.cs.pp: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace $rootnamespace$ 4 | { 5 | public class Calculator 6 | { 7 | private readonly Queue buffer = new Queue(); 8 | 9 | public void Enter(int number) 10 | { 11 | buffer.Enqueue(number); 12 | } 13 | 14 | public void Add() 15 | { 16 | buffer.Enqueue(buffer.Dequeue() + buffer.Dequeue()); 17 | } 18 | 19 | public int Value() 20 | { 21 | return buffer.Peek(); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /nuget/Samples/FluentExampleWithImplementationInBaseClass.cs.pp: -------------------------------------------------------------------------------- 1 | using NBehave; 2 | using NBehave.Fluent.Framework.Extensions; 3 | using NBehave.Fluent.Framework.NUnit; 4 | using NBehave.Spec.NUnit; 5 | using NUnit.Framework; 6 | 7 | namespace $rootnamespace$ 8 | { 9 | [TestFixture] 10 | public class FluentExampleWithImplementationInBaseClass : CalculatorAdditionSpec 11 | { 12 | protected override Feature CreateFeature() 13 | { 14 | return new Feature("addition of two numbers") 15 | .AddStory() 16 | .AsA("user") 17 | .IWant("my calculator to add number together") 18 | .SoThat("I don't need to try and do it in my head"); 19 | } 20 | 21 | [Test] 22 | public void should_add_1_plus_1_correctly() 23 | { 24 | var stepHelper = this; 25 | Feature.AddScenario() 26 | .WithHelperObject(stepHelper) 27 | .Given("a calculator") 28 | .And("I have entered 1 into the calculator") 29 | .And("I have entered 1 into the calculator") 30 | .When("I add the numbers") 31 | .Then("the sum should be 2"); 32 | } 33 | } 34 | 35 | public abstract class CalculatorAdditionSpec : ScenarioDrivenSpecBase 36 | { 37 | private Calculator _calculator; 38 | 39 | protected void Given_a_calculator() 40 | { 41 | _calculator = new Calculator(); 42 | } 43 | 44 | protected void Given_I_have_entered_1_into_the_calculator() 45 | { 46 | _calculator.Enter(1); 47 | } 48 | 49 | protected void When_I_add_the_numbers() 50 | { 51 | _calculator.Add(); 52 | } 53 | 54 | protected void Then_the_sum_should_be_2() 55 | { 56 | _calculator.Value().ShouldEqual(2); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /nuget/Samples/FluentExampleWithInlineImplementation.cs.pp: -------------------------------------------------------------------------------- 1 | using NBehave; 2 | using NBehave.Fluent.Framework.Extensions; 3 | using NBehave.Fluent.Framework.NUnit; 4 | using NBehave.Spec.NUnit; 5 | using NUnit.Framework; 6 | 7 | namespace $rootnamespace$ 8 | { 9 | [TestFixture] 10 | public class FluentExampleWithInlineImplementation : ScenarioDrivenSpecBase 11 | { 12 | protected override Feature CreateFeature() 13 | { 14 | return new Feature("addition of two numbers") 15 | .AddStory() 16 | .AsA("user") 17 | .IWant("my calculator to add number together") 18 | .SoThat("I don't need to try and do it in my head"); 19 | } 20 | 21 | [Test] 22 | public void should_add_1_plus_1_correctly() 23 | { 24 | Calculator calculator = null; 25 | 26 | Feature.AddScenario() 27 | .Given("a calculator", () => calculator = new Calculator()) 28 | .And("I have entered 1 into the calculator", () => calculator.Enter(1)) 29 | .And("I have entered 1 into the calculator", () => calculator.Enter(1)) 30 | .When("I add the numbers", () => calculator.Add()) 31 | .Then("the sum should be 2", () => calculator.Value().ShouldEqual(2)); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /nuget/Samples/Gherkin/EmbeddedExample.cs.pp: -------------------------------------------------------------------------------- 1 | using NBehave; 2 | using NUnit.Framework; 3 | 4 | namespace $rootnamespace$.Gherkin 5 | { 6 | [TestFixture] 7 | public class Embedded 8 | { 9 | [Test] 10 | public void Should_Run_feature_file() 11 | { 12 | @"..\..\Gherkin\simple.feature".ExecuteFile(GetType().Assembly); 13 | } 14 | 15 | [Test] 16 | public void Should_Run_feature_text() 17 | { 18 | @"Feature: a small example with tables and examples 19 | As a [role] 20 | I want [feature] 21 | So that [benefit] 22 | 23 | Scenario: Add item to list 24 | Given an empty list 25 | When I add foo to list 26 | Then the list should contain foo 27 | ".ExecuteText(GetType().Assembly); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /nuget/Samples/Gherkin/Examples.cs.pp: -------------------------------------------------------------------------------- 1 | using NBehave; 2 | using NBehave.Spec.NUnit; 3 | 4 | namespace $rootnamespace$.Gherkin 5 | { 6 | [ActionSteps] 7 | public class ExamplesSteps 8 | { 9 | int cucumbers; 10 | 11 | [Given("there are $start cucumbers")] 12 | public void GivenCucumbers(int start) 13 | { 14 | cucumbers = start; 15 | } 16 | 17 | [When("I eat $x cucumbers")] 18 | public void EatCucumbers(int x) 19 | { 20 | cucumbers -= x; 21 | } 22 | 23 | [Then("I should have $y cucumbers")] 24 | public void CucumbersLeft(int y) 25 | { 26 | cucumbers.ShouldEqual(y); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /nuget/Samples/Gherkin/Examples.feature: -------------------------------------------------------------------------------- 1 | Feature: Example 2 | This narrative text do not have to follow any particular format, use what fits you. 3 | Parameters (like ) in table scenarios can be written as [start], $start or 4 | In Gherkin syntax examples usually have "Scenario Outline" which you can use, but in nbehave you can use "Scenario" as we have done in this example, 5 | you can use whichever you want. 6 | 7 | Scenario: eating 8 | Given there are cucumbers 9 | When I eat cucumbers 10 | Then I should have cucumbers 11 | 12 | Examples: 13 | | start | eat | left | 14 | | 12 | 5 | 7 | 15 | | 20 | 5 | 15 | -------------------------------------------------------------------------------- /nuget/Samples/Gherkin/GameOfLife.cs.pp: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace $rootnamespace$.Gherkin 4 | { 5 | public class GameOfLife 6 | { 7 | private readonly bool[,] board; 8 | 9 | public GameOfLife(int width, int height) 10 | { 11 | board = new bool[width, height]; 12 | } 13 | 14 | public void ToggleCell(int x, int y) 15 | { 16 | board[x, y] = board[x, y] == false; 17 | } 18 | 19 | public override string ToString() 20 | { 21 | var board = string.Empty; 22 | 23 | for (var y = 0; y <= this.board.GetUpperBound(1); y++) 24 | { 25 | for (var x = 0; x <= this.board.GetUpperBound(0); x++) 26 | { 27 | if (this.board[x, y]) 28 | board += "X"; 29 | else 30 | board += "."; 31 | } 32 | if (y < this.board.GetUpperBound(1)) 33 | board += Environment.NewLine; 34 | } 35 | return board; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /nuget/Samples/Gherkin/GameOfLife.feature: -------------------------------------------------------------------------------- 1 | Feature: Game of life 2 | 3 | 4 | Scenario: Empty game 5 | Given a new game: 5 by 5 6 | Then the grid should be 7 | ..... 8 | ..... 9 | ..... 10 | ..... 11 | ..... 12 | 13 | Scenario: I can toggle a cell 14 | 15 | Given a 5 by 5 game 16 | When I toggle the cell at (2, 3) 17 | Then the grid should look like 18 | ..... 19 | ..... 20 | ..... 21 | ..X.. 22 | ..... 23 | When I toggle the cell at (2, 4) 24 | Then the grid should look like 25 | ..... 26 | ..... 27 | ..... 28 | ..X.. 29 | ..X.. 30 | When I toggle the cell at (2, 3) 31 | Then the grid should look like 32 | ..... 33 | ..... 34 | ..... 35 | ..... 36 | ..X.. 37 | -------------------------------------------------------------------------------- /nuget/Samples/Gherkin/GameOfLifeSteps.cs.pp: -------------------------------------------------------------------------------- 1 | using NBehave; 2 | using NBehave.Spec.NUnit; 3 | 4 | namespace $rootnamespace$.Gherkin 5 | { 6 | [ActionSteps] 7 | public class GameOfLifeSteps 8 | { 9 | private GameOfLife game; 10 | 11 | [Given(@"a $width by $height game")] 12 | [Given(@"a new game: $width by $height")] 13 | public void GameOfLife(int width, int height) 14 | { 15 | game = new GameOfLife(width, height); 16 | } 17 | 18 | [When(@"I toggle the cell at ($x, $y)")] 19 | public void ToggleCell(int x, int y) 20 | { 21 | game.ToggleCell(x, y); 22 | } 23 | 24 | [Then(@"the grid should look like\s+(?(.+\s*)+)")] 25 | [Then(@"the grid should be\s+(?(.+\s*)+)")] 26 | public void GameLooksLike(string rows) 27 | { 28 | game.ToString().ShouldEqual(rows); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /nuget/Samples/Gherkin/Language.cs.pp: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NBehave; 3 | 4 | namespace $rootnamespace$.Gherkin 5 | { 6 | [ActionSteps] 7 | public class LanguageSteps 8 | { 9 | // You should also try to put these attributes on the step methods in Simple.cs 10 | // You can have multiple step attributes on one method 11 | 12 | [Given("en tom lista")] 13 | public void EmptyList() 14 | { 15 | ScenarioContext.Current.Add("list", new List()); 16 | } 17 | 18 | [When("jag lägger till $x till listan")] 19 | public void AddToList(string x) 20 | { 21 | var list = ScenarioContext.Current.Get>("list"); 22 | list.Add(x); 23 | } 24 | 25 | [Then("ska listan innehålla $y")] 26 | public void ListShouldContain(string y) 27 | { 28 | var list = ScenarioContext.Current.Get>("list"); 29 | NUnit.Framework.CollectionAssert.Contains(list, y); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /nuget/Samples/Gherkin/Language.feature: -------------------------------------------------------------------------------- 1 | # language: sv 2 | Egenskap: Different languages 3 | nbehave supports a variety of languages, see the Gherkin project for full list of languages 4 | 5 | Scenario: a different language 6 | Givet en tom lista 7 | När jag lägger till foo till listan 8 | Så ska listan innehålla foo -------------------------------------------------------------------------------- /nuget/Samples/Gherkin/Simple.cs.pp: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NBehave; 3 | 4 | namespace $rootnamespace$.Gherkin 5 | { 6 | [ActionSteps] 7 | public class SimpleSteps 8 | { 9 | [Given("an empty list")] 10 | public void EmptyList() 11 | { 12 | ScenarioContext.Current.Add("list", new List()); 13 | } 14 | 15 | [When("I add $x to list")] 16 | public void AddToList(string x) 17 | { 18 | var list = ScenarioContext.Current.Get>("list"); 19 | list.Add(x); 20 | } 21 | 22 | [Then("the list should contain $y")] 23 | public void ListShouldContain(string y) 24 | { 25 | var list = ScenarioContext.Current.Get>("list"); 26 | NUnit.Framework.CollectionAssert.Contains(list, y); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /nuget/Samples/Gherkin/Simple.feature: -------------------------------------------------------------------------------- 1 | Feature: a small example with tables and examples 2 | As a [role] 3 | I want [feature] 4 | So that [benefit] 5 | 6 | # This is a comment line and will be ignored. 7 | 8 | Scenario: Add item to list 9 | Given an empty list 10 | When I add foo to list 11 | Then the list should contain foo 12 | -------------------------------------------------------------------------------- /nuget/Samples/Gherkin/Tables.cs.pp: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using NBehave; 4 | using NUnit.Framework; 5 | 6 | namespace $rootnamespace$.Gherkin 7 | { 8 | public class Contact 9 | { 10 | public string Name {get; set; } 11 | public string Country {get; set; } 12 | } 13 | 14 | [ActionSteps] 15 | public class TablesSteps 16 | { 17 | [Given("a list of contacts:")] 18 | public void Contacts(List contacts) 19 | { 20 | ScenarioContext.Current.Add("contacts", contacts); 21 | } 22 | 23 | [When("I search for contacts from $country")] 24 | public void Search(string country) 25 | { 26 | var contacts = ScenarioContext.Current.Get>("contacts"); 27 | var found = contacts.Where(_=>_.Country == country).ToList(); 28 | ScenarioContext.Current.Add("found", found); 29 | } 30 | 31 | [Then("I should find:")] 32 | public void ContactsFound(List expected) 33 | { 34 | var found = ScenarioContext.Current.Get>("found"); 35 | CollectionAssert.AreEquivalent(expected, found); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /nuget/Samples/Gherkin/Tables.feature: -------------------------------------------------------------------------------- 1 | Feature: tables 2 | This narrative text do not have to follow any particular format, use what fits you. 3 | Parameters (like ) in table scenarios can be written as [start], $start or 4 | In Gherkin syntax examples usually have "Scenario Outline" which you can use, but in nbehave you can use "Scenario" as we have done in this example, 5 | you can use whichever you want. 6 | 7 | Scenario: a table 8 | 9 | Given a list of contacts: 10 | | Name | Country | 11 | |Morgan Persson | Sweden | 12 | |Jimmy Nilsson | Sweden | 13 | |Jimmy Bogard | USA | 14 | 15 | When I search for contacts from Sweden 16 | 17 | Then I should find: 18 | | Name | Country | 19 | | Morgan Persson | Sweden | 20 | | Jimmy Nilsson | Sweden | -------------------------------------------------------------------------------- /nuget/Samples/SpecExample.cs.pp: -------------------------------------------------------------------------------- 1 | using NBehave.Spec.NUnit; 2 | using NUnit.Framework; 3 | 4 | namespace $rootnamespace$ 5 | { 6 | public class SpecExample 7 | { 8 | [Test] 9 | public void Some_extension_methods_you_can_use() 10 | { 11 | true.ShouldBeTrue(); 12 | false.ShouldBeFalse(); 13 | 1.ShouldEqual(1); 14 | 2.ShouldNotEqual(1); 15 | new int[]{1, 2, 3, 5, 8, 13}.ShouldContain(5); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /nuget/Samples/__ReadMe__.txt: -------------------------------------------------------------------------------- 1 | Files: 2 | Gherkin\Simple.feature - A very simple feature file 3 | Gherkin\Simple.cs - Step implementations for steps in the above feature file 4 | 5 | FluentExample.cs - contains example(s) of how to use the fluent example 6 | SpecSample.cs - contains a few examples of extension methods you can use to assert outcomes. 7 | 8 | The Spec samples are based on nunit but you may use xunit, mbunit or mstest if you want. choose the one that suits you best. 9 | The same is true for the fluent samples. 10 | 11 | To run the features, just go to the same package manager console where you installed the samples and run. 12 | .\packages\nbehave.0.1.0.0\tools\net46\NBehave-Console.exe .\bin\debug\YourTestProjectAssembly.dll /sf=Gherkin\*.feature 13 | 14 | You will have to change 0.1.0.0 to the version of nbehave you installed, and you will have to change .\bin\debug\YourTestProjectAssembly.dll to point to the dll that will be created when you compile the samples. 15 | 16 | For more info goto https://github.com/nbehave/NBehave 17 | 18 | -------------------------------------------------------------------------------- /nuget/VsPlugin.feature: -------------------------------------------------------------------------------- 1 | Feature: dummy 2 | This file is here (almost) only to trigger install.ps1 for nuget, feel free to delete it. 3 | You may also try to run this file with the plugin installed. 4 | 5 | Scenario: dummy 6 | Given this file 7 | When you right click this file and then click "Run Scenario" 8 | # or click the green dot with the arrow to the left 9 | Then this file is "executed" 10 | And you should see 4 pending steps in the output window -------------------------------------------------------------------------------- /nuget/VsPlugin.scripts/Install.ps1: -------------------------------------------------------------------------------- 1 | param($installPath, $toolsPath, $package, $project) 2 | & "$toolsPath\net40\VsPlugin\NBehave.VS2010.Plugin.vsix" 3 | Write-Host "You need to restart Visual Studio for the plugin to be loaded." -BackgroundColor Black -ForegroundColor Yellow 4 | 5 | $file = $project.ProjectItems.Item("VsPlugin.feature") 6 | $file.Open() 7 | $project.DTE.ItemOperations.OpenFile($file.Document.FullName, [EnvDTE.Constants]::vsDocumentKindText) 8 | -------------------------------------------------------------------------------- /nuget/VsPlugin.scripts/UnInstall.ps1: -------------------------------------------------------------------------------- 1 | param($installPath, $toolsPath, $package, $project) 2 | 3 | Write-Host "To really uninstall this package you have to do this via the Extension Mananger in the Tools menu." -BackgroundColor Black -ForegroundColor Yellow 4 | Write-Host "Press any key to uninstall package" -BackgroundColor Black -ForegroundColor Yellow 5 | 6 | $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") -------------------------------------------------------------------------------- /nuget/nbehave.fluent.mbunit.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | nbehave.fluent.mbunit 5 | $version$ 6 | NBehave Fluent - MbUnit 7 | NBehave 8 | NBehave 9 | http://www.opensource.org/licenses/bsd-license.php 10 | http://nbehave.org/ 11 | http://static.tumblr.com/z2xvmc8/mhzlb82x5/logo.png 12 | false 13 | Fluent interface for writing BDD scenarios 14 | 15 | Copyright © NBehave 2007-2018 16 | en-US 17 | nbehave bdd atdd 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /nuget/nbehave.fluent.mstest.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | nbehave.fluent.mstest 5 | $version$ 6 | NBehave Fluent - MsTest 7 | NBehave 8 | NBehave 9 | http://www.opensource.org/licenses/bsd-license.php 10 | http://nbehave.org/ 11 | http://static.tumblr.com/z2xvmc8/mhzlb82x5/logo.png 12 | false 13 | Fluent interface for writing BDD scenarios 14 | 15 | Copyright © NBehave 2007-2018 16 | en-US 17 | nbehave bdd atdd 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /nuget/nbehave.fluent.nunit.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | nbehave.fluent.nunit 5 | $version$ 6 | NBehave Fluent - NUnit 7 | NBehave 8 | NBehave 9 | http://www.opensource.org/licenses/bsd-license.php 10 | http://nbehave.org/ 11 | http://static.tumblr.com/z2xvmc8/mhzlb82x5/logo.png 12 | false 13 | Fluent interface for writing BDD scenarios 14 | 15 | Copyright © NBehave 2007-2018 16 | en-US 17 | nbehave bdd atdd 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /nuget/nbehave.fluent.xunit.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | nbehave.fluent.xunit 5 | $version$ 6 | NBehave Fluent - XUnit 7 | NBehave 8 | NBehave 9 | http://www.opensource.org/licenses/bsd-license.php 10 | http://nbehave.org/ 11 | http://static.tumblr.com/z2xvmc8/mhzlb82x5/logo.png 12 | false 13 | Fluent interface for writing BDD scenarios 14 | 15 | Copyright © NBehave 2007-2018 16 | en-US 17 | nbehave bdd atdd 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /nuget/nbehave.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | nbehave 5 | $version$ 6 | NBehave 7 | NBehave 8 | NBehave 9 | http://www.opensource.org/licenses/bsd-license.php 10 | http://nbehave.org/ 11 | http://static.tumblr.com/z2xvmc8/mhzlb82x5/logo.png 12 | false 13 | Simple approach to Behaviour Driven Development for .NET projects. 14 | 15 | Copyright © NBehave 2007-2018 16 | en-US 17 | nbehave bdd atdd gherkin cucumber 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /nuget/nbehave.resharper71.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | nbehave.resharper71 5 | $version$ 6 | NBehave Resharper 7.1 7 | NBehave 8 | NBehave 9 | http://www.opensource.org/licenses/bsd-license.php 10 | http://nbehave.org/ 11 | http://static.tumblr.com/z2xvmc8/mhzlb82x5/logo.png 12 | false 13 | Resharper 7.1 plugin for nbehave so that you can run and debug your features from Visual Studio 14 | 15 | Copyright © NBehave 2007-2013 16 | en-US 17 | nbehave bdd atdd gherkin cucumber resharper 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /nuget/nbehave.resharper711.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | nbehave.resharper711 5 | $version$ 6 | NBehave Resharper 7.1.1 7 | NBehave 8 | NBehave 9 | http://www.opensource.org/licenses/bsd-license.php 10 | http://nbehave.org/ 11 | http://static.tumblr.com/z2xvmc8/mhzlb82x5/logo.png 12 | false 13 | Resharper 7.1.1 plugin for nbehave so that you can run and debug your features from Visual Studio 14 | 15 | Copyright © NBehave 2007-2013 16 | en-US 17 | nbehave bdd atdd gherkin cucumber resharper 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /nuget/nbehave.resharper712.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | nbehave.resharper712 5 | $version$ 6 | NBehave Resharper 7.1.2 7 | NBehave 8 | NBehave 9 | http://www.opensource.org/licenses/bsd-license.php 10 | http://nbehave.org/ 11 | http://static.tumblr.com/z2xvmc8/mhzlb82x5/logo.png 12 | false 13 | Resharper 7.1.2 plugin for nbehave so that you can run and debug your features from Visual Studio 14 | 15 | Copyright © NBehave 2007-2013 16 | en-US 17 | nbehave bdd atdd gherkin cucumber resharper 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /nuget/nbehave.resharper80.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | nbehave.resharper8.0 5 | $version$ 6 | NBehave Resharper 8.0 7 | NBehave 8 | NBehave 9 | http://www.opensource.org/licenses/bsd-license.php 10 | http://nbehave.org/ 11 | http://static.tumblr.com/z2xvmc8/mhzlb82x5/logo.png 12 | false 13 | Resharper 8.0 plugin for nbehave so that you can run and debug your features from Visual Studio 14 | 15 | Copyright © NBehave 2007-2013 16 | en-US 17 | nbehave bdd atdd gherkin cucumber resharper 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /nuget/nbehave.runners.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | nbehave.runners 5 | $version$ 6 | NBehave Runners 7 | NBehave 8 | NBehave 9 | http://www.opensource.org/licenses/bsd-license.php 10 | http://nbehave.org/ 11 | http://static.tumblr.com/z2xvmc8/mhzlb82x5/logo.png 12 | false 13 | Simple approach to Behaviour Driven Development for .NET projects. 14 | 15 | Copyright © NBehave 2007-2018 16 | en-US 17 | nbehave bdd atdd gherkin cucumber 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /nuget/nbehave.samples.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | nbehave.samples 5 | $version$ 6 | NBehave samples 7 | NBehave 8 | NBehave 9 | http://www.opensource.org/licenses/bsd-license.php 10 | http://nbehave.org/ 11 | http://static.tumblr.com/z2xvmc8/mhzlb82x5/logo.png 12 | false 13 | This package contains samples that demonstrate the use of nbehave 14 | 15 | Copyright © NBehave 2007-2018 16 | en-US 17 | nbehave bdd atdd gherkin cucumber sample 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /nuget/nbehave.spec.mbunit.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | nbehave.spec.mbunit 5 | $version$ 6 | NBehave Spec - MbUnit 7 | NBehave 8 | NBehave 9 | http://www.opensource.org/licenses/bsd-license.php 10 | http://nbehave.org/ 11 | http://static.tumblr.com/z2xvmc8/mhzlb82x5/logo.png 12 | false 13 | Extension methods for asserts for a more readable assert. 14 | Ex: 1.ShouldNotBeEqualTo(2) 15 | 16 | Copyright © NBehave 2007-2018 17 | en-US 18 | nbehave bdd atdd tdd 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /nuget/nbehave.spec.mstest.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | nbehave.spec.mstest 5 | $version$ 6 | NBehave Spec - MsTest 7 | NBehave 8 | NBehave 9 | http://www.opensource.org/licenses/bsd-license.php 10 | http://nbehave.org/ 11 | http://static.tumblr.com/z2xvmc8/mhzlb82x5/logo.png 12 | false 13 | Extension methods for asserts for a more readable assert. 14 | Ex: 1.ShouldNotBeEqualTo(2) 15 | 16 | Copyright © NBehave 2007-2018 17 | en-US 18 | nbehave bdd atdd tdd 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /nuget/nbehave.spec.nunit.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | nbehave.spec.nunit 5 | $version$ 6 | NBehave Spec - NUnit 7 | NBehave 8 | NBehave 9 | http://www.opensource.org/licenses/bsd-license.php 10 | http://nbehave.org/ 11 | http://static.tumblr.com/z2xvmc8/mhzlb82x5/logo.png 12 | false 13 | Extension methods for asserts for a more readable assert. 14 | Ex: 1.ShouldNotBeEqualTo(2) 15 | 16 | Copyright © NBehave 2007-2018 17 | en-US 18 | nbehave bdd atdd tdd 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /nuget/nbehave.spec.xunit.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | nbehave.spec.xunit 5 | $version$ 6 | NBehave Spec - XUnit 7 | NBehave 8 | NBehave 9 | http://www.opensource.org/licenses/bsd-license.php 10 | http://nbehave.org/ 11 | http://static.tumblr.com/z2xvmc8/mhzlb82x5/logo.png 12 | false 13 | Extension methods for asserts for a more readable assert. 14 | Ex: 1.ShouldNotBeEqualTo(2) 15 | 16 | Copyright © NBehave 2007-2018 17 | en-US 18 | nbehave bdd atdd tdd 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /nuget/nbehave.vsplugin.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | nbehave.vsplugin 5 | $version$ 6 | NBehave Visual Studio plugin 7 | NBehave 8 | NBehave 9 | http://www.opensource.org/licenses/bsd-license.php 10 | http://nbehave.org/ 11 | http://static.tumblr.com/z2xvmc8/mhzlb82x5/logo.png 12 | false 13 | Simple approach to Behaviour Driven Development for .NET projects. 14 | 15 | Copyright © NBehave 2007-2012 16 | en-US 17 | nbehave bdd atdd gherkin cucumber resharper 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /paket.dependencies: -------------------------------------------------------------------------------- 1 | source https://www.nuget.org/api/v2 2 | nuget fake 3 | nuget FSharp.Core 4 | nuget GurkBurk ~> 2.0.0 5 | nuget mbunit = 3.4.14 6 | nuget Mono.Reflection ~> 1.1.0 restriction: >= net40 7 | nuget NuGet.CommandLine ~> 4.6.2 8 | nuget NUnit = 3.9.0 restriction: >= net40 9 | nuget NUnit.ConsoleRunner ~> 3.8.0 10 | nuget RhinoMocks = 3.6.1 11 | nuget Should ~> 1.1.12.0 12 | nuget xunit = 2.3.0 13 | nuget MSTest.TestFramework = 1.2.0 14 | nuget TinyIoC ~> 1.3.0 15 | -------------------------------------------------------------------------------- /src/CommonAssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: ComVisible(false)] 5 | [assembly: AssemblyDescription("NBehave - BDD tool.")] 6 | [assembly: AssemblyTrademark("")] 7 | [assembly: AssemblyCulture("")] 8 | [assembly: AssemblyVersion("0.7.0.0")] 9 | [assembly: AssemblyFileVersion("0.7.0.0")] 10 | [assembly: AssemblyInformationalVersion("0.7.0-devlocal0000")] 11 | [assembly: AssemblyCopyright("Copyright © NBehave 2007-2018")] 12 | [assembly: AssemblyProduct("NBehave")] 13 | [assembly: AssemblyCompany("NBehave")] 14 | [assembly: AssemblyConfiguration("release")] 15 | -------------------------------------------------------------------------------- /src/NBehave.Console.Specifications/GreetingSystem.scenario: -------------------------------------------------------------------------------- 1 | Feature: A greeting 2 | As a developer 3 | I want to be able to greet someone 4 | So that I can be friendly 5 | 6 | Scenario: Greeting 7 | Given my name is Morgan 8 | When I'm greeted 9 | Then I should be greeted with “Hello, Morgan!” -------------------------------------------------------------------------------- /src/NBehave.Console.Specifications/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("NBehave.Console.Tests")] 5 | [assembly: Guid("ad482b06-bd3b-4f83-9905-3a1f93ef3abc")] 6 | -------------------------------------------------------------------------------- /src/NBehave.Console.Specifications/paket.references: -------------------------------------------------------------------------------- 1 | NUnit -------------------------------------------------------------------------------- /src/NBehave.Console/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("NBehave.Console")] 5 | [assembly: Guid("f6f9c81c-3db2-4b52-91fd-406531eea1b2")] -------------------------------------------------------------------------------- /src/NBehave.Console/paket.references: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nbehave/NBehave/b671008dc814f59ed15272e02e88421c543ae773/src/NBehave.Console/paket.references -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework.Specifications/MbUnit_ScenarioDrivenSpecBaseSpecs.cs: -------------------------------------------------------------------------------- 1 | using MbUnit.Framework; 2 | using NBehave.Fluent.Framework.Extensions; 3 | 4 | namespace NBehave.Fluent.Framework.Specifications 5 | { 6 | public abstract class MbUnit_ScenarioDrivenSpecBaseSpecs : MbUnit.ScenarioDrivenSpecBase 7 | { 8 | [TestFixture] 9 | public class ScenarioDrivenSpecBaseSpecs : MbUnit_ScenarioDrivenSpecBaseSpecs 10 | { 11 | protected override Feature CreateFeature() 12 | { 13 | return new Feature("Setting up features and scenarios") 14 | .AddStory() 15 | .AsA("developer") 16 | .IWant("to specify a feature") 17 | .SoThat("I can specify behaviour through scenarios"); 18 | } 19 | 20 | [Test] 21 | public void should_populate_the_feature_narrative() 22 | { 23 | Assert.AreEqual("As a developer, I want to specify a feature so that I can specify behaviour through scenarios", Feature.Narrative); 24 | } 25 | 26 | [Test] 27 | public void should_execute_scenarios_implemented_inline() 28 | { 29 | string detail1 = null; 30 | string detail2 = null; 31 | Feature.AddScenario() 32 | .Given("a scenario with inline implementation", () => detail1 = "implementation") 33 | .When("the scenario is executed", () => detail2 = "implementation") 34 | .Then("the implementation from Given should be called", () => Assert.IsNotNull(detail1)) 35 | .And("the implementation from When should be called", () => Assert.IsNotNull(detail2)); 36 | Assert.IsNotNull(detail1); 37 | Assert.IsNotNull(detail2); 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework.Specifications/MsTest_ScenarioDrivenSpecBaseSpecs.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using NBehave.Fluent.Framework.Extensions; 3 | 4 | namespace NBehave.Fluent.Framework.Specifications 5 | { 6 | public abstract class MsTest_ScenarioDrivenSpecBaseSpecs : MSTest.ScenarioDrivenSpecBase 7 | { 8 | [TestClass] 9 | public class ScenarioDrivenSpecBaseSpecs : MsTest_ScenarioDrivenSpecBaseSpecs 10 | { 11 | protected override Feature CreateFeature() 12 | { 13 | return new Feature("Setting up features and scenarios") 14 | .AddStory() 15 | .AsA("developer") 16 | .IWant("to specify a feature") 17 | .SoThat("I can specify behaviour through scenarios"); 18 | } 19 | 20 | [TestMethod] 21 | public void should_populate_the_feature_narrative() 22 | { 23 | Assert.AreEqual("As a developer, I want to specify a feature so that I can specify behaviour through scenarios", Feature.Narrative); 24 | } 25 | 26 | [TestMethod] 27 | public void should_execute_scenarios_implemented_inline() 28 | { 29 | string detail1 = null; 30 | string detail2 = null; 31 | Feature.AddScenario() 32 | .Given("a scenario with inline implementation", () => detail1 = "implementation") 33 | .When("the scenario is executed", () => detail2 = "implementation") 34 | .Then("the implementation from Given should be called", () => Assert.IsNotNull(detail1)) 35 | .And("the implementation from When should be called", () => Assert.IsNotNull(detail2)); 36 | Assert.IsNotNull(detail1); 37 | Assert.IsNotNull(detail2); 38 | } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework.Specifications/NUnit_ScenarioDrivenSpecBaseSpecs.cs: -------------------------------------------------------------------------------- 1 | using NBehave.Fluent.Framework.Extensions; 2 | using NUnit.Framework; 3 | 4 | namespace NBehave.Fluent.Framework.Specifications 5 | { 6 | public abstract class NUnit_ScenarioDrivenSpecBaseSpecs : NUnit.ScenarioDrivenSpecBase 7 | { 8 | [TestFixture] 9 | public class ScenarioDrivenSpecBaseSpecs : NUnit_ScenarioDrivenSpecBaseSpecs 10 | { 11 | protected override Feature CreateFeature() 12 | { 13 | return new Feature("Setting up features and scenarios") 14 | .AddStory() 15 | .AsA("developer") 16 | .IWant("to specify a feature") 17 | .SoThat("I can specify behaviour through scenarios"); 18 | } 19 | 20 | [Test] 21 | public void should_populate_the_feature_narrative() 22 | { 23 | Assert.AreEqual("As a developer, I want to specify a feature so that I can specify behaviour through scenarios", Feature.Narrative); 24 | } 25 | 26 | [Test] 27 | public void should_execute_scenarios_implemented_inline() 28 | { 29 | string detail1 = null; 30 | string detail2 = null; 31 | Feature.AddScenario() 32 | .Given("a scenario with inline implementation", () => detail1 = "implementation") 33 | .When("the scenario is executed", () => detail2 = "implementation") 34 | .Then("the implementation from Given should be called", () => Assert.IsNotNull(detail1)) 35 | .And("the implementation from When should be called", () => Assert.IsNotNull(detail2)); 36 | Assert.IsNotNull(detail1); 37 | Assert.IsNotNull(detail2); 38 | } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework.Specifications/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | 8 | [assembly : AssemblyTitle("NBehave.Spec.Framework.Specification")] 9 | [assembly : AssemblyDescription("")] 10 | [assembly : AssemblyConfiguration("")] 11 | [assembly : AssemblyCompany("World")] 12 | [assembly : AssemblyProduct("NBehave.Spec.Framework.Specification")] 13 | [assembly : AssemblyCopyright("Copyright © World 2007")] 14 | [assembly : AssemblyTrademark("")] 15 | [assembly : AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | 21 | [assembly : ComVisible(false)] 22 | 23 | // The following GUID is for the ID of the typelib if this project is exposed to COM 24 | 25 | [assembly : Guid("ba5cb57c-e439-46bd-8d6d-979563d448b0")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Revision and Build Numbers 35 | // by using the '*' as shown below: 36 | 37 | [assembly : AssemblyVersion("1.0.0.0")] 38 | [assembly : AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework.Specifications/ScenarioDrivenSpecBaseSpecs.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using NBehave.Fluent.Framework.Extensions; 3 | using NUnit.Framework; 4 | 5 | namespace NBehave.Fluent.Framework.Specifications 6 | { 7 | [TestFixture] 8 | public class ScenarioDrivenSpecBaseSpecs_WithActionSteps : ScenarioDrivenSpecBase 9 | { 10 | protected override Feature CreateFeature() 11 | { 12 | return new Feature("ScenarioDrivenSpecBase"); 13 | } 14 | 15 | [SetUp] 16 | public override void MainSetup() 17 | { 18 | base.MainSetup(); 19 | } 20 | 21 | [Test] 22 | public void PendingStepsAreDetected() 23 | { 24 | Feature.AddScenario("Detect pending steps") 25 | .WithHelperObject() 26 | .Given("A step pending implementation") 27 | .When("The spec is executed") 28 | .Then("The step should be identified") 29 | ; 30 | 31 | Assert.AreEqual(3, Feature.FindPendingSteps() 32 | .First() 33 | .Count()); 34 | } 35 | } 36 | 37 | [ActionSteps] 38 | public class ScenarioDrivenSpecBaseSpecSteps 39 | { 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework.Specifications/XUnit_ScenarioDrivenSpecBaseSpecs.cs: -------------------------------------------------------------------------------- 1 | using NBehave.Fluent.Framework.Extensions; 2 | using Xunit; 3 | 4 | namespace NBehave.Fluent.Framework.Specifications 5 | { 6 | public abstract class XUnit_ScenarioDrivenSpecBaseSpecs : Xunit.ScenarioDrivenSpecBase 7 | { 8 | public class ScenarioDrivenSpecBaseSpecs : XUnit_ScenarioDrivenSpecBaseSpecs 9 | { 10 | protected override Feature CreateFeature() 11 | { 12 | return new Feature("Setting up features and scenarios") 13 | .AddStory() 14 | .AsA("developer") 15 | .IWant("to specify a feature") 16 | .SoThat("I can specify behaviour through scenarios"); 17 | } 18 | 19 | [Fact] 20 | public void should_populate_the_feature_narrative() 21 | { 22 | Assert.Equal("As a developer, I want to specify a feature so that I can specify behaviour through scenarios", Feature.Narrative); 23 | } 24 | 25 | [Fact] 26 | public void should_execute_scenarios_implemented_inline() 27 | { 28 | string detail1 = null; 29 | string detail2 = null; 30 | Feature.AddScenario() 31 | .Given("a scenario with inline implementation", () => detail1 = "implementation") 32 | .When("the scenario is executed", () => detail2 = "implementation") 33 | .Then("the implementation from Given should be called", () => Assert.NotNull(detail1)) 34 | .And("the implementation from When should be called", () => Assert.NotNull(detail2)); 35 | } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework.Specifications/paket.references: -------------------------------------------------------------------------------- 1 | mbunit 2 | NUnit 3 | xunit 4 | MSTest.TestFramework 5 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework/ActionStepStepResolver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NBehave.Hooks; 3 | using NBehave.Internal; 4 | 5 | namespace NBehave.Fluent.Framework 6 | { 7 | public class ActionStepStepResolver : IStepResolver 8 | { 9 | private readonly object _stepHelper; 10 | private readonly ActionCatalog _actionCatalog; 11 | private readonly ActionStepParser _stepParser; 12 | private readonly ParameterConverter _parameterConverter; 13 | 14 | public ActionStepStepResolver(object stepHelper) 15 | { 16 | _stepHelper = stepHelper; 17 | _actionCatalog = new ActionCatalog(); 18 | _stepParser = new ActionStepParser(new StoryRunnerFilter(), _actionCatalog); 19 | _stepParser.FindActionStepMethods(stepHelper.GetType(), _stepHelper); 20 | _parameterConverter = new ParameterConverter(_actionCatalog); 21 | } 22 | 23 | public Action ResolveStep(StringStep stringStep) 24 | { 25 | var actionMethodInfo = _actionCatalog.GetAction(stringStep); 26 | if (actionMethodInfo == null) 27 | return null; 28 | 29 | var parameters = _parameterConverter.GetParametersForStep(stringStep); 30 | return () => 31 | { 32 | actionMethodInfo.ExecuteNotificationMethod(typeof(BeforeStepAttribute)); 33 | actionMethodInfo.MethodInfo.Invoke(_stepHelper, parameters); 34 | actionMethodInfo.ExecuteNotificationMethod(typeof(AfterStepAttribute)); 35 | }; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework/DictionaryStepResolver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace NBehave.Fluent.Framework 5 | { 6 | public class DictionaryStepResolver : IStepResolver 7 | { 8 | private readonly Dictionary inlineImplementations = new Dictionary(); 9 | 10 | public void RegisterImplementation(ScenarioFragment currentScenarioStage, string step, Action implementation) 11 | { 12 | if (implementation != null) 13 | { 14 | var stepKey = currentScenarioStage + " " + step; 15 | RegisterImpl(stepKey, implementation); 16 | RegisterImpl("And " + step, implementation); 17 | } 18 | } 19 | 20 | private void RegisterImpl(string stepKey, Action implementation) 21 | { 22 | if (inlineImplementations.ContainsKey(stepKey)) 23 | inlineImplementations.Remove(stepKey); 24 | inlineImplementations.Add(stepKey, implementation); 25 | } 26 | 27 | public Action ResolveStep(StringStep stringStep) 28 | { 29 | Action step; 30 | return inlineImplementations.TryGetValue(stringStep.Step, out step) ? step : null; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework/IAsAFragment.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.Fluent.Framework 2 | { 3 | public interface IAsAFragment 4 | { 5 | IIWantFragment AsA(string role); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework/IGivenFragment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.Fluent.Framework 4 | { 5 | public interface IGivenFragment : IScenarioFragmentBase 6 | { 7 | IWhenFragment When(string step); 8 | IWhenFragment When(string step, Action implementation); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework/IIWantFragment.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.Fluent.Framework 2 | { 3 | public interface IIWantFragment 4 | { 5 | ISoThatFragment IWant(string goal); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework/IScenarioBuilderStart.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.Fluent.Framework 4 | { 5 | public interface IScenarioBuilderStart 6 | { 7 | IGivenFragment Given(string step); 8 | IGivenFragment Given(string step, Action implementation); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework/IScenarioBuilderStartWithHelperObject.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.Fluent.Framework 2 | { 3 | public interface IScenarioBuilderStartWithHelperObject : IScenarioBuilderStart 4 | { 5 | IScenarioBuilderStart WithHelperObject(object stepHelper); 6 | IScenarioBuilderStart WithHelperObject() where T : new(); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework/IScenarioFragmentBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.Fluent.Framework 4 | { 5 | public interface IScenarioFragmentBase where T : IScenarioFragmentBase 6 | { 7 | T And(string step); 8 | T And(string step, Action implementation); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework/ISoThatFragment.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.Fluent.Framework 2 | { 3 | public interface ISoThatFragment 4 | { 5 | StoryBuilder SoThat(string reason); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework/IStepResolver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.Fluent.Framework 4 | { 5 | public interface IStepResolver 6 | { 7 | Action ResolveStep(StringStep stringStep); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework/IThenFragment.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.Fluent.Framework 2 | { 3 | public interface IThenFragment : IScenarioFragmentBase 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework/IWhenFragment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.Fluent.Framework 4 | { 5 | public interface IWhenFragment : IScenarioFragmentBase 6 | { 7 | IThenFragment Then(string step); 8 | IThenFragment Then(string step, Action implementation); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework/MSTest/ScenarioDrivenSpecBase.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace NBehave.Fluent.Framework.MSTest 4 | { 5 | [TestClass] 6 | public abstract class ScenarioDrivenSpecBase : Framework.ScenarioDrivenSpecBase 7 | { 8 | [TestInitialize] 9 | public override void MainSetup() 10 | { 11 | base.MainSetup(); 12 | } 13 | 14 | [TestCleanup] 15 | public override void MainTeardown() 16 | { 17 | base.MainTeardown(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework/MbUnit/ScenarioDrivenSpecBase.cs: -------------------------------------------------------------------------------- 1 | using MbUnit.Framework; 2 | 3 | namespace NBehave.Fluent.Framework.MbUnit 4 | { 5 | [TestFixture] 6 | public abstract class ScenarioDrivenSpecBase : Framework.ScenarioDrivenSpecBase 7 | { 8 | [FixtureSetUp] 9 | public override void MainSetup() 10 | { 11 | base.MainSetup(); 12 | } 13 | 14 | [FixtureTearDown] 15 | public override void MainTeardown() 16 | { 17 | base.MainTeardown(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework/NUnit/ScenarioDrivenSpecBase.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace NBehave.Fluent.Framework.NUnit 4 | { 5 | [TestFixture] 6 | public abstract class ScenarioDrivenSpecBase : Framework.ScenarioDrivenSpecBase 7 | { 8 | [OneTimeSetUp] 9 | public override void MainSetup() 10 | { 11 | base.MainSetup(); 12 | } 13 | 14 | [OneTimeTearDown] 15 | public override void MainTeardown() 16 | { 17 | base.MainTeardown(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("NBehave")] 5 | 6 | // The following GUID is for the ID of the typelib if this project is exposed to COM 7 | [assembly: Guid("BD064127-4A3B-40de-915D-9122E51E1FC4")] -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework/ReflectedMethodStepResolver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace NBehave.Fluent.Framework 5 | { 6 | public class ReflectedMethodStepResolver : IStepResolver 7 | { 8 | private readonly object _methodProvider; 9 | 10 | public ReflectedMethodStepResolver(object methodProvider) 11 | { 12 | _methodProvider = methodProvider; 13 | } 14 | 15 | public Action ResolveStep(StringStep stringStep) 16 | { 17 | var methodName = stringStep.Step.Replace(' ', '_'); 18 | var storyType = _methodProvider.GetType(); 19 | var method = storyType.GetMethod(methodName, BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public, 20 | null, Type.EmptyTypes, null); 21 | if (method != null) 22 | return () => method.Invoke(_methodProvider, new object[0]); 23 | 24 | return null; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework/ScenarioDrivenSpecBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Text; 4 | using NBehave.Fluent.Framework.Extensions; 5 | using Rhino.Mocks; 6 | 7 | namespace NBehave.Fluent.Framework 8 | { 9 | public abstract class ScenarioDrivenSpecBase 10 | { 11 | protected Feature Feature { get; private set; } 12 | 13 | protected abstract Feature CreateFeature(); 14 | 15 | public virtual void MainSetup() 16 | { 17 | Feature = CreateFeature(); 18 | } 19 | 20 | public virtual void MainTeardown() 21 | { 22 | var scenariosWithPendingSteps = Feature.FindPendingSteps(); 23 | if (!scenariosWithPendingSteps.Any()) 24 | return; 25 | 26 | // Some steps are still pending an implementation. Let's build up a message about them. 27 | var message = new StringBuilder(); 28 | foreach (var scenarioStruct in scenariosWithPendingSteps) 29 | { 30 | message.AppendFormat("Scenario: {0}{1}", scenarioStruct.Key.Title, Environment.NewLine); 31 | foreach (var pendingStep in scenarioStruct) 32 | { 33 | message.AppendFormat(" Step: {0}{1}", pendingStep.Step, Environment.NewLine); 34 | } 35 | message.AppendFormat(Environment.NewLine); 36 | } 37 | throw new ApplicationException("The following implementations are still pending:" + Environment.NewLine + message); 38 | } 39 | 40 | protected TType CreateDependency() 41 | where TType : class 42 | { 43 | return MockRepository.GenerateMock(); 44 | } 45 | 46 | protected TType CreateStub() 47 | where TType : class 48 | { 49 | return MockRepository.GenerateStub(); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework/Xunit/ScenarioDrivenSpecBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.Fluent.Framework.Xunit 4 | { 5 | public abstract class ScenarioDrivenSpecBase : Framework.ScenarioDrivenSpecBase, IDisposable 6 | { 7 | protected ScenarioDrivenSpecBase() 8 | { 9 | base.MainSetup(); 10 | } 11 | 12 | public void Dispose() 13 | { 14 | base.MainTeardown(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/NBehave.Fluent.Framework/paket.references: -------------------------------------------------------------------------------- 1 | mbunit 2 | Mono.Reflection 3 | NUnit 4 | RhinoMocks 5 | xunit 6 | MSTest.TestFramework 7 | -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using NBehave.Extensions; 4 | 5 | 6 | namespace NBehave.ReSharper.Plugin 7 | { 8 | public static class Extensions 9 | { 10 | 11 | public static string AsString(this IEnumerable examples) 12 | { 13 | var s = ""; 14 | examples.Each(e => s += e.ToString() + Environment.NewLine); 15 | return s; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/Properties/AssemblyInfo7.1.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | using JetBrains.Application.PluginSupport; 4 | 5 | [assembly: AssemblyTitle("NBehave.ReSharper.Plugin")] 6 | [assembly: Guid("0FB76103-6201-46BD-8C84-BD462663AE84")] 7 | 8 | [assembly: PluginTitle("NBehave R# 7.1 runner")] 9 | [assembly: PluginDescription("Run text based feature files with NBehave")] 10 | [assembly: PluginVendor("NBehave")] 11 | -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/Properties/AssemblyInfo8.0.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | using JetBrains.Application.PluginSupport; 4 | 5 | [assembly: AssemblyTitle("NBehave.Resharper.Plugin")] 6 | [assembly: Guid("3fe3da9c-2877-4210-8f15-ca9defe78764")] 7 | 8 | [assembly: PluginTitle("NBehave R# 8 runner")] 9 | [assembly: PluginDescription("Run text based feature files with NBehave")] 10 | [assembly: PluginVendor("NBehave")] 11 | -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/Resource/nbehave.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nbehave/NBehave/b671008dc814f59ed15272e02e88421c543ae773/src/NBehave.ReSharper.Plugin/Resource/nbehave.png -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/UnitTestProvider/IdentityGenerator.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.ReSharper.Plugin.UnitTestProvider 2 | { 3 | /// 4 | /// This is a hack to circumvent R# sorting nodes 5 | /// 6 | public static class IdentityGenerator 7 | { 8 | private static int _id; 9 | 10 | public static int NextValue() 11 | { 12 | _id++; 13 | return _id; 14 | } 15 | 16 | public static void Reset() 17 | { 18 | _id = 0; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/UnitTestProvider/NBehaveBackgroundTestElement.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nbehave/NBehave/b671008dc814f59ed15272e02e88421c543ae773/src/NBehave.ReSharper.Plugin/UnitTestProvider/NBehaveBackgroundTestElement.cs -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/UnitTestProvider/NBehaveExampleParentTestElement.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nbehave/NBehave/b671008dc814f59ed15272e02e88421c543ae773/src/NBehave.ReSharper.Plugin/UnitTestProvider/NBehaveExampleParentTestElement.cs -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/UnitTestProvider/NBehaveExampleTestElement.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nbehave/NBehave/b671008dc814f59ed15272e02e88421c543ae773/src/NBehave.ReSharper.Plugin/UnitTestProvider/NBehaveExampleTestElement.cs -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/UnitTestProvider/NBehaveFeatureTestElement.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nbehave/NBehave/b671008dc814f59ed15272e02e88421c543ae773/src/NBehave.ReSharper.Plugin/UnitTestProvider/NBehaveFeatureTestElement.cs -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/UnitTestProvider/NBehaveScenarioTestElement.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nbehave/NBehave/b671008dc814f59ed15272e02e88421c543ae773/src/NBehave.ReSharper.Plugin/UnitTestProvider/NBehaveScenarioTestElement.cs -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/UnitTestProvider/NBehaveStepTestElement.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nbehave/NBehave/b671008dc814f59ed15272e02e88421c543ae773/src/NBehave.ReSharper.Plugin/UnitTestProvider/NBehaveStepTestElement.cs -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/UnitTestProvider/NBehaveUnitTestElementBase7.1.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using JetBrains.ProjectModel; 4 | using JetBrains.ReSharper.UnitTestFramework; 5 | 6 | namespace NBehave.ReSharper.Plugin.UnitTestProvider 7 | { 8 | public abstract partial class NBehaveUnitTestElementBase 9 | { 10 | public string AssemblyOutFile { get { return _project.GetOutputAssemblyFile().Location.FullPath; } } 11 | 12 | public IList GetTaskSequence(ICollection explicitElements, IUnitTestLaunch launch) 13 | { 14 | return GetTaskSequence(explicitElements.ToList()); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/UnitTestProvider/NBehaveUnitTestElementBase8.0.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using JetBrains.ProjectModel; 4 | using JetBrains.ReSharper.TaskRunnerFramework; 5 | using JetBrains.ReSharper.UnitTestFramework; 6 | using JetBrains.ReSharper.UnitTestFramework.Strategy; 7 | using NBehave.ReSharper.Plugin.UnitTestRunner; 8 | 9 | namespace NBehave.ReSharper.Plugin.UnitTestProvider 10 | { 11 | public abstract partial class NBehaveUnitTestElementBase 12 | { 13 | private static readonly IUnitTestRunStrategy RunStrategy = new OutOfProcessUnitTestRunStrategy(new RemoteTaskRunnerInfo(NBehaveTaskRunner.RunnerId, typeof(NBehaveTaskRunner))); 14 | 15 | public string AssemblyOutFile { get { return _project.GetOutputAssemblyInfo().Location.FullPath; } } 16 | 17 | public IUnitTestRunStrategy GetRunStrategy(IHostProvider hostProvider) 18 | { 19 | return RunStrategy; 20 | } 21 | 22 | public IList GetTaskSequence(ICollection explicitElements, IUnitTestLaunch launch) 23 | { 24 | return GetTaskSequence(explicitElements.ToList()); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/UnitTestProvider/Presenter.cs: -------------------------------------------------------------------------------- 1 | using JetBrains.CommonControls; 2 | using JetBrains.ReSharper.UnitTestFramework; 3 | using JetBrains.TreeModels; 4 | using JetBrains.UI.TreeView; 5 | 6 | namespace NBehave.ReSharper.Plugin.UnitTestProvider 7 | { 8 | [UnitTestPresenter] 9 | public class Presenter : IUnitTestPresenter 10 | { 11 | private readonly TestTreePresenter _treePresenter = new TestTreePresenter(); 12 | 13 | public void Present(IUnitTestElement element, IPresentableItem item, TreeModelNode node, PresentationState state) 14 | { 15 | if (element is NBehaveUnitTestElementBase) 16 | _treePresenter.UpdateItem(element, node, item, state); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/UnitTestProvider/TestProvider7.1.cs: -------------------------------------------------------------------------------- 1 | using JetBrains.ReSharper.TaskRunnerFramework; 2 | using NBehave.ReSharper.Plugin.UnitTestRunner; 3 | 4 | namespace NBehave.ReSharper.Plugin.UnitTestProvider 5 | { 6 | public partial class TestProvider 7 | { 8 | 9 | public RemoteTaskRunnerInfo GetTaskRunnerInfo() 10 | { 11 | return new RemoteTaskRunnerInfo(typeof(NBehaveTaskRunner)); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/UnitTestProvider/TestProvider8.0.cs: -------------------------------------------------------------------------------- 1 | using JetBrains.ReSharper.TaskRunnerFramework; 2 | using NBehave.ReSharper.Plugin.UnitTestRunner; 3 | 4 | namespace NBehave.ReSharper.Plugin.UnitTestProvider 5 | { 6 | public partial class TestProvider 7 | { 8 | public RemoteTaskRunnerInfo GetTaskRunnerInfo() 9 | { 10 | return new RemoteTaskRunnerInfo(NBehaveId, typeof(NBehaveTaskRunner)); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/UnitTestProvider/UnitTestMetadataExplorer.cs: -------------------------------------------------------------------------------- 1 | using JetBrains.ProjectModel; 2 | using JetBrains.ReSharper.UnitTestFramework; 3 | 4 | namespace NBehave.ReSharper.Plugin.UnitTestProvider 5 | { 6 | [MetadataUnitTestExplorer] 7 | public partial class UnitTestMetadataExplorer : IUnitTestMetadataExplorer 8 | { 9 | private readonly TestProvider _provider; 10 | private readonly ISolution _solution; 11 | 12 | public IUnitTestProvider Provider { get { return _provider; } } 13 | 14 | public UnitTestMetadataExplorer(TestProvider provider, ISolution solution) 15 | { 16 | _provider = provider; 17 | _solution = solution; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/UnitTestProvider/UnitTestMetadataExplorer7.1.cs: -------------------------------------------------------------------------------- 1 | using JetBrains.Application; 2 | using JetBrains.Metadata.Reader.API; 3 | using JetBrains.ProjectModel; 4 | using JetBrains.ReSharper.UnitTestFramework; 5 | 6 | namespace NBehave.ReSharper.Plugin.UnitTestProvider 7 | { 8 | public partial class UnitTestMetadataExplorer 9 | { 10 | public void ExploreAssembly(IProject project, IMetadataAssembly assembly, UnitTestElementConsumer consumer) 11 | { 12 | ReadLockCookie.Execute(() => new MetadataExplorer(_provider, _solution, project, consumer).ExploreProject()); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/UnitTestProvider/UnitTestMetadataExplorer8.0.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using JetBrains.Application; 3 | using JetBrains.Metadata.Reader.API; 4 | using JetBrains.ProjectModel; 5 | using JetBrains.ReSharper.UnitTestFramework; 6 | 7 | namespace NBehave.ReSharper.Plugin.UnitTestProvider 8 | { 9 | public partial class UnitTestMetadataExplorer 10 | { 11 | public void ExploreAssembly(IProject project, IMetadataAssembly assembly, UnitTestElementConsumer consumer, ManualResetEvent exitEvent) 12 | { 13 | ReadLockCookie.Execute(() => new MetadataExplorer(_provider, _solution, project, consumer).ExploreProject()); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/UnitTestRunner/NBehaveAssemblyTask.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | using JetBrains.ReSharper.TaskRunnerFramework; 4 | 5 | namespace NBehave.ReSharper.Plugin.UnitTestRunner 6 | { 7 | [Serializable] 8 | public class NBehaveAssemblyTask : RemoteTask, IEquatable 9 | { 10 | public NBehaveAssemblyTask(XmlElement element) 11 | : base(element) 12 | { 13 | AssemblyFile = GetXmlAttribute(element, "assemblyFile"); 14 | } 15 | 16 | public string AssemblyFile { get; private set; } 17 | 18 | public NBehaveAssemblyTask(string pathToAssembly) 19 | : base(NBehaveTaskRunner.RunnerId) 20 | { 21 | AssemblyFile = pathToAssembly; 22 | } 23 | 24 | public override void SaveXml(XmlElement element) 25 | { 26 | base.SaveXml(element); 27 | SetXmlAttribute(element, "assemblyFile", AssemblyFile); 28 | } 29 | 30 | public override bool IsMeaningfulTask 31 | { 32 | get { return true; } 33 | } 34 | 35 | public bool Equals(NBehaveAssemblyTask other) 36 | { 37 | if (other == null) 38 | return false; 39 | if (ReferenceEquals(this, other)) return true; 40 | return other.AssemblyFile == AssemblyFile; 41 | } 42 | 43 | public override bool Equals(RemoteTask other) 44 | { 45 | return Equals(other as NBehaveAssemblyTask); 46 | } 47 | 48 | public override bool Equals(object obj) 49 | { 50 | return Equals(obj as NBehaveAssemblyTask); 51 | } 52 | 53 | public override int GetHashCode() 54 | { 55 | unchecked 56 | { 57 | return AssemblyFile.GetHashCode(); 58 | } 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/UnitTestRunner/NBehaveTaskRunner7.1.cs: -------------------------------------------------------------------------------- 1 | using JetBrains.ReSharper.TaskRunnerFramework; 2 | 3 | namespace NBehave.ReSharper.Plugin.UnitTestRunner 4 | { 5 | public partial class NBehaveTaskRunner 6 | { 7 | public override TaskResult Start(TaskExecutionNode node) 8 | { 9 | return TaskResult.Success; 10 | } 11 | 12 | public override TaskResult Execute(TaskExecutionNode node) 13 | { 14 | return TaskResult.Success; 15 | } 16 | 17 | public override TaskResult Finish(TaskExecutionNode node) 18 | { 19 | return TaskResult.Success; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/UnitTestRunner/NBehaveTaskRunnerListener.cs: -------------------------------------------------------------------------------- 1 | using NBehave.EventListeners; 2 | 3 | namespace NBehave.ReSharper.Plugin.UnitTestRunner 4 | { 5 | 6 | public class NBehaveTaskRunnerListener : EventListener 7 | { 8 | private readonly ResharperResultPublisher publisher; 9 | 10 | public NBehaveTaskRunnerListener(ResharperResultPublisher publisher) 11 | { 12 | this.publisher = publisher; 13 | } 14 | 15 | public override void ScenarioFinished(ScenarioResult result) 16 | { 17 | publisher.Notify(result); 18 | } 19 | 20 | public override void FeatureFinished(FeatureResult result) 21 | { 22 | publisher.Notify(result); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/UnitTestRunner/TaskExecutionNodeExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using JetBrains.ReSharper.TaskRunnerFramework; 3 | 4 | namespace NBehave.ReSharper.Plugin.UnitTestRunner 5 | { 6 | public static class TaskExecutionNodeExtensions 7 | { 8 | 9 | public static IEnumerable AllTasks(this IEnumerable nodes) 10 | { 11 | var tasks = new List(); 12 | foreach (var node in nodes) 13 | { 14 | tasks.Add(node.RemoteTask); 15 | tasks.AddRange(AllTasks(node.Children)); 16 | } 17 | return tasks; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/__ReadMe__.txt: -------------------------------------------------------------------------------- 1 | To debug the plugin set devenv.exe as "Start external external program" for this project. 2 | For parameters add /ReSharper.Internal /ReSharper.Plugin \NBehave.ReSharper.Plugin.dll 3 | you may also add another parameter pointing to a sln or csproj file so you can load a testproject automatically 4 | -------------------------------------------------------------------------------- /src/NBehave.ReSharper.Plugin/paket.references: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nbehave/NBehave/b671008dc814f59ed15272e02e88421c543ae773/src/NBehave.ReSharper.Plugin/paket.references -------------------------------------------------------------------------------- /src/NBehave.Spec.MSTest.Specifications/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("NBehave.Spec.MSTest.Specs")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Headspring Systems")] 12 | [assembly: AssemblyProduct("NBehave.Spec.MSTest.Specs")] 13 | [assembly: AssemblyCopyright("Copyright © Headspring Systems 2008")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("929fbec9-d1ca-439d-9dbc-e770bad2d110")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/NBehave.Spec.MSTest.Specifications/SpecBaseSpecs.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using Rhino.Mocks; 3 | 4 | namespace NBehave.Spec.MSTest.Specifications 5 | { 6 | [TestClass] 7 | public class When_initializing_the_SpecBase : MSTest.SpecBase 8 | { 9 | protected override StopWatch Establish_context() 10 | { 11 | return new StopWatch(); 12 | } 13 | 14 | protected override void Because_of() 15 | { 16 | } 17 | 18 | [TestMethod] 19 | public void should_populate_the_SUT_before_starting_the_specification() 20 | { 21 | Sut.ShouldNotBeNull(); 22 | } 23 | } 24 | 25 | [TestClass] 26 | public class When_initializing_the_SpecBase_with_mocks : MSTest.SpecBase 27 | { 28 | private ITimer _timer; 29 | 30 | protected override StopWatch Establish_context() 31 | { 32 | _timer = CreateDependency(); 33 | 34 | _timer.Stub(x => x.Start(null)).IgnoreArguments().Return(true); 35 | 36 | return new StopWatch(_timer); 37 | } 38 | 39 | protected override void Because_of() 40 | { 41 | Sut.Start(); 42 | } 43 | 44 | [TestMethod] 45 | public void should_call_the_before_each_spec_before_starting_the_specification() 46 | { 47 | _timer.AssertWasCalled(x => x.Start(null), opt => opt.IgnoreArguments()); 48 | } 49 | } 50 | 51 | public class StopWatch 52 | { 53 | private readonly ITimer _timer; 54 | 55 | public StopWatch() 56 | { 57 | } 58 | 59 | public StopWatch(ITimer timer) 60 | { 61 | _timer = timer; 62 | } 63 | 64 | public void Start() 65 | { 66 | _timer.Start(""); 67 | } 68 | } 69 | 70 | public interface ITimer 71 | { 72 | bool Start(string reason); 73 | void Start(); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/NBehave.Spec.MSTest.Specifications/paket.references: -------------------------------------------------------------------------------- 1 | NUnit 2 | RhinoMocks 3 | MSTest.TestFramework 4 | -------------------------------------------------------------------------------- /src/NBehave.Spec.MSTest/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("NBehave.Spec.MSTest")] 5 | [assembly: Guid("07fb81bb-b15c-4429-bc5d-e3ec041c122c")] 6 | -------------------------------------------------------------------------------- /src/NBehave.Spec.MSTest/SpecBase.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace NBehave.Spec.MSTest 4 | { 5 | [TestClass] 6 | public abstract class SpecBase : Spec.SpecBase 7 | { 8 | [TestInitialize] 9 | public override void MainSetup() 10 | { 11 | base.MainSetup(); 12 | } 13 | 14 | [TestCleanup] 15 | public override void MainTeardown() 16 | { 17 | base.MainTeardown(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/NBehave.Spec.MSTest/SpecBase_generic.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace NBehave.Spec.MSTest 4 | { 5 | [TestClass] 6 | public abstract class SpecBase : Spec.SpecBase 7 | { 8 | [TestInitialize] 9 | public override void MainSetup() 10 | { 11 | base.MainSetup(); 12 | } 13 | 14 | [TestCleanup] 15 | public override void MainTeardown() 16 | { 17 | base.MainTeardown(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/NBehave.Spec.MSTest/paket.references: -------------------------------------------------------------------------------- 1 | RhinoMocks 2 | MSTest.TestFramework 3 | -------------------------------------------------------------------------------- /src/NBehave.Spec.MbUnit.Specifications/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("NBehave.Spec.MbUnit.Specs")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("Dell, Inc")] 11 | [assembly: AssemblyProduct("NBehave.Spec.MbUnit.Specs")] 12 | [assembly: AssemblyCopyright("Copyright © Dell, Inc 2008")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("0c6d5552-d887-4e6a-8817-4a4a026855d7")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /src/NBehave.Spec.MbUnit.Specifications/paket.references: -------------------------------------------------------------------------------- 1 | mbunit 2 | NUnit 3 | RhinoMocks -------------------------------------------------------------------------------- /src/NBehave.Spec.MbUnit/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("NBehave.Spec.MbUnit")] 5 | [assembly: Guid("3e0cd5f6-923d-48cf-a5a8-c94fc5f444a3")] 6 | -------------------------------------------------------------------------------- /src/NBehave.Spec.MbUnit/SpecBase.cs: -------------------------------------------------------------------------------- 1 | using MbUnit.Framework; 2 | 3 | namespace NBehave.Spec.MbUnit 4 | { 5 | [TestFixture] 6 | public abstract class SpecBase : Spec.SpecBase 7 | { 8 | [FixtureSetUp] 9 | public override void MainSetup() 10 | { 11 | base.MainSetup(); 12 | } 13 | 14 | [FixtureTearDown] 15 | public override void MainTeardown() 16 | { 17 | base.MainTeardown(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/NBehave.Spec.MbUnit/SpecBase_generic.cs: -------------------------------------------------------------------------------- 1 | using MbUnit.Framework; 2 | 3 | namespace NBehave.Spec.MbUnit 4 | { 5 | [TestFixture] 6 | public abstract class SpecBase : Spec.SpecBase 7 | { 8 | [FixtureSetUp] 9 | public override void MainSetup() 10 | { 11 | base.MainSetup(); 12 | } 13 | 14 | [FixtureTearDown] 15 | public override void MainTeardown() 16 | { 17 | base.MainTeardown(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/NBehave.Spec.MbUnit/SpecificationAttribute.cs: -------------------------------------------------------------------------------- 1 | using MbUnit.Framework; 2 | 3 | namespace NBehave.Spec.MbUnit 4 | { 5 | public class SpecificationAttribute : TestAttribute 6 | { } 7 | } -------------------------------------------------------------------------------- /src/NBehave.Spec.MbUnit/paket.references: -------------------------------------------------------------------------------- 1 | mbunit 2 | RhinoMocks -------------------------------------------------------------------------------- /src/NBehave.Spec.NUnit.Specifications/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | 8 | [assembly : AssemblyTitle("NBehave.Spec.NUnit.Specs")] 9 | [assembly : AssemblyDescription("")] 10 | [assembly : AssemblyConfiguration("")] 11 | [assembly : AssemblyCompany("Dell, Inc")] 12 | [assembly : AssemblyProduct("NBehave.Spec.NUnit.Specs")] 13 | [assembly : AssemblyCopyright("Copyright © Dell, Inc 2008")] 14 | [assembly : AssemblyTrademark("")] 15 | [assembly : AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | 21 | [assembly : ComVisible(false)] 22 | 23 | // The following GUID is for the ID of the typelib if this project is exposed to COM 24 | 25 | [assembly : Guid("d161bbc9-91c0-49fd-bff9-1bc859ff9608")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Build and Revision Numbers 35 | // by using the '*' as shown below: 36 | // [assembly: AssemblyVersion("1.0.*")] 37 | 38 | [assembly : AssemblyVersion("1.0.0.0")] 39 | [assembly : AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /src/NBehave.Spec.NUnit.Specifications/paket.references: -------------------------------------------------------------------------------- 1 | NUnit 2 | RhinoMocks -------------------------------------------------------------------------------- /src/NBehave.Spec.NUnit/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("NBehave.Spec.NUnit")] 5 | [assembly: Guid("c6e9073e-1abc-45c8-8ae6-1cdbbcd41ba3")] 6 | -------------------------------------------------------------------------------- /src/NBehave.Spec.NUnit/SpecBase.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace NBehave.Spec.NUnit 4 | { 5 | [TestFixture] 6 | public abstract class SpecBase : Spec.SpecBase 7 | { 8 | [OneTimeSetUp] 9 | public override void MainSetup() 10 | { 11 | base.MainSetup(); 12 | } 13 | 14 | [OneTimeTearDown] 15 | public override void MainTeardown() 16 | { 17 | base.MainTeardown(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/NBehave.Spec.NUnit/SpecBase_generic.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace NBehave.Spec.NUnit 4 | { 5 | [TestFixture] 6 | public abstract class SpecBase : Spec.SpecBase 7 | { 8 | [OneTimeSetUp] 9 | public override void MainSetup() 10 | { 11 | base.MainSetup(); 12 | } 13 | 14 | [OneTimeTearDown] 15 | public override void MainTeardown() 16 | { 17 | base.MainTeardown(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/NBehave.Spec.NUnit/SpecificationAttribute.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace NBehave.Spec.NUnit 4 | { 5 | public class SpecificationAttribute : TestAttribute 6 | { } 7 | } -------------------------------------------------------------------------------- /src/NBehave.Spec.NUnit/paket.references: -------------------------------------------------------------------------------- 1 | NUnit 2 | RhinoMocks -------------------------------------------------------------------------------- /src/NBehave.Spec.Xunit.Specifications/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("NBehave.Spec.Xunit.Specs")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("Headspring Systems")] 11 | [assembly: AssemblyProduct("NBehave.Spec.Xunit.Specs")] 12 | [assembly: AssemblyCopyright("Copyright © Headspring Systems 2008")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("6f83d0b8-790b-4c91-bf33-91fac3ad66eb")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /src/NBehave.Spec.Xunit.Specifications/SpecBaseSpecs.cs: -------------------------------------------------------------------------------- 1 | using NBehave.Spec.Xunit; 2 | using NUnit.Framework; 3 | using Rhino.Mocks; 4 | 5 | namespace Xunit.SpecBase_Specifications 6 | { 7 | public class When_initializing_the_SpecBase : SpecBase 8 | { 9 | protected override StopWatch Establish_context() 10 | { 11 | return new StopWatch(); 12 | } 13 | 14 | protected override void Because_of() 15 | { 16 | } 17 | 18 | [Test] 19 | public void should_populate_the_SUT_before_starting_the_specification() 20 | { 21 | Assert.NotNull(Sut); 22 | } 23 | } 24 | 25 | public class When_initializing_the_SpecBase_with_mocks : SpecBase 26 | { 27 | private ITimer _timer; 28 | 29 | protected override StopWatch Establish_context() 30 | { 31 | _timer = CreateDependency(); 32 | 33 | _timer.Stub(x => x.Start(null)).IgnoreArguments().Return(true); 34 | 35 | return new StopWatch(_timer); 36 | } 37 | 38 | protected override void Because_of() 39 | { 40 | Sut.Start(); 41 | } 42 | 43 | [Test] 44 | public void should_call_the_before_each_spec_before_starting_the_specification() 45 | { 46 | _timer.AssertWasCalled(x => x.Start(null), opt => opt.IgnoreArguments()); 47 | } 48 | } 49 | 50 | public class StopWatch 51 | { 52 | private readonly ITimer _timer; 53 | 54 | public StopWatch() 55 | { 56 | } 57 | 58 | public StopWatch(ITimer timer) 59 | { 60 | _timer = timer; 61 | } 62 | 63 | public void Start() 64 | { 65 | _timer.Start(""); 66 | } 67 | } 68 | 69 | public interface ITimer 70 | { 71 | bool Start(string reason); 72 | void Start(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/NBehave.Spec.Xunit.Specifications/paket.references: -------------------------------------------------------------------------------- 1 | NUnit 2 | RhinoMocks 3 | xunit -------------------------------------------------------------------------------- /src/NBehave.Spec.Xunit/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("NBehave.Spec.Xunit")] 5 | [assembly: Guid("dc64fe2b-33e1-47af-a0ab-f624bff06ebb")] 6 | -------------------------------------------------------------------------------- /src/NBehave.Spec.Xunit/SpecBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.Spec.Xunit 4 | { 5 | public abstract class SpecBase : Spec.SpecBase, IDisposable 6 | { 7 | protected SpecBase() 8 | { 9 | base.MainSetup(); 10 | } 11 | 12 | public void Dispose() 13 | { 14 | base.MainTeardown(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/NBehave.Spec.Xunit/SpecBase_generic.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.Spec.Xunit 4 | { 5 | public abstract class SpecBase : Spec.SpecBase, IDisposable 6 | { 7 | protected SpecBase() 8 | { 9 | base.MainSetup(); 10 | } 11 | 12 | public void Dispose() 13 | { 14 | base.MainTeardown(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/NBehave.Spec.Xunit/SpecificationAttribute.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | 3 | namespace NBehave.Spec.Xunit 4 | { 5 | public class SpecificationAttribute : FactAttribute 6 | { } 7 | } -------------------------------------------------------------------------------- /src/NBehave.Spec.Xunit/paket.references: -------------------------------------------------------------------------------- 1 | RhinoMocks 2 | xunit -------------------------------------------------------------------------------- /src/NBehave.Spec/ActionSpecification.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.Spec 4 | { 5 | public class ActionSpecification : IActionSpecification 6 | { 7 | private readonly T _value; 8 | private readonly Action _assert; 9 | 10 | public ActionSpecification(T value, Action assert) 11 | { 12 | _value = value; 13 | _assert = assert; 14 | } 15 | 16 | public void WhenCalling(Action action) 17 | { 18 | Exception e = null; 19 | 20 | try 21 | { 22 | action(_value); 23 | } 24 | catch (Exception ex) 25 | { 26 | e = ex; 27 | } 28 | 29 | _assert.Invoke(e); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/NBehave.Spec/IActionSpecification.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.Spec 4 | { 5 | public interface IActionSpecification 6 | { 7 | void WhenCalling(Action action); 8 | } 9 | } -------------------------------------------------------------------------------- /src/NBehave.Spec/SpecBase.cs: -------------------------------------------------------------------------------- 1 | using Rhino.Mocks; 2 | 3 | namespace NBehave.Spec 4 | { 5 | public abstract class SpecBase 6 | { 7 | public virtual void MainSetup() 8 | { 9 | Establish_context(); 10 | Because_of(); 11 | } 12 | 13 | public virtual void MainTeardown() 14 | { 15 | Cleanup(); 16 | } 17 | 18 | protected virtual void Establish_context() 19 | { 20 | } 21 | 22 | protected virtual void Because_of() 23 | { 24 | } 25 | 26 | protected virtual void Cleanup() 27 | { 28 | } 29 | 30 | protected TType CreateDependency() 31 | where TType : class 32 | { 33 | return MockRepository.GenerateMock(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/NBehave.Spec/SpecBase_generic.cs: -------------------------------------------------------------------------------- 1 | using Rhino.Mocks; 2 | 3 | namespace NBehave.Spec 4 | { 5 | public abstract class SpecBase 6 | { 7 | public virtual void MainSetup() 8 | { 9 | Sut = Establish_context(); 10 | Because_of(); 11 | } 12 | 13 | public virtual void MainTeardown() 14 | { 15 | Cleanup(); 16 | } 17 | 18 | protected virtual void Because_of() {} 19 | protected abstract TContext Establish_context(); 20 | protected virtual void Cleanup() {} 21 | 22 | protected virtual TContext Sut { get; private set; } 23 | 24 | protected TType CreateDependency() 25 | where TType : class 26 | { 27 | return MockRepository.GenerateMock(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/NBehave.Spec/ThrowingAction.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.Spec 2 | { 3 | public delegate void ThrowingAction(); 4 | } 5 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/ConfigurationNoAppDomain.cs: -------------------------------------------------------------------------------- 1 | using NBehave.Configuration; 2 | 3 | namespace NBehave.Specifications 4 | { 5 | public static class ConfigurationNoAppDomain 6 | { 7 | public static NBehaveConfiguration New 8 | { 9 | get 10 | { 11 | return NBehaveConfiguration.New.DontIsolateInAppDomain(); 12 | } 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/NBehave.Specifications/Domain/ExampleBuilderSpec.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NUnit.Framework; 3 | 4 | namespace NBehave.Specifications.Domain 5 | { 6 | [TestFixture] 7 | public class ExampleBuilderSpec 8 | { 9 | [Test] 10 | public void Should_create_table_instance_from_string() 11 | { 12 | var columnNames = new ExampleColumns(new[] { new ExampleColumn("colA"), new ExampleColumn("colB"), }); 13 | var columnValues = new Dictionary { { "colA", "A" }, { "colB", "B" } }; 14 | var example = new Example(columnNames, columnValues); 15 | 16 | var str = example.ToString(); 17 | var exampleFromString = ExampleBuilder.BuildFromString(str); 18 | 19 | CollectionAssert.AreEqual(exampleFromString.ColumnNames, example.ColumnNames); 20 | CollectionAssert.AreEqual(exampleFromString.ColumnValues, example.ColumnValues); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/NBehave.Specifications/Domain/FeatureSpec.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NUnit.Framework; 3 | 4 | namespace NBehave.Specifications.Domain 5 | { 6 | [TestFixture] 7 | public class FeatureSpec 8 | { 9 | [Test] 10 | public void Should_convert_feature_to_string() 11 | { 12 | var feature = new Feature("Title", string.Format(" As a x{0} I want y{0} So that z", Environment.NewLine), "source", 1); 13 | var featureAsString = feature.ToString(); 14 | string expected = string.Format("Feature: Title{0} As a x{0} I want y{0} So that z", Environment.NewLine); 15 | Assert.AreEqual(expected, featureAsString); 16 | } 17 | 18 | [Test] 19 | public void Should_convert_background_to_string() 20 | { 21 | var feature = new Feature("Title", string.Format(" As a x{0} I want y{0} So that z", Environment.NewLine), "source", 1); 22 | var background = new Scenario("backgroundTitle", "source", feature, 4); 23 | background.AddStep(new StringStep("Given", "a background step", "source, 5")); 24 | feature.AddBackground(background); 25 | var featureAsString = feature.ToString(); 26 | string expected = string.Format("Feature: Title{0} As a x{0} I want y{0} So that z", Environment.NewLine); 27 | expected += string.Format("{0}{0} Background: backgroundTitle{0} Given a background step", Environment.NewLine); 28 | Assert.AreEqual(expected, featureAsString); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/NBehave.Specifications/Domain/StringTableStepSpec.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 3 | using System.Runtime.Serialization.Formatters.Binary; 4 | using NUnit.Framework; 5 | 6 | namespace NBehave.Specifications.Domain 7 | { 8 | [TestFixture] 9 | public class StringTableStepSpec 10 | { 11 | [Test] 12 | public void Should_be_able_to_serialize_binary() 13 | { 14 | var s = new StringTableStep("Given", "x", "source"); 15 | var columns = new ExampleColumns(new[] { new ExampleColumn("a") }); 16 | var values = new Dictionary { { "a", "value" } }; 17 | var row = new Example(columns, values); 18 | s.AddTableStep(row); 19 | 20 | var b = new BinaryFormatter(); 21 | using (Stream stream = new MemoryStream()) 22 | b.Serialize(stream, s); 23 | Assert.Pass("Should not throw exception"); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/EventListeners/FailSpecResultEventListenerSpec.cs: -------------------------------------------------------------------------------- 1 | using NBehave.EventListeners; 2 | using NBehave.Extensions; 3 | using NBehave.Specifications.Features; 4 | using NUnit.Framework; 5 | 6 | namespace NBehave.Specifications.EventListeners 7 | { 8 | [TestFixture] 9 | public class FailSpecResultEventListenerSpec 10 | { 11 | [Test] 12 | public void Should_not_throw_if_feature_passes() 13 | { 14 | var listener = new FailSpecResultEventListener(); 15 | var runner = ConfigurationNoAppDomain 16 | .New 17 | .SetScenarioFiles(new[] { TestFeatures.FeatureNamedStory }) 18 | .SetAssemblies(new[] { "TestLib.dll" }) 19 | .SetEventListener(listener) 20 | .Build(); Assert.DoesNotThrow(() => runner.Run()); 21 | } 22 | 23 | [Test] 24 | public void Should_throw_TestFailedException() 25 | { 26 | var listener = new FailSpecResultEventListener(); 27 | var runner = ConfigurationNoAppDomain 28 | .New 29 | .SetScenarioFiles(new[] { TestFeatures.FeatureWithFailingStep }) 30 | .SetAssemblies(new[] { "TestLib.dll" }) 31 | .SetEventListener(listener) 32 | .Build(); 33 | Assert.Throws(() => runner.Run()); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/NBehave.Specifications/EventListeners/MultiOutputEventListenerSpec.cs: -------------------------------------------------------------------------------- 1 | using NBehave.EventListeners; 2 | using NUnit.Framework; 3 | using Rhino.Mocks; 4 | 5 | namespace NBehave.Specifications.EventListeners 6 | { 7 | [TestFixture] 8 | public class MultiOutputEventListenerSpec 9 | { 10 | [Test] 11 | public void ShouldInvokeMethodOnAllSpecifiedListeners() 12 | { 13 | var mockFirstEventListener = MockRepository.GenerateMock(); 14 | var mockSecondEventListener = MockRepository.GenerateMock(); 15 | 16 | EventListener listener = new MultiOutputEventListener(mockFirstEventListener, mockSecondEventListener); 17 | listener.RunStarted(); 18 | mockFirstEventListener.AssertWasCalled(l => l.RunStarted()); 19 | mockSecondEventListener.AssertWasCalled(l => l.RunStarted()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/ExampleSpec.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NUnit.Framework; 3 | 4 | namespace NBehave.Specifications 5 | { 6 | [TestFixture] 7 | public class ExampleSpec 8 | { 9 | Example _row; 10 | 11 | [SetUp] 12 | public void EstablishContext() 13 | { 14 | const string colName = "colName"; 15 | const string colValue = "a really wide column value"; 16 | var columnNames = new ExampleColumns { new ExampleColumn(colName) }; 17 | var columnValues = new Dictionary 18 | { 19 | { "colName" , colValue } 20 | }; 21 | _row = new Example(columnNames, columnValues); 22 | } 23 | 24 | [Test] 25 | public void Should_use_formatted_column() 26 | { 27 | var rowAsString = _row.ColumnNamesToString(); 28 | const string expected = " | colName |"; 29 | Assert.That(rowAsString, Is.EqualTo(expected)); 30 | } 31 | 32 | [Test] 33 | public void ShouldMakeColumnValuesToString() 34 | { 35 | var rowAsString = _row.ColumnValuesToString(); 36 | const string expected = " | a really wide column value |"; 37 | Assert.That(rowAsString, Is.EqualTo(expected)); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/Extensions/StoryRunnerFilterExtensionsSpec.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using NBehave.Extensions; 3 | using NUnit.Framework; 4 | 5 | namespace NBehave.Specifications.Extensions 6 | { 7 | [TestFixture] 8 | public class StoryRunnerFilterExtensionsSpec 9 | { 10 | [Test] 11 | public void Should_build_pattern_based_on_class_name() 12 | { 13 | var filter = In.Context(); 14 | Assert.AreEqual("^StoryRunnerFilterExtensionsSpec$", filter.ClassNameFilter.ToString()); 15 | } 16 | 17 | [Test] 18 | public void Should_build_pattern_based_on_class_name_using_global_context() 19 | { 20 | var filter = In.GlobalContext().And(); 21 | Assert.AreEqual("^StoryRunnerFilterExtensionsSpec$", filter.ClassNameFilter.ToString()); 22 | } 23 | 24 | [Test] 25 | public void Should_build_pattern_based_on_multiple_class_names() 26 | { 27 | var filter = In.Context().And().And(); 28 | Assert.AreEqual("^StoryRunnerFilterExtensionsSpec|StringBuilder|TestAttribute$", filter.ClassNameFilter.ToString()); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/Features/FeatureInSwedish.feature: -------------------------------------------------------------------------------- 1 | # language: sv 2 | Egenskap: Need a feature 3 | 4 | Scenario: Need a scenario 5 | Givet att jag knappat in 5 6 | Och att jag knappat in 4 7 | När jag summerar 8 | Så ska resultatet vara 9 9 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/Features/FeatureNamedStory.feature: -------------------------------------------------------------------------------- 1 | Feature: Greeting system 2 | As a project member 3 | I want specs written in a non techie way 4 | So that everyone can understand them 5 | 6 | Scenario: Greeting someone 7 | Given my name is Morgan 8 | When I'm greeted 9 | Then I should be greeted with “Hello, Morgan!” 10 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/Features/FeatureWithCommentOnLastRow.feature: -------------------------------------------------------------------------------- 1 | Feature: Greeting someone 2 | As a polite person 3 | I want to be able to say hello 4 | So that this scenario doesn't fail due to not having a feature declared 5 | 6 | Scenario: greeting Morgan 7 | Given my name is Kalle 8 | When I'm greeted 9 | Then I should be greeted with “Hello, Kalle!” 10 | #comment -------------------------------------------------------------------------------- /src/NBehave.Specifications/Features/FeatureWithFailingStep.feature: -------------------------------------------------------------------------------- 1 | Feature: Feature with failing step 2 | As a nbehave user 3 | I want to be able to have a failing step 4 | So that I can make write code to make it pass 5 | 6 | Scenario: scenario with failing step 7 | Given my name is Morgan 8 | When I'm greeted 9 | Then I should be greeted with “Hello, Scott!” -------------------------------------------------------------------------------- /src/NBehave.Specifications/Features/FeatureWithLowerCaseSteps.feature: -------------------------------------------------------------------------------- 1 | Feature: File with incorrect steps 2 | 3 | Scenario: Given, when then in lowercase 4 | given a step 5 | when steps are all lowercase 6 | then we should not crash -------------------------------------------------------------------------------- /src/NBehave.Specifications/Features/FeatureWithManyScenarios.feature: -------------------------------------------------------------------------------- 1 | Feature: Greeting system 2 | As a X 3 | I want y 4 | So that Z 5 | 6 | Scenario: greeting Morgan 7 | Given my name is Morgan 8 | When I'm greeted 9 | Then I should be greeted with “Hello, Morgan!” 10 | 11 | Scenario: greeting scott 12 | Given my name is Scott 13 | When I'm greeted 14 | Then I should be greeted with “Hello, Scott!” -------------------------------------------------------------------------------- /src/NBehave.Specifications/Features/FeatureWithNewLineInGivenClause.feature: -------------------------------------------------------------------------------- 1 | Feature: Need a feature 2 | 3 | Scenario: Need a scenario 4 | Given my name is Morgan 5 | When I'm greeted 6 | Then I should be greeted with “Hello, Morgan!” -------------------------------------------------------------------------------- /src/NBehave.Specifications/Features/FeatureWithPendingStep.feature: -------------------------------------------------------------------------------- 1 | Feature: Not implemented feature 2 | As a project member 3 | I want specs written in a non techie way 4 | So that everyone can understand them 5 | 6 | Scenario: Pending scenario 7 | Given an unimplemented step 8 | When another unimplemented step 9 | Then there should be 3 pending steps 10 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/Features/FeatureWithTags.feature: -------------------------------------------------------------------------------- 1 | @tag1 @tag2 2 | Feature: Greeting system with tags 3 | As a project member 4 | I want specs written in a non techie way 5 | So that everyone can understand them 6 | 7 | @tag3 @tag4 8 | Scenario: Greeting someone 9 | Given my name is Morgan 10 | When I'm greeted 11 | Then I should be greeted with “Hello, Morgan!” 12 | 13 | @tag5 14 | Scenario: Greeting someone else 15 | Given my name is Anna 16 | When I'm greeted 17 | Then I should be greeted with “Hello, Anna!” 18 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/Features/FeaturesAndScenarios.feature: -------------------------------------------------------------------------------- 1 | Feature: S1 2 | As a X1 3 | I want Y1 4 | So that Z1 5 | 6 | Scenario: SC1 7 | Given something 8 | When some event occurs 9 | Then there is some outcome 10 | Scenario: SC2 11 | Given something two 12 | When some event #2 occurs 13 | Then there is some outcome #2 14 | Scenario: Pending scenario 15 | Given something pending 16 | And something pending 17 | And something more pending 18 | When some pending event occurs 19 | And some more pending event occurs 20 | Then this text should still show up in xml output 21 | 22 | Feature: S2 23 | As a X2 24 | I want Y2 25 | So that Z2 26 | 27 | Scenario: SC1 28 | Given something 29 | When some event occurs 30 | Then there is some outcome 31 | 32 | Feature: S3 33 | As a X3 34 | I want Y3 35 | So that Z3 36 | 37 | Scenario: SC3 38 | Given something 39 | When some event occurs 40 | Then there is some outcome 41 | Scenario: FailingScenario 42 | Given something x 43 | When some event y occurs 44 | Then there is some failing outcome 45 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/Features/ScenarioWithExamples.feature: -------------------------------------------------------------------------------- 1 | Feature: Example 2 | As a X1 3 | I want Y1 4 | So that Z1 5 | 6 | Scenario: SC1 7 | Given a string [str] 8 | When string is ecco'ed 9 | Then you should see [strOut] 10 | 11 | Examples: 12 | | str | strOut | 13 | | xyz | xyz | 14 | | abc | abc | 15 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/Features/ScenarioWithNoActionSteps.feature: -------------------------------------------------------------------------------- 1 | Feature: A feature with pending scenarios 2 | As a nbehave user 3 | I was a feature to have unimplemented scenarios 4 | So that I can write business cases up before any coding is done 5 | 6 | Scenario: A pending scenario 7 | Given something that has no ActionStep 8 | And something else that has no ActionStep 9 | When it is executed 10 | Then it should be pending -------------------------------------------------------------------------------- /src/NBehave.Specifications/Features/ScenarioWithTables.feature: -------------------------------------------------------------------------------- 1 | Feature: Example 2 | As a X1 3 | I want Y1 4 | So that Z1 5 | 6 | Scenario: SC1 7 | Given a string [str] 8 | | str | 9 | | aaa | 10 | | bbb | 11 | When string is ecco'ed 12 | Then you should see [strOut] 13 | | strOut | 14 | | aaa | 15 | | bbb | 16 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/Features/ScenariosWithoutFeature.feature: -------------------------------------------------------------------------------- 1 | Feature: Greeting someone 2 | As a polite person 3 | I want to be able to say hello 4 | So that this scenario doesn't fail due to not having a feature declared 5 | 6 | Scenario: greeting Morgan 7 | Given my name is Morgan 8 | When I'm greeted 9 | Then I should be greeted with “Hello, Morgan!” 10 | 11 | Scenario: greeting scott 12 | Given my name is Scott 13 | When I'm greeted 14 | Then I should be greeted with “Hello, Scott!” -------------------------------------------------------------------------------- /src/NBehave.Specifications/IgnoreSpaceAndUnderScoreMatcherSpec.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NBehave.Contracts; 3 | using NUnit.Framework; 4 | 5 | namespace NBehave.Specifications 6 | { 7 | public class SomeSpec {} 8 | // ReSharper disable InconsistentNaming 9 | public class Some_Spec {} 10 | // ReSharper restore InconsistentNaming 11 | public class Some {} 12 | public class Spec {} 13 | 14 | [TestFixture] 15 | public class IgnoreSpaceAndUnderScoreMatcherSpec 16 | { 17 | [TestCase("Spec.story", typeof(Spec))] 18 | [TestCase("Some Spec.story", typeof(SomeSpec))] 19 | [TestCase("Some Spec.scenario", typeof(SomeSpec))] 20 | [TestCase("Some Spec.story", typeof(Some_Spec))] 21 | [TestCase("Some_Spec.story", typeof(SomeSpec))] 22 | [TestCase("Some_Spec.story", typeof(Some_Spec))] 23 | public void ShouldBeConsidiredEqual(string fileName, Type typeToMatch) 24 | { 25 | IFileMatcher matcher = new IgnoreSpaceAndUnderScoreMatcher(typeToMatch); 26 | Assert.IsTrue(matcher.IsMatch(fileName)); 27 | } 28 | 29 | [TestCase("Spec.story", typeof(SomeSpec))] 30 | [TestCase("SpecSome.story", typeof(SomeSpec))] 31 | [TestCase("Some-Spec.scenario", typeof(SomeSpec))] 32 | [TestCase("Some.Spec.scenario", typeof(SomeSpec))] 33 | [TestCase("Some Spec.story", typeof(Spec))] 34 | [TestCase("Some_Spec.story", typeof(Some))] 35 | public void ShouldNotBeConsidiredEqual(string fileName, Type typeToMatch) 36 | { 37 | IFileMatcher matcher = new IgnoreSpaceAndUnderScoreMatcher(typeToMatch); 38 | Assert.IsFalse(matcher.IsMatch(fileName)); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/LoadAndParseScenarioFilesSpec.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NBehave.Configuration; 3 | using NBehave.Internal; 4 | using NUnit.Framework; 5 | 6 | namespace NBehave.Specifications 7 | { 8 | [TestFixture] 9 | public class LoadAndParseScenarioFilesSpec 10 | { 11 | private LoadScenarioFiles loadScenarioFiles; 12 | private NBehaveConfiguration config; 13 | private ParseScenarioFiles parseScenarioFiles; 14 | private IEnumerable features; 15 | 16 | private void CreateLoaderAndParser() 17 | { 18 | loadScenarioFiles = new LoadScenarioFiles(config); 19 | parseScenarioFiles = new ParseScenarioFiles(config); 20 | var files = loadScenarioFiles.LoadFiles(); 21 | features = parseScenarioFiles.LoadFiles(files); 22 | } 23 | 24 | [Test] 25 | public void ShouldBeAbleToUseRelativePathsWithDots() 26 | { 27 | config = ConfigurationNoAppDomain.New.SetScenarioFiles(new[] { @"./*.feature" }); 28 | 29 | CreateLoaderAndParser(); 30 | CollectionAssert.IsNotEmpty(features); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly : AssemblyTitle("NBehave.Framework.Tests")] 5 | // The following GUID is for the ID of the typelib if this project is exposed to COM 6 | 7 | [assembly : Guid("7565bb09-bc32-4bd0-8549-2a5cc5fefb76")] -------------------------------------------------------------------------------- /src/NBehave.Specifications/ScenarioContextSpec.cs: -------------------------------------------------------------------------------- 1 | using NBehave.Internal; 2 | using NUnit.Framework; 3 | 4 | namespace NBehave.Specifications 5 | { 6 | [TestFixture] 7 | public class ScenarioContextSpec 8 | { 9 | [SetUp] 10 | public void Initialize() 11 | { 12 | NBehaveInitializer.Initialize(ConfigurationNoAppDomain.New); 13 | } 14 | 15 | [Test] 16 | public void Should_retrieve_set_value_with_type() 17 | { 18 | var context = ScenarioContext.Current; 19 | context["Foo2"] = "Hello2"; 20 | object value = context.Get("Foo2"); 21 | Assert.AreEqual("Hello2", value); 22 | } 23 | 24 | [Test] 25 | public void Should_TryGet_value_when_item_exists_returns_true_and_out_param_has_value() 26 | { 27 | ScenarioContext.Current["hasValue"] = 42; 28 | int value; 29 | var result = ScenarioContext.Current.TryGet("hasValue", out value); 30 | Assert.IsTrue(result); 31 | Assert.AreEqual(42, value); 32 | } 33 | 34 | [Test] 35 | public void Should_get_same_instance_of_context_when_using_Current() 36 | { 37 | var context1 = ScenarioContext.Current; 38 | context1["Foo3"] = "same"; 39 | var context2 = ScenarioContext.Current; 40 | var value = context2["Foo3"]; 41 | Assert.AreEqual("same", value); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /src/NBehave.Specifications/StringExtensionsSpec.cs: -------------------------------------------------------------------------------- 1 | using NBehave.Extensions; 2 | using NUnit.Framework; 3 | 4 | namespace NBehave.Specifications 5 | { 6 | [TestFixture] 7 | public class StringExtensionsSpec 8 | { 9 | [Test] 10 | public void ShouldRemoveFirstWordWhenFirstCharIsNotWhitespace() 11 | { 12 | const string str = "one two"; 13 | Assert.That(str.RemoveFirstWord(), Is.EqualTo("two")); 14 | } 15 | 16 | [Test] 17 | public void ShouldRemoveFirstWordWhenFirstCharIsAWhitespace() 18 | { 19 | const string str = "\tone two"; 20 | Assert.That(str.RemoveFirstWord(), Is.EqualTo("two")); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/NBehave.Specifications/System.Specs/Backgrounds/Background.feature: -------------------------------------------------------------------------------- 1 | Feature: Support for background sections 2 | As a NBehave user 3 | I want to be able to declare background sections 4 | So that I can add context to my scenarios 5 | 6 | Background: can have title 7 | Given this background section declaration 8 | And this one 9 | 10 | Scenario: Running a feature file with a background section 11 | Given this scenario under the context of a background section 12 | When the scenario with a background section is executed 13 | Then the background section steps should be called before this scenario -------------------------------------------------------------------------------- /src/NBehave.Specifications/System.Specs/Examples/Examples.feature: -------------------------------------------------------------------------------- 1 | Feature: Support for examples 2 | As a NBehave user 3 | I want to be able to declare examples 4 | So that I can template my scenarios 5 | 6 | Scenario: Running a feature file with a examples section 7 | Given this scenario containing examples [col1] 8 | When the scenario is executed [col2] 9 | Then it should be templated and executed with each [row] 10 | 11 | Examples: 12 | | col1 | col2 | row | 13 | | 1 | 2 | 3 | 14 | | 2 | 4 | 6 | 15 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/System.Specs/Examples/ExamplesWithPendingSteps.feature: -------------------------------------------------------------------------------- 1 | Feature: Support for examples 2 | As a NBehave user 3 | I want to be able to declare examples 4 | So that I can template my scenarios 5 | 6 | Scenario: Running a feature file with a examples section and no action steps 7 | Given this scenario with no action step containing examples [col1] 8 | When the scenario with no action step is executed [col2] 9 | Then it should be marked as pending 10 | 11 | Examples: 12 | | col1 | col2 | row | 13 | | 1 | 2 | 3 | 14 | | 2 | 4 | 6 | 15 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/System.Specs/Examples/WhenRunningAScenarioWithExamples.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using NBehave.Extensions; 3 | using NUnit.Framework; 4 | 5 | namespace NBehave.Specifications.System.Specs.Examples 6 | { 7 | [TestFixture] 8 | public class WhenRunningAScenarioWithScenarioOutlines : SystemTestContext 9 | { 10 | private FeatureResults _results; 11 | 12 | protected override void EstablishContext() 13 | { 14 | Configure_With(Path.Combine("System.Specs", "Examples", "Examples.feature")); 15 | } 16 | 17 | protected override void Because() 18 | { 19 | _results = _config.Build().Run(); 20 | } 21 | 22 | [Test] 23 | public void AllStepsShouldPass() 24 | { 25 | Assert.That(_results.NumberOfPassingScenarios, Is.EqualTo(1)); 26 | } 27 | } 28 | 29 | [ActionSteps] 30 | public class ScenarioOutlineSteps 31 | { 32 | [Given("this scenario containing examples $col1")] 33 | public void Given(int col1) 34 | { 35 | } 36 | 37 | [When("the scenario is executed $col2")] 38 | public void When(int col2) 39 | { 40 | } 41 | 42 | [Then("it should be templated and executed with each $row")] 43 | public void Then(int row) 44 | { 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/System.Specs/Examples/WhenRunningAScenarioWithExamplesButNoActionSteps.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 3 | using System.Linq; 4 | using NBehave.Extensions; 5 | using NUnit.Framework; 6 | 7 | namespace NBehave.Specifications.System.Specs.Examples 8 | { 9 | [TestFixture] 10 | public class WhenRunningAScenarioWithScenarioOutlinesButNoActionSteps : SystemTestContext 11 | { 12 | private FeatureResults _results; 13 | 14 | protected override void EstablishContext() 15 | { 16 | Configure_With(Path.Combine("System.Specs", "Examples", "ExamplesWithPendingSteps.feature")); 17 | } 18 | 19 | protected override void Because() 20 | { 21 | _results = _config.Build().Run(); 22 | } 23 | 24 | [Test] 25 | public void ItShouldMarkAllResultsAsPending() 26 | { 27 | IEnumerable enumerable = _results.First().ScenarioResults.First().StepResults.Select(result => result.Result).ToList(); 28 | CollectionAssert.AllItemsAreInstancesOfType(enumerable, typeof (Pending)); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/System.Specs/ExamplesWithTables/ExamplesWithTables.feature: -------------------------------------------------------------------------------- 1 | Feature: Support for scenario outlines with tables 2 | As a NBehave user 3 | I want to be able to declare scenario outlines with tables 4 | So that I can template my scenarios which have tables 5 | 6 | Scenario: Running a feature file with a scenario section 7 | Given this scenario containing scenario outline and a table: 8 | | left | right | 9 | | [left] | [right] | 10 | When the tabled scenario outline is executed 11 | Then the table should be templated into the scenario outline and executed with each row: 12 | | sum | 13 | | [sum] | 14 | 15 | Examples: 16 | | left | right | sum | 17 | | 1 | 2 | 3 | 18 | | 2 | 4 | 6 | 19 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/System.Specs/ExamplesWithTables/WhenRunningAScenarioWithExamples.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using NBehave.Extensions; 3 | using NUnit.Framework; 4 | using Should; 5 | 6 | namespace NBehave.Specifications.System.Specs.ExamplesWithTables 7 | { 8 | [TestFixture] 9 | public class WhenRunningAScenarioWithExamplesAndTables : SystemTestContext 10 | { 11 | private FeatureResults _results; 12 | 13 | protected override void EstablishContext() 14 | { 15 | Configure_With(Path.Combine("System.Specs", "ExamplesWithTables", "ExamplesWithTables.feature")); 16 | } 17 | 18 | protected override void Because() 19 | { 20 | _results = _config.Build().Run(); 21 | } 22 | 23 | [Test] 24 | public void AllStepsShouldPass() 25 | { 26 | Assert.That(_results.NumberOfPassingScenarios, Is.EqualTo(1)); 27 | } 28 | } 29 | 30 | [ActionSteps] 31 | public class ExamplesWithTableSteps 32 | { 33 | private int _left; 34 | private int _right; 35 | 36 | [Given("this scenario containing scenario outline and a table:")] 37 | public void Given(int left, int right) 38 | { 39 | _left = left; 40 | _right = right; 41 | } 42 | 43 | [When("the tabled scenario outline is executed")] 44 | public void When() 45 | { 46 | } 47 | 48 | [Then("the table should be templated into the scenario outline and executed with each row:")] 49 | public void Then(int sum) 50 | { 51 | sum.ShouldEqual(_left + _right); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/System.Specs/Scenarios/Scenario.feature: -------------------------------------------------------------------------------- 1 | Feature: Support for scenarios 2 | As a NBehave user 3 | I want to be able to declare scenarios 4 | So that I can test my features 5 | 6 | Scenario: Running a feature file with a scenario 7 | Given this plain scenario 8 | When this plain scenario is executed 9 | Then this plain scenario should pass 10 | 11 | Scenario: Running a feature file with multiple scenarios 12 | Given this second scenario 13 | When the second scenario is executed 14 | Then it should also pass -------------------------------------------------------------------------------- /src/NBehave.Specifications/System.Specs/Scenarios/ScenarioWithArguments.feature: -------------------------------------------------------------------------------- 1 | Feature: Support for scenarios 2 | As a NBehave user 3 | I want to be able to declare scenarios 4 | So that I can test my features 5 | 6 | Scenario: Running a feature file with a scenario that has arguments 7 | Given a scenario that has arguments 8 | When the scenario with arguments is executed 9 | Then the scenario with arguments should pass -------------------------------------------------------------------------------- /src/NBehave.Specifications/System.Specs/Scenarios/ScenarioWithFailingStep.feature: -------------------------------------------------------------------------------- 1 | Feature: Support for scenarios 2 | As a NBehave user 3 | I want to be able to declare scenarios 4 | So that I can test my features 5 | 6 | Scenario: Running a feature file with a scenario that has a failing step 7 | Given this failing scenario 8 | When this failing scenario is executed 9 | Then the failing scenario should display an error message -------------------------------------------------------------------------------- /src/NBehave.Specifications/System.Specs/Scenarios/ScenarioWithoutFeature.feature: -------------------------------------------------------------------------------- 1 | Scenario: Running a feature file with a scenario 2 | Given this featureless scenario 3 | When this featureless scenario is executed 4 | Then the user should be notified that this is not valid 5 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/System.Specs/Scenarios/WhenRunningAScenarioWithAFailingStep.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using NBehave.Extensions; 3 | using NUnit.Framework; 4 | using Should; 5 | 6 | namespace NBehave.Specifications.System.Specs.Scenarios 7 | { 8 | [TestFixture] 9 | public class WhenRunningAScenarioWithAFailingStep : SystemTestContext 10 | { 11 | private FeatureResults _results; 12 | 13 | protected override void EstablishContext() 14 | { 15 | Configure_With(Path.Combine("System.Specs", "Scenarios", "ScenarioWithFailingStep.feature")); 16 | } 17 | 18 | protected override void Because() 19 | { 20 | _results = _config.Build().Run(); 21 | } 22 | 23 | [Test] 24 | public void ShouldDisplayErrorMessageForFailingStep() 25 | { 26 | Assert.That(_results.NumberOfFailingScenarios, Is.EqualTo(1)); 27 | StringAssert.StartsWith("Should.Core.Exceptions.EqualException", _results[0].ScenarioResults[0].Message); 28 | } 29 | } 30 | 31 | [ActionSteps] 32 | public class ScenarioStepsWithFailingStep 33 | { 34 | [Given("this failing scenario")] 35 | public void Given() 36 | { 37 | } 38 | 39 | [When("this failing scenario is executed")] 40 | public void When() 41 | { 42 | } 43 | 44 | [Then("the failing scenario should display an error message")] 45 | public void Then() 46 | { 47 | 1.ShouldEqual(2); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/System.Specs/Scenarios/WhenRunningAScenarioWithArguments.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using NBehave.Extensions; 3 | using NUnit.Framework; 4 | 5 | namespace NBehave.Specifications.System.Specs.Scenarios 6 | { 7 | [TestFixture] 8 | public class WhenRunningAScenarioWithArguments : SystemTestContext 9 | { 10 | private FeatureResults _results; 11 | 12 | protected override void EstablishContext() 13 | { 14 | Configure_With(Path.Combine("System.Specs", "Scenarios", "ScenarioWithArguments.feature")); 15 | } 16 | 17 | protected override void Because() 18 | { 19 | _results = _config.Build().Run(); 20 | } 21 | 22 | [Test] 23 | public void AllStepsShouldPass() 24 | { 25 | Assert.That(_results.NumberOfPassingScenarios, Is.EqualTo(1)); 26 | } 27 | } 28 | 29 | [ActionSteps] 30 | public class ScenarioStepsWithArguments 31 | { 32 | [Given("a scenario that has $arguments")] 33 | public void Given(string arguments) 34 | { 35 | Assert.That(arguments, Is.EqualTo("arguments")); 36 | } 37 | 38 | [When("the scenario with arguments is $executed")] 39 | public void When(string executed) 40 | { 41 | Assert.That(executed, Is.EqualTo("executed")); 42 | } 43 | 44 | [Then(@"the scenario with arguments should $pass")] 45 | public void Then(string pass) 46 | { 47 | Assert.That(pass, Is.EqualTo("pass")); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/System.Specs/Scenarios/WhenRunningAScenarioWithoutAFeature.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using NBehave.Extensions; 3 | using NUnit.Framework; 4 | 5 | namespace NBehave.Specifications.System.Specs.Scenarios 6 | { 7 | [TestFixture] 8 | public class WhenRunningAScenarioWithoutAFeature : SystemTestContext 9 | { 10 | private FeatureResults result; 11 | 12 | protected override void EstablishContext() 13 | { 14 | Configure_With(Path.Combine("System.Specs", "Scenarios", "ScenarioWithoutFeature.feature")); 15 | } 16 | 17 | protected override void Because() 18 | { 19 | result = _config.Build().Run(); 20 | } 21 | 22 | [Test] 23 | public void AllStepsShouldPass() 24 | { 25 | Assert.That(result.NumberOfPassingScenarios, Is.GreaterThan(0)); 26 | Assert.That(result.NumberOfFailingScenarios, Is.EqualTo(0)); 27 | Assert.That(result.NumberOfPendingScenarios, Is.EqualTo(0)); 28 | } 29 | } 30 | 31 | [ActionSteps] 32 | public class ScenarioStepsWithoutFeature 33 | { 34 | [Given("this featureless scenario")] 35 | public void Given() 36 | { 37 | } 38 | 39 | [When("this featureless scenario is executed")] 40 | public void When() 41 | { 42 | } 43 | 44 | [Then("the user should be notified that this is not valid")] 45 | public void Then() 46 | { 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/NBehave.Specifications/System.Specs/SystemTestContext.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using NBehave.Configuration; 3 | using NUnit.Framework; 4 | 5 | namespace NBehave.Specifications.System.Specs 6 | { 7 | public class SystemTestContext 8 | { 9 | protected NBehaveConfiguration _config; 10 | 11 | [SetUp] 12 | public void SetUp() 13 | { 14 | EstablishContext(); 15 | Because(); 16 | } 17 | 18 | 19 | protected void Configure_With(params string[] featureFiles) 20 | { 21 | _config = ConfigurationNoAppDomain 22 | .New 23 | .SetAssemblies(new[] { Path.GetFileName(GetType().Assembly.Location) }) 24 | .SetEventListener(NBehave.EventListeners.EventListeners.NullEventListener()) 25 | .SetScenarioFiles(featureFiles); 26 | } 27 | 28 | protected virtual void Because() 29 | { 30 | } 31 | 32 | protected virtual void EstablishContext() 33 | { 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/NBehave.Specifications/System.Specs/Tables/TableScenario.feature: -------------------------------------------------------------------------------- 1 | Feature: Support for tables 2 | As a NBehave user 3 | I want to be able to declare tables 4 | So that I can test scenario using tabular data 5 | 6 | Scenario: Running a feature file with a scenario that uses tables 7 | Given this tabled scenario: 8 | | Latin | English | 9 | | Cucumis sativus | Cucumber | 10 | | Cucumis anguria | Burr Gherkin | 11 | When this tabled scenario is executed 12 | Then this tabled scenario should pass: 13 | | Latin | English | 14 | | Cucumis sativus | Cucumber | 15 | | Cucumis anguria | Burr Gherkin | -------------------------------------------------------------------------------- /src/NBehave.Specifications/System.Specs/Tags/Tags.feature: -------------------------------------------------------------------------------- 1 | @Tag1 @Tag2 2 | Feature: Support for scenarios 3 | As a NBehave user 4 | I want to be able to declare scenarios 5 | So that I can test my features 6 | 7 | @Tag3 @Tag4 8 | Scenario: Scenario1 9 | Given this plain scenario 10 | When this plain scenario is executed 11 | Then this plain scenario should pass 12 | 13 | @Tag3 14 | Scenario: Scenario2 15 | Given this second scenario 16 | When the second scenario is executed 17 | Then it should also pass -------------------------------------------------------------------------------- /src/NBehave.Specifications/Text/ExampleColumnsSpec.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using NUnit.Framework; 3 | 4 | namespace NBehave.Narrator.Framework.Specifications.Text 5 | { 6 | [TestFixture] 7 | public class ExampleColumnsSpec 8 | { 9 | [Test] 10 | public void ShouldBeSerializable() 11 | { 12 | var e = new ExampleColumns(new[] { "a", "b" }); 13 | var ser = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); 14 | using (var ms = new MemoryStream()) 15 | ser.Serialize(ms, e); 16 | Assert.IsTrue(true, "Serialization succeded"); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/NBehave.Specifications/Text/ExampleSpec.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 3 | using NUnit.Framework; 4 | 5 | namespace NBehave.Narrator.Framework.Specifications.Text 6 | { 7 | [TestFixture] 8 | public class ExampleSpec 9 | { 10 | [Test] 11 | public void ShouldBeSerializable() 12 | { 13 | var e = new Example(new ExampleColumns(new[] { "a" }), new Dictionary { { "a", "a" } }); 14 | var ser = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); 15 | using (var ms = new MemoryStream()) 16 | ser.Serialize(ms, e); 17 | Assert.IsTrue(true, "Serialization succeded"); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/NBehave.Specifications/paket.references: -------------------------------------------------------------------------------- 1 | NUnit 2 | RhinoMocks 3 | Should -------------------------------------------------------------------------------- /src/NBehave.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nbehave/NBehave/b671008dc814f59ed15272e02e88421c543ae773/src/NBehave.snk -------------------------------------------------------------------------------- /src/NBehave/Attributes/ActionStepsAttribute.cs: -------------------------------------------------------------------------------- 1 | using JetBrains.Annotations; 2 | 3 | using System; 4 | 5 | namespace NBehave 6 | { 7 | [AttributeUsage(AttributeTargets.Class)] 8 | [MeansImplicitUse] 9 | public class ActionStepsAttribute : Attribute 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/NBehave/Attributes/GivenAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave 2 | { 3 | public class GivenAttribute : ActionStepAttribute 4 | { 5 | public GivenAttribute() 6 | { 7 | Type = "Given"; 8 | } 9 | 10 | public GivenAttribute(string regexOrTokenString) 11 | : base(regexOrTokenString) 12 | { 13 | Type = "Given"; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/NBehave/Attributes/ThenAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave 2 | { 3 | public class ThenAttribute : ActionStepAttribute 4 | { 5 | public ThenAttribute() 6 | { 7 | Type = "Then"; 8 | } 9 | 10 | public ThenAttribute(string regexOrTokenString) : base(regexOrTokenString) 11 | { 12 | Type = "Then"; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/NBehave/Attributes/WhenAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave 2 | { 3 | public class WhenAttribute : ActionStepAttribute 4 | { 5 | public WhenAttribute() 6 | { 7 | Type = "When"; 8 | } 9 | 10 | public WhenAttribute(string regexOrTokenString) 11 | : base(regexOrTokenString) 12 | { 13 | Type = "When"; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NBehave/Contracts/IFileMatcher.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.Contracts 2 | { 3 | public interface IFileMatcher 4 | { 5 | bool IsMatch(string fileName); 6 | } 7 | } -------------------------------------------------------------------------------- /src/NBehave/Contracts/IMatchFiles.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.Contracts 2 | { 3 | public interface IMatchFiles 4 | { 5 | IFileMatcher FileMatcher { get; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/NBehave/Domain/BackgroundStepResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave 4 | { 5 | [Serializable] 6 | public class BackgroundStepResult : StepResult 7 | { 8 | public BackgroundStepResult(string backgroundTitle, StepResult result) 9 | : base(result.StringStep, result.Result) 10 | { 11 | BackgroundTitle = backgroundTitle; 12 | } 13 | 14 | public string BackgroundTitle { get; private set; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/NBehave/Domain/ColumnValues.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | namespace NBehave 6 | { 7 | [Serializable] 8 | public class ColumnValues : IEnumerable> 9 | { 10 | private readonly Dictionary values = new Dictionary(); 11 | 12 | public ColumnValues(Dictionary columnValues) 13 | { 14 | foreach (var value in columnValues) 15 | values.Add(value.Key.ToLower(), value.Value); 16 | } 17 | 18 | public string this[string key] 19 | { 20 | get { return values[key.ToLower()]; } 21 | set { values[key.ToLower()] = value; } 22 | } 23 | 24 | public IEnumerator> GetEnumerator() 25 | { 26 | return values.GetEnumerator(); 27 | } 28 | 29 | IEnumerator IEnumerable.GetEnumerator() 30 | { 31 | return GetEnumerator(); 32 | } 33 | 34 | public void Clear() 35 | { 36 | values.Clear(); 37 | } 38 | 39 | public void Add(string key, string value) 40 | { 41 | values.Add(key.ToLower(), value); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /src/NBehave/Domain/ExampleBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace NBehave 5 | { 6 | public static class ExampleBuilder 7 | { 8 | public static Example BuildFromString(string str) 9 | { 10 | var cols = str.Trim().Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); 11 | var columnNames = BuildColumnNames(cols); 12 | var columnValues = BuildColumnValues(columnNames, cols); 13 | return new Example(columnNames, columnValues); 14 | } 15 | 16 | private static ExampleColumns BuildColumnNames(string[] cols) 17 | { 18 | var theMiddle = cols.Length / 2; 19 | var columnNames = new ExampleColumns(); 20 | for (int i = 0; i < theMiddle; i++) 21 | columnNames.Add(new ExampleColumn(cols[i].Trim())); 22 | return columnNames; 23 | } 24 | 25 | private static Dictionary BuildColumnValues(ExampleColumns columnNames, string[] cols) 26 | { 27 | var theMiddle = cols.Length / 2; 28 | var columnValues = new Dictionary(); 29 | for (int i = 0; i < theMiddle; i++) 30 | { 31 | string value = cols[1 + i + theMiddle].Trim(); 32 | columnValues.Add(columnNames[i].Name, value); 33 | } 34 | return columnValues; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/NBehave/Domain/ExampleColumn.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave 4 | { 5 | [Serializable] 6 | public class ExampleColumn : IEquatable 7 | { 8 | public string Name { get; private set; } 9 | 10 | public ExampleColumn(string name) 11 | { 12 | if (string.IsNullOrEmpty(name)) 13 | throw new ArgumentNullException("name"); 14 | Name = name; 15 | } 16 | 17 | public bool Equals(ExampleColumn other) 18 | { 19 | if (ReferenceEquals(null, other)) return false; 20 | if (ReferenceEquals(this, other)) return true; 21 | return Equals(other.Name, Name); 22 | } 23 | 24 | public override bool Equals(object obj) 25 | { 26 | if (ReferenceEquals(null, obj)) return false; 27 | if (ReferenceEquals(this, obj)) return true; 28 | if (obj.GetType() != typeof (ExampleColumn)) return false; 29 | return Equals((ExampleColumn) obj); 30 | } 31 | 32 | public override int GetHashCode() 33 | { 34 | return Name.GetHashCode(); 35 | } 36 | 37 | public static bool operator ==(ExampleColumn left, ExampleColumn right) 38 | { 39 | return Equals(left, right); 40 | } 41 | 42 | public static bool operator !=(ExampleColumn left, ExampleColumn right) 43 | { 44 | return !Equals(left, right); 45 | } 46 | 47 | public override string ToString() 48 | { 49 | return Name; 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /src/NBehave/Domain/ExampleColumns.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace NBehave 5 | { 6 | [Serializable] 7 | public class ExampleColumns : List 8 | { 9 | public ExampleColumns() 10 | { 11 | } 12 | 13 | public ExampleColumns(IEnumerable columns) 14 | : base(columns) 15 | { 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/NBehave/Domain/Result.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave 4 | { 5 | [Serializable] 6 | public class Passed : Result 7 | { 8 | public Passed() 9 | : base(string.Empty) 10 | { 11 | } 12 | } 13 | 14 | [Serializable] 15 | public class Failed : Result 16 | { 17 | public WrappedException Exception { get; private set; } 18 | 19 | public Failed(Exception exception) 20 | : base(exception.ToString()) 21 | { 22 | Exception = new WrappedException(exception); 23 | } 24 | } 25 | 26 | [Serializable] 27 | public class Pending : Result 28 | { 29 | public Pending(string pendingReason) 30 | : base(pendingReason) 31 | { 32 | } 33 | } 34 | 35 | [Serializable] 36 | public class PendingNotImplemented : Pending 37 | { 38 | public PendingNotImplemented(string pendingReason) 39 | : base(pendingReason) 40 | { 41 | } 42 | } 43 | 44 | [Serializable] 45 | public class Skipped : Pending 46 | { 47 | public Skipped(string message) 48 | : base(message) 49 | { 50 | } 51 | } 52 | 53 | [Serializable] 54 | public abstract class Result 55 | { 56 | protected Result(string message) 57 | { 58 | Message = message; 59 | } 60 | 61 | private string _message; 62 | public string Message 63 | { 64 | get { return _message; } 65 | protected set { _message = value; } 66 | } 67 | 68 | public override string ToString() 69 | { 70 | return GetType().Name.Replace(typeof(Result).Name, string.Empty).ToLower(); 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /src/NBehave/Domain/StepResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave 4 | { 5 | [Serializable] 6 | public class StepResult : Result 7 | { 8 | public StepResult(StringStep stringStep, Result resultForActionStep) 9 | : base(resultForActionStep.Message) 10 | { 11 | StringStep = stringStep; 12 | Result = resultForActionStep; 13 | } 14 | 15 | public StringStep StringStep { get; private set; } 16 | public Result Result { get; private set; } 17 | 18 | public void MergeResult(Result stepResult) 19 | { 20 | if (stepResult is Passed) 21 | { 22 | return; 23 | } 24 | 25 | if (stepResult is Pending && Result is Passed) 26 | { 27 | Result = stepResult; 28 | Message = stepResult.Message; 29 | } 30 | 31 | if (stepResult is Failed && (Result is Passed || Result is Pending)) 32 | { 33 | Result = stepResult; 34 | Message = stepResult.Message; 35 | } 36 | 37 | if (Result == null) 38 | { 39 | Result = stepResult; 40 | Message = stepResult.Message; 41 | } 42 | } 43 | 44 | public override string ToString() 45 | { 46 | return Result.ToString(); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/NBehave/Domain/TypeOfStep.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave 2 | { 3 | public enum TypeOfStep 4 | { 5 | Given, 6 | When, 7 | Then, 8 | Unknown 9 | } 10 | } -------------------------------------------------------------------------------- /src/NBehave/EventListeners/BackgroundWriter.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 3 | using System.Linq; 4 | 5 | namespace NBehave.EventListeners 6 | { 7 | public class BackgroundWriter 8 | { 9 | private readonly TextWriter writer; 10 | 11 | public BackgroundWriter(TextWriter writer) 12 | { 13 | this.writer = writer; 14 | } 15 | 16 | public void Write(IEnumerable backgroundSteps) 17 | { 18 | writer.WriteLine("Background: " + backgroundSteps.First().BackgroundTitle); 19 | foreach (var step in backgroundSteps) 20 | writer.WriteLine(" " + step.StringStep); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/NBehave/EventListeners/ConsoleWriter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace NBehave.EventListeners 5 | { 6 | public class ConsoleWriter : IOutputWriter 7 | { 8 | public TextWriter Out { get { return Console.Out; } } 9 | 10 | public void ResetColor() 11 | { 12 | Console.ResetColor(); 13 | } 14 | 15 | public void WriteLine() 16 | { 17 | Console.WriteLine(); 18 | } 19 | 20 | public void WriteLine(string str) 21 | { 22 | Console.WriteLine(str); 23 | } 24 | 25 | public void WriteColorString(string text, ConsoleColor color) 26 | { 27 | var currentColor = Console.ForegroundColor; 28 | Console.ForegroundColor = color; 29 | WriteLine(text); 30 | Console.ForegroundColor = currentColor; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/NBehave/EventListeners/EventListener.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.EventListeners 4 | { 5 | public abstract class EventListener : MarshalByRefObject, IEventListener 6 | { 7 | public virtual void FeatureStarted(Feature feature) 8 | { } 9 | 10 | public virtual void FeatureFinished(FeatureResult result) 11 | { 12 | } 13 | 14 | public virtual void ScenarioStarted(string scenarioTitle) 15 | { 16 | } 17 | 18 | public virtual void ScenarioFinished(ScenarioResult result) 19 | { 20 | } 21 | 22 | public virtual void RunStarted() 23 | { 24 | } 25 | 26 | public virtual void RunFinished() 27 | { 28 | } 29 | 30 | public override object InitializeLifetimeService() 31 | { 32 | return null; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/NBehave/EventListeners/FailSpecResultEventListener.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace NBehave.EventListeners 7 | { 8 | public class FailSpecResultEventListener : EventListener 9 | { 10 | private readonly List _results = new List(); 11 | 12 | public override void RunFinished() 13 | { 14 | var failedScenarios = _results.Where(_ => _.Result is Failed).ToList(); 15 | if (failedScenarios.Any() == false) 16 | return; 17 | var errors = new StringBuilder(); 18 | foreach (var failedScenario in failedScenarios) 19 | { 20 | errors.Append(string.Format("Scenario {0} failed", failedScenario.ScenarioTitle)); 21 | errors.Append(Environment.NewLine); 22 | foreach (var error in failedScenario.StepResults.Where(_ => _.Result is Failed)) 23 | { 24 | errors.AppendLine(string.Format("Step '{0}' failed with result:", error.StringStep)); 25 | errors.AppendLine(error.Result.Message); 26 | errors.Append(Environment.NewLine); 27 | } 28 | errors.Append(Environment.NewLine); 29 | } 30 | throw new StepFailedException(errors.ToString()); 31 | } 32 | 33 | public override void ScenarioFinished(ScenarioResult result) 34 | { 35 | _results.Add(result); 36 | } 37 | } 38 | 39 | public class StepFailedException : Exception 40 | { 41 | public StepFailedException(string message) 42 | : base(message) 43 | { 44 | 45 | } 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /src/NBehave/EventListeners/IEventListener.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.EventListeners 2 | { 3 | public interface IEventListener 4 | { 5 | void RunStarted(); 6 | void FeatureStarted(Feature feature); 7 | void FeatureFinished(FeatureResult result); 8 | void ScenarioStarted(string scenarioTitle); 9 | void ScenarioFinished(ScenarioResult result); 10 | void RunFinished(); 11 | } 12 | } -------------------------------------------------------------------------------- /src/NBehave/EventListeners/IOutputWriter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace NBehave.EventListeners 5 | { 6 | public interface IOutputWriter 7 | { 8 | TextWriter Out { get; } 9 | void ResetColor(); 10 | void WriteLine(); 11 | void WriteLine(string str); 12 | void WriteColorString(string text, ConsoleColor color); 13 | } 14 | } -------------------------------------------------------------------------------- /src/NBehave/EventListeners/MultiOutputEventListener.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.EventListeners 4 | { 5 | public class MultiOutputEventListener : EventListener 6 | { 7 | private readonly IEventListener[] listeners; 8 | 9 | public MultiOutputEventListener(params IEventListener[] listeners) 10 | { 11 | this.listeners = listeners; 12 | } 13 | 14 | public IEventListener[] Listeners 15 | { 16 | get { return listeners; } 17 | } 18 | 19 | public override void FeatureStarted(Feature feature) 20 | { 21 | Invoke(l => l.FeatureStarted(feature)); 22 | } 23 | 24 | public override void ScenarioStarted(string scenarioTitle) 25 | { 26 | Invoke(l => l.ScenarioStarted(scenarioTitle)); 27 | } 28 | 29 | public override void RunStarted() 30 | { 31 | Invoke(l => l.RunStarted()); 32 | } 33 | 34 | public override void RunFinished() 35 | { 36 | Invoke(l => l.RunFinished()); 37 | } 38 | 39 | public override void FeatureFinished(FeatureResult result) 40 | { 41 | Invoke(l => l.FeatureFinished(result)); 42 | } 43 | 44 | public override void ScenarioFinished(ScenarioResult result) 45 | { 46 | Invoke(l => l.ScenarioFinished(result)); 47 | } 48 | 49 | private void Invoke(Action f) 50 | { 51 | foreach (var listener in listeners) 52 | { 53 | f(listener); 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/NBehave/EventListeners/NullEventListener.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.EventListeners 2 | { 3 | public class NullEventListener : EventListener 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/NBehave/EventListeners/Xml/EventReceived.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.EventListeners.Xml 4 | { 5 | public class EventReceived 6 | { 7 | public EventReceived(string message, EventType eventType) 8 | { 9 | Message = message; 10 | EventType = eventType; 11 | Time = DateTime.Now; 12 | } 13 | 14 | public EventType EventType { get; set; } 15 | 16 | public string Message { get; set; } 17 | 18 | public DateTime Time { get; set; } 19 | 20 | public override string ToString() 21 | { 22 | return string.Format("{0} : {1}", EventType, Message); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/NBehave/EventListeners/Xml/EventType.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.EventListeners.Xml 2 | { 3 | public enum EventType 4 | { 5 | RunStart, 6 | RunFinished, 7 | FeatureStart, 8 | FeatureNarrative, 9 | FeatureFinished, 10 | ScenarioStart, 11 | ScenarioResult 12 | } 13 | } -------------------------------------------------------------------------------- /src/NBehave/EventListeners/Xml/StoryResultsEventReceived.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.EventListeners.Xml 2 | { 3 | public class ScenarioResultEventReceived : EventReceived 4 | { 5 | public ScenarioResultEventReceived(ScenarioResult results) 6 | : base(string.Empty, EventType.ScenarioResult) 7 | { 8 | ScenarioResult = results; 9 | } 10 | 11 | public ScenarioResult ScenarioResult { get; private set; } 12 | } 13 | } -------------------------------------------------------------------------------- /src/NBehave/Extensions/EnumerableExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace NBehave.Extensions 5 | { 6 | public static class EnumerableExtensions 7 | { 8 | public static void Each(this IEnumerable list, Action action) 9 | { 10 | foreach (var item in list) 11 | { 12 | action(item); 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NBehave/Extensions/NBehaveConfigurationExtensions.cs: -------------------------------------------------------------------------------- 1 | using NBehave.Configuration; 2 | using NBehave.Internal; 3 | 4 | namespace NBehave.Extensions 5 | { 6 | public static class NBehaveConfigurationExtensions 7 | { 8 | public static IRunner Build(this NBehaveConfiguration configuration) 9 | { 10 | return RunnerFactory.CreateTextRunner(configuration); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NBehave/Extensions/ReflectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | 5 | namespace NBehave.Extensions 6 | { 7 | public static class ReflectionExtensions 8 | { 9 | public static bool IsGenericIEnumerable(this ParameterInfo paramType) 10 | { 11 | if (paramType.ParameterType.IsGenericType == false) 12 | { 13 | return false; 14 | } 15 | 16 | var genericArgument = paramType.GetGenericArgument(); 17 | 18 | var ien = typeof(List<>).CreateGenericInstance(genericArgument); 19 | return paramType.ParameterType.IsAssignableFrom(ien.GetType()); 20 | } 21 | 22 | public static Type GetGenericArgument(this ParameterInfo paramType) 23 | { 24 | var genericArgs = paramType.ParameterType.GetGenericArguments(); 25 | if (genericArgs.Length > 1) 26 | { 27 | throw new NotSupportedException("Sorry, nbehave only supports one generic parameter"); 28 | } 29 | return genericArgs[0]; 30 | } 31 | 32 | public static object CreateInstanceOfGenericList(this Type parameterType) 33 | { 34 | return typeof(List<>).CreateGenericInstance(parameterType); 35 | } 36 | 37 | public static object CreateGenericInstance(this Type generic, Type innerType) 38 | { 39 | var specificType = generic.MakeGenericType(new[] { innerType }); 40 | return Activator.CreateInstance(specificType, null); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/NBehave/Extensions/StoryRunnerFilterExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.RegularExpressions; 3 | using NBehave.Internal; 4 | 5 | namespace NBehave.Extensions 6 | { 7 | public static class In 8 | { 9 | public static StoryRunnerFilter Context() 10 | { 11 | return new StoryRunnerFilter().And(); 12 | } 13 | 14 | public static StoryRunnerFilter GlobalContext() 15 | { 16 | return new StoryRunnerFilter(); 17 | } 18 | } 19 | 20 | public static class StoryRunnerFilterExtensions 21 | { 22 | public static StoryRunnerFilter Context(this StoryRunnerFilter filter) 23 | { 24 | Type type = typeof(TActionStepsClass); 25 | string classFilterValue = filter.ClassNameFilter.UpdateWith(type.Name); 26 | var namespaceFilter = filter.NamespaceFilter.UpdateWith(type.Namespace); 27 | return new StoryRunnerFilter(namespaceFilter, classFilterValue, filter.MethodNameFiler.ToString()); 28 | } 29 | 30 | private static string UpdateWith(this Regex initialFilter, string valueToApply) 31 | { 32 | string filterValue = initialFilter.ToString().TrimStart('^').TrimEnd('$'); 33 | if (filterValue == StoryRunnerFilter.MatchAnything) 34 | return valueToApply; 35 | return filterValue + string.Format("|{0}", valueToApply); 36 | } 37 | 38 | public static StoryRunnerFilter And(this StoryRunnerFilter filter) 39 | { 40 | return filter.Context(); 41 | } 42 | 43 | } 44 | } -------------------------------------------------------------------------------- /src/NBehave/Extensions/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Text.RegularExpressions; 2 | 3 | namespace NBehave.Extensions 4 | { 5 | public static class StringExtensions 6 | { 7 | private static readonly char[] WhiteSpaceChars = new[] { ' ', '\n', '\r', '\t' }; 8 | private static readonly Regex WhiteSpace = new Regex(@"\s"); 9 | 10 | public static string TrimWhiteSpaceChars(this string str) 11 | { 12 | return str.Trim(WhiteSpaceChars); 13 | } 14 | 15 | private static readonly Regex FirstWordRegex = new Regex(@"(\w+|\d+)+", RegexOptions.Compiled); 16 | public static string GetFirstWord(this string str) 17 | { 18 | return FirstWordRegex.Match(str).Value; 19 | } 20 | 21 | public static string RemoveFirstWord(this string tokenString) 22 | { 23 | var tokenStringToMatch = tokenString.TrimStart(); 24 | var firstWhiteSpace = WhiteSpace.Match(tokenStringToMatch); 25 | if (firstWhiteSpace.Success) 26 | { 27 | var posOfFirstSpace = firstWhiteSpace.Index; 28 | return tokenStringToMatch.Substring(posOfFirstSpace + 1).TrimStart(WhiteSpaceChars); 29 | } 30 | 31 | return tokenString; 32 | } 33 | 34 | public static StringStep AsStringStep(this string text, string source) 35 | { 36 | return new StringStep(text.GetFirstWord(), text.RemoveFirstWord(), source); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/NBehave/FeatureContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NBehave.Internal; 3 | 4 | namespace NBehave 5 | { 6 | public class FeatureContext : NBehaveContext 7 | { 8 | public string FeatureTitle { get { return Feature.Title; } } 9 | internal Feature Feature { get; set; } 10 | 11 | public FeatureContext(Feature feature) 12 | { 13 | Feature = feature; 14 | } 15 | 16 | public FeatureContext(Feature feature, IEnumerable tags) 17 | :this(feature) 18 | { 19 | AddTags(tags); 20 | } 21 | 22 | public static FeatureContext Current 23 | { 24 | get { return TinyIoC.TinyIoCContainer.Current.Resolve(); } 25 | } 26 | 27 | public override string ToString() 28 | { 29 | return FeatureTitle; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/NBehave/Hooks/AfterFeatureAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.Hooks 4 | { 5 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field)] 6 | public class AfterFeatureAttribute : HookAttribute { } 7 | } -------------------------------------------------------------------------------- /src/NBehave/Hooks/AfterRunAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.Hooks 4 | { 5 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field)] 6 | public class AfterRunAttribute : HookAttribute { } 7 | } -------------------------------------------------------------------------------- /src/NBehave/Hooks/AfterScenarioAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.Hooks 4 | { 5 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field)] 6 | public class AfterScenarioAttribute : HookAttribute { } 7 | } -------------------------------------------------------------------------------- /src/NBehave/Hooks/AfterStepAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.Hooks 4 | { 5 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field)] 6 | public class AfterStepAttribute : HookAttribute { } 7 | } -------------------------------------------------------------------------------- /src/NBehave/Hooks/BeforeFeatureAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.Hooks 4 | { 5 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field)] 6 | public class BeforeFeatureAttribute : HookAttribute { } 7 | } -------------------------------------------------------------------------------- /src/NBehave/Hooks/BeforeRunAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.Hooks 4 | { 5 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field)] 6 | public class BeforeRunAttribute : HookAttribute { } 7 | } -------------------------------------------------------------------------------- /src/NBehave/Hooks/BeforeScenarioAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.Hooks 4 | { 5 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field)] 6 | public class BeforeScenarioAttribute : HookAttribute { } 7 | } -------------------------------------------------------------------------------- /src/NBehave/Hooks/BeforeStepAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.Hooks 4 | { 5 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field)] 6 | public class BeforeStepAttribute : HookAttribute { } 7 | } -------------------------------------------------------------------------------- /src/NBehave/Hooks/HookAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using JetBrains.Annotations; 3 | 4 | namespace NBehave.Hooks 5 | { 6 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] 7 | [MeansImplicitUse] 8 | public class HookAttribute : Attribute 9 | { 10 | public string[] RunIfHasTags { get; set; } 11 | public string[] DontRunIfHasTags { get; set; } 12 | 13 | protected HookAttribute() 14 | : this(new string[0], new string[0]) 15 | { } 16 | 17 | private HookAttribute(string[] runIfHasTags, string[] dontRunIfHasTags) 18 | { 19 | RunIfHasTags = runIfHasTags; 20 | DontRunIfHasTags = dontRunIfHasTags; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/NBehave/Hooks/HooksAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using JetBrains.Annotations; 3 | 4 | namespace NBehave.Hooks 5 | { 6 | [AttributeUsage(AttributeTargets.Class)] 7 | [MeansImplicitUse] 8 | public class HooksAttribute : Attribute { } 9 | } -------------------------------------------------------------------------------- /src/NBehave/Hooks/LoadHooks.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using NBehave.Configuration; 3 | 4 | namespace NBehave.Hooks 5 | { 6 | public class LoadHooks 7 | { 8 | private readonly NBehaveConfiguration _configuration; 9 | private readonly HooksCatalog _hooks; 10 | 11 | public LoadHooks(NBehaveConfiguration configuration, HooksCatalog hooks) 12 | { 13 | _configuration = configuration; 14 | _hooks = hooks; 15 | } 16 | 17 | public void Initialise() 18 | { 19 | var parser = new HooksParser(_hooks); 20 | 21 | foreach (var assembly in _configuration.Assemblies) 22 | parser.FindHooks(Assembly.LoadFrom(assembly)); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/NBehave/IgnoreSpaceAndUnderScoreMatcher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Text.RegularExpressions; 4 | using NBehave.Contracts; 5 | 6 | namespace NBehave 7 | { 8 | public class IgnoreSpaceAndUnderScoreMatcher : IFileMatcher 9 | { 10 | private readonly string _className; 11 | 12 | public IgnoreSpaceAndUnderScoreMatcher(Type typeToMatch) 13 | { 14 | _className = typeToMatch.Name.Replace("_", string.Empty).Replace(" ", string.Empty); 15 | } 16 | 17 | bool IFileMatcher.IsMatch(string fileName) 18 | { 19 | var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName); 20 | var match = Regex.Match(fileNameWithoutExtension, @"^[\w+_|\s]*$").Value; 21 | var matchWithoutSpaceAndUnderScore = match.Replace("_", string.Empty).Replace(" ", string.Empty); 22 | return _className == matchWithoutSpaceAndUnderScore; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/NBehave/Internal/EventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.Internal 4 | { 5 | public class EventArgs : EventArgs 6 | { 7 | public readonly T EventInfo; 8 | 9 | public EventArgs(T eventInfo) 10 | { 11 | EventInfo = eventInfo; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /src/NBehave/Internal/ExampleRunner.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace NBehave.Internal 6 | { 7 | public class ExampleRunner 8 | { 9 | public ScenarioExampleResult RunExamples(Scenario scenario, 10 | Func, IEnumerable> runSteps, 11 | Action beforeScenario, 12 | Action afterScenario) 13 | { 14 | var exampleResults = new ScenarioExampleResult(scenario.Feature, scenario.Title, scenario.Steps, scenario.Examples); 15 | 16 | foreach (var example in scenario.Examples) 17 | { 18 | beforeScenario(); 19 | var scenarioResult = RunExample(scenario, runSteps, example); 20 | afterScenario(scenario, scenarioResult); 21 | exampleResults.AddResult(scenarioResult); 22 | } 23 | return exampleResults; 24 | } 25 | 26 | private ScenarioResult RunExample(Scenario scenario, Func, IEnumerable> runSteps, Example example) 27 | { 28 | var steps = BuildSteps(scenario, example); 29 | 30 | var scenarioResult = new ScenarioResult(scenario.Feature, scenario.Title); 31 | var stepResults = runSteps(steps); 32 | scenarioResult.AddActionStepResults(stepResults); 33 | return scenarioResult; 34 | } 35 | 36 | private IEnumerable BuildSteps(Scenario scenario, Example example) 37 | { 38 | return scenario.Steps.Select(step => step.BuildStep(example)); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/NBehave/Internal/Gherkin/IListener.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace NBehave.Internal.Gherkin 4 | { 5 | public interface IListener 6 | { 7 | void Feature(Token keyword, Token title, Token narrative); 8 | void Scenario(Token keyword, Token title); 9 | void Examples(Token keyword, Token name); 10 | void Step(Token keyword, Token name); 11 | void Table(IList> rows, LineInFile lineInFile); 12 | void Background(Token keyword, Token name); 13 | void Comment(Token comment); 14 | void Tag(Token name); 15 | void SyntaxError(string state, string @event, IEnumerable legalEvents, LineInFile lineInFile); 16 | void Eof(); 17 | void DocString(Token docString); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/NBehave/Internal/Gherkin/LineInFile.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.Internal.Gherkin 2 | { 3 | public struct LineInFile 4 | { 5 | public readonly int Line; 6 | 7 | public LineInFile(int line) 8 | { 9 | Line = line; 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/NBehave/Internal/Gherkin/ParseException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace NBehave.Internal.Gherkin 5 | { 6 | [Serializable] 7 | public class ParseException : Exception 8 | { 9 | public ParseException(string message, Exception innerException) 10 | : base(message, innerException) 11 | {} 12 | 13 | protected ParseException(SerializationInfo info, StreamingContext ctx) 14 | : base(info, ctx) 15 | { } 16 | 17 | } 18 | } -------------------------------------------------------------------------------- /src/NBehave/Internal/Gherkin/Parser.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using GurkBurk; 3 | 4 | namespace NBehave.Internal.Gherkin 5 | { 6 | public class Parser 7 | { 8 | private readonly IListener listener; 9 | 10 | public Parser(IListener listener) 11 | { 12 | this.listener = listener; 13 | } 14 | 15 | public void Scan(string source) 16 | { 17 | var stream = CreateStream(source); 18 | Scan(stream); 19 | } 20 | 21 | public void Scan(TextReader stream) 22 | { 23 | var feature = stream.ReadToEnd(); 24 | var lexer = new I18nLexer(new GherkinListener(listener)); 25 | try 26 | { 27 | lexer.scan(feature); 28 | } 29 | catch (LexerError e) 30 | { 31 | throw new ParseException(e.Message, e); 32 | } 33 | } 34 | 35 | private TextReader CreateStream(string source) 36 | { 37 | var ms = new MemoryStream(); 38 | var sr = new StreamWriter(ms); 39 | sr.Write(source); 40 | sr.Flush(); 41 | ms.Seek(0, SeekOrigin.Begin); 42 | return new StreamReader(ms); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/NBehave/Internal/Gherkin/StepKind.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.Internal.Gherkin 2 | { 3 | public enum StepKind 4 | { 5 | Given, 6 | When, 7 | Then, 8 | And, 9 | But, 10 | Any, 11 | Unknown, 12 | } 13 | } -------------------------------------------------------------------------------- /src/NBehave/Internal/Gherkin/Token.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.Internal.Gherkin 2 | { 3 | public struct Token 4 | { 5 | public readonly string Content; 6 | public readonly LineInFile LineInFile; 7 | 8 | public Token(string content, LineInFile lineInFile) 9 | { 10 | LineInFile = lineInFile; 11 | Content = content; 12 | } 13 | 14 | public bool Equals(Token other) 15 | { 16 | return LineInFile.Line == other.LineInFile.Line && string.Equals(Content, other.Content); 17 | } 18 | 19 | public override bool Equals(object obj) 20 | { 21 | if (ReferenceEquals(null, obj)) return false; 22 | return obj is Token && Equals((Token) obj); 23 | } 24 | 25 | public override int GetHashCode() 26 | { 27 | unchecked 28 | { 29 | return (LineInFile.GetHashCode() * 397) ^ (Content != null ? Content.GetHashCode() : 0); 30 | } 31 | } 32 | 33 | public static bool operator ==(Token left, Token right) 34 | { 35 | return left.Equals(right); 36 | } 37 | 38 | public static bool operator !=(Token left, Token right) 39 | { 40 | return !left.Equals(right); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/NBehave/Internal/IContextHandler.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.Internal 2 | { 3 | public interface IContextHandler 4 | { 5 | void OnFeatureStartedEvent(Feature feature); 6 | void OnFeatureFinishedEvent(); 7 | void OnScenarioStartedEvent(Scenario scenario); 8 | void OnScenarioFinishedEvent(); 9 | void OnStepStartedEvent(StringStep step); 10 | void OnStepFinishedEvent(); 11 | } 12 | } -------------------------------------------------------------------------------- /src/NBehave/Internal/IFeatureRunner.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.Internal 2 | { 3 | public interface IFeatureRunner 4 | { 5 | FeatureResult Run(Feature feature); 6 | } 7 | } -------------------------------------------------------------------------------- /src/NBehave/Internal/IRunContext.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.Internal 2 | { 3 | public interface IRunContext 4 | { 5 | void RunStarted(); 6 | void RunFinished(FeatureResults results); 7 | void FeatureStarted(Feature feature); 8 | void FeatureFinished(FeatureResult featureResult); 9 | void ScenarioStartedEvent(Scenario scenario); 10 | void ScenarioFinishedEvent(ScenarioResult result); 11 | void StepStarted(StringStep step); 12 | void StepFinished(StepResult stepResult); 13 | } 14 | } -------------------------------------------------------------------------------- /src/NBehave/Internal/IRunContextEvents.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NBehave.Internal 4 | { 5 | public interface IRunContextEvents 6 | { 7 | event EventHandler OnRunStarted; 8 | event EventHandler> OnRunFinished; 9 | event EventHandler> OnFeatureStarted; 10 | event EventHandler> OnFeatureFinished; 11 | event EventHandler> OnScenarioStarted; 12 | event EventHandler> OnScenarioFinished; 13 | event EventHandler> OnStepStarted; 14 | event EventHandler> OnStepFinished; 15 | } 16 | } -------------------------------------------------------------------------------- /src/NBehave/Internal/IRunner.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.Internal 2 | { 3 | public interface IRunner 4 | { 5 | FeatureResults Run(); 6 | } 7 | } -------------------------------------------------------------------------------- /src/NBehave/Internal/IStringStepRunner.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.Internal 2 | { 3 | public interface IStringStepRunner 4 | { 5 | void Run(StringStep step); 6 | } 7 | } -------------------------------------------------------------------------------- /src/NBehave/Internal/LoadScenarioFiles.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using NBehave.Configuration; 6 | 7 | namespace NBehave.Internal 8 | { 9 | public class LoadScenarioFiles 10 | { 11 | private readonly NBehaveConfiguration configuration; 12 | 13 | public LoadScenarioFiles(NBehaveConfiguration configuration) 14 | { 15 | this.configuration = configuration; 16 | } 17 | 18 | public IEnumerable LoadFiles() 19 | { 20 | IEnumerable files = configuration 21 | .ScenarioFiles 22 | .Select(_ => GetFiles(_)) 23 | .SelectMany(_ => _); 24 | return files.ToList(); 25 | } 26 | 27 | private IEnumerable GetFiles(string location) 28 | { 29 | string[] files; 30 | if (Path.IsPathRooted(location)) 31 | { 32 | files = Directory.GetFiles(Path.GetDirectoryName(location), Path.GetFileName(location)); 33 | } 34 | else 35 | { 36 | var absoluteLocation = GetAbsolutePath(location); 37 | var pattern = Path.GetFileName(absoluteLocation); 38 | var path = Path.GetDirectoryName(absoluteLocation); 39 | files = Directory.GetFiles(path, pattern, SearchOption.AllDirectories); 40 | } 41 | 42 | return files; 43 | } 44 | 45 | private string GetAbsolutePath(string location) 46 | { 47 | var directory = Path.GetDirectoryName(location); 48 | var fileName = Path.GetFileName(location); 49 | var fullPath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, directory)); 50 | var fullLocation = Path.Combine(fullPath, fileName); 51 | return fullLocation; 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /src/NBehave/Internal/NBehaveContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace NBehave.Internal 4 | { 5 | public abstract class NBehaveContext : Dictionary 6 | { 7 | private readonly List tags = new List(); 8 | public IEnumerable Tags { get { return tags; } } 9 | 10 | internal void AddTags(IEnumerable tagsToAdd) 11 | { 12 | tags.AddRange(tagsToAdd); 13 | } 14 | 15 | internal void ClearTags() 16 | { 17 | tags.Clear(); 18 | } 19 | 20 | public T Get(string key) 21 | { 22 | return (T)this[key]; 23 | } 24 | 25 | public bool TryGet(string key, out T value) 26 | { 27 | object v; 28 | var hasItem = TryGetValue(key, out v); 29 | value = (T)v; 30 | return hasItem; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/NBehave/Internal/ParseScenarioFiles.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NBehave.Configuration; 3 | using NBehave.TextParsing; 4 | 5 | namespace NBehave.Internal 6 | { 7 | public class ParseScenarioFiles 8 | { 9 | private readonly NBehaveConfiguration configuration; 10 | 11 | public ParseScenarioFiles(NBehaveConfiguration configuration) 12 | { 13 | this.configuration = configuration; 14 | } 15 | 16 | public IEnumerable LoadFiles(IEnumerable files) 17 | { 18 | var textParser = new GherkinScenarioParser(configuration); 19 | var features = new List(); 20 | Feature feature = null; 21 | textParser.FeatureEvent += (s, e) => 22 | { 23 | feature = e.EventInfo; 24 | features.Add(e.EventInfo); 25 | }; 26 | textParser.ScenarioEvent += (s, e) => 27 | { 28 | if (feature == null) 29 | { 30 | feature = e.EventInfo.Feature; 31 | features.Add(feature); 32 | } 33 | }; 34 | foreach (var file in files) 35 | { 36 | feature = null; 37 | textParser.Parse(file); 38 | } 39 | return features; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/NBehave/Internal/RunnerFactory.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Linq; 3 | using NBehave.Configuration; 4 | using NBehave.Remoting; 5 | 6 | namespace NBehave.Internal 7 | { 8 | public static class RunnerFactory 9 | { 10 | public static IRunner CreateTextRunner(NBehaveConfiguration configuration) 11 | { 12 | var assemblyWithConfigFile = configuration.Assemblies 13 | .Where(path => File.Exists(path + ".config")) 14 | .Select(path => path + ".config") 15 | .FirstOrDefault(); 16 | if (assemblyWithConfigFile == null) { 17 | assemblyWithConfigFile = configuration.Assemblies.First() + ".config"; 18 | } 19 | 20 | if (configuration.CreateAppDomain == false) 21 | return new TextRunner(configuration); 22 | 23 | return new AppDomainRunner(configuration, assemblyWithConfigFile); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/NBehave/MatchAllFiles.cs: -------------------------------------------------------------------------------- 1 | using NBehave.Contracts; 2 | 3 | namespace NBehave 4 | { 5 | public class MatchAllFiles : IFileMatcher 6 | { 7 | bool IFileMatcher.IsMatch(string fileName) 8 | { 9 | return true; 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/NBehave/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("NBehave")] 5 | 6 | // The following GUID is for the ID of the typelib if this project is exposed to COM 7 | [assembly: Guid("65b4f572-dfe4-4b4f-8c5e-a74c8918b5f4")] -------------------------------------------------------------------------------- /src/NBehave/Remoting/AppDomainBootstrapper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | 5 | namespace NBehave.Remoting 6 | { 7 | public class AppDomainBootstrapper : MarshalByRefObject 8 | { 9 | private string[] _assemblyProbe; 10 | 11 | public void InitializeDomain(string[] assemblyProbe) 12 | { 13 | _assemblyProbe = assemblyProbe; 14 | AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; 15 | } 16 | 17 | Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) 18 | { 19 | foreach (string basePath in _assemblyProbe) 20 | { 21 | string assemblyFileName = args.Name; 22 | if (args.Name.Contains(",")) 23 | assemblyFileName = args.Name.Split(',')[0]; 24 | string assemblyLocation = Path.Combine(basePath, assemblyFileName); 25 | if (File.Exists(assemblyLocation + ".dll")) 26 | return Assembly.LoadFile(assemblyLocation + ".dll"); 27 | if (File.Exists(assemblyLocation + ".exe")) 28 | return Assembly.LoadFile(assemblyLocation + ".exe"); 29 | } 30 | return null; 31 | 32 | } 33 | 34 | } 35 | } -------------------------------------------------------------------------------- /src/NBehave/Remoting/RemotableStoryRunner.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NBehave.Configuration; 3 | using NBehave.Internal; 4 | 5 | namespace NBehave.Remoting 6 | { 7 | public class RemotableStoryRunner : MarshalByRefObject, IRunner 8 | { 9 | private NBehaveConfiguration configuration; 10 | 11 | public void Initialise(NBehaveConfiguration configuration) 12 | { 13 | this.configuration = configuration; 14 | } 15 | 16 | public FeatureResults Run() 17 | { 18 | var runner = new TextRunner(configuration); 19 | var results = runner.Run(); 20 | return results; 21 | } 22 | 23 | public override object InitializeLifetimeService() 24 | { 25 | return null; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/NBehave/ScenarioContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NBehave.Internal; 3 | 4 | namespace NBehave 5 | { 6 | public class ScenarioContext : NBehaveContext 7 | { 8 | public FeatureContext FeatureContext { get; private set; } 9 | public string ScenarioTitle { get { return Scenario.Title; } } 10 | internal Scenario Scenario { get; set; } 11 | 12 | public ScenarioContext(FeatureContext featureContext, Scenario scenario) 13 | { 14 | FeatureContext = featureContext; 15 | Scenario = scenario; 16 | } 17 | 18 | public ScenarioContext(FeatureContext featureContext, Scenario scenario, IEnumerable tags) 19 | : this(featureContext, scenario) 20 | { 21 | AddTags(tags); 22 | } 23 | 24 | public static ScenarioContext Current 25 | { 26 | get { return TinyIoC.TinyIoCContainer.Current.Resolve(); } 27 | } 28 | 29 | public override string ToString() 30 | { 31 | return ScenarioTitle; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/NBehave/StepContext.cs: -------------------------------------------------------------------------------- 1 | using NBehave.Internal; 2 | 3 | namespace NBehave 4 | { 5 | public static class Step 6 | { 7 | public static void Pend(string reason) 8 | { 9 | StepContext.Current.Pend(reason); 10 | } 11 | } 12 | 13 | public class StepContext : NBehaveContext 14 | { 15 | public FeatureContext FeatureContext { get; private set; } 16 | public ScenarioContext ScenarioContext { get; private set; } 17 | public string Step { get { return StringStep.Step; } } 18 | 19 | internal StringStep StringStep { get; set; } 20 | 21 | public StepContext(FeatureContext featureContext, ScenarioContext scenarioContext) 22 | { 23 | FeatureContext = featureContext; 24 | ScenarioContext = scenarioContext; 25 | } 26 | 27 | public static StepContext Current 28 | { 29 | get { return TinyIoC.TinyIoCContainer.Current.Resolve(); } 30 | } 31 | 32 | public override string ToString() 33 | { 34 | return Step; 35 | } 36 | 37 | public void Pend(string reason) 38 | { 39 | StringStep.Pend(reason); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/NBehave/TextParsing/GroupEventsByFeature.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace NBehave.TextParsing 6 | { 7 | public static class GroupEventsByFeature 8 | { 9 | public static IEnumerable GetEventsForNextFeature(Queue events) 10 | { 11 | return GetEventsWhile(events, nextEvent => nextEvent is EofEvent || nextEvent is FeatureEvent); 12 | } 13 | 14 | private static IEnumerable GetEventsWhile(Queue events, Predicate continueIfEventIsNot) 15 | { 16 | if (events.Any() == false) 17 | yield break; 18 | GherkinEvent nextEvent; 19 | do 20 | { 21 | yield return events.Dequeue(); 22 | nextEvent = (events.Any()) ? events.Peek() : null; 23 | } while (events.Any() && !(continueIfEventIsNot(nextEvent))); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/NBehave/TextParsing/ModelBuilders/ExamplesBuilder.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using NBehave.Internal.Gherkin; 4 | 5 | namespace NBehave.TextParsing.ModelBuilders 6 | { 7 | public class ExamplesBuilder 8 | { 9 | private Scenario scenario; 10 | private bool listenToParsedTable; 11 | 12 | public ExamplesBuilder(IGherkinParserEvents gherkinEvents) 13 | { 14 | gherkinEvents.FeatureEvent += (s, e) => Cleanup(); 15 | gherkinEvents.EofEvent += (s, e) => Cleanup(); 16 | gherkinEvents.ScenarioEvent += (sender, evt) => { scenario = evt.EventInfo; }; 17 | gherkinEvents.ExamplesEvent += (sender, evt) => { listenToParsedTable = true; }; 18 | gherkinEvents.TableEvent += (sender, evt) => ExtractExamplesFromTable(evt.EventInfo); 19 | } 20 | 21 | private void ExtractExamplesFromTable(IList> table) 22 | { 23 | if (!listenToParsedTable) 24 | return; 25 | 26 | var columns = table.First().Select(token => new ExampleColumn(token.Content)).ToList(); 27 | var exampleColumns = new ExampleColumns(columns); 28 | 29 | foreach (var list in table.Skip(1)) 30 | { 31 | var example = list.Select(token => token.Content); 32 | var row = new Dictionary(); 33 | 34 | for (int i = 0; i < example.Count(); i++) 35 | row.Add(exampleColumns[i].Name.ToLower(), example.ElementAt(i)); 36 | 37 | scenario.AddExamples(new List { new Example(exampleColumns, row) }); 38 | } 39 | listenToParsedTable = false; 40 | } 41 | 42 | private void Cleanup() 43 | { 44 | listenToParsedTable = false; 45 | scenario = null; 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /src/NBehave/TextParsing/ModelBuilders/FeatureBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace NBehave.TextParsing.ModelBuilders 2 | { 3 | public class FeatureBuilder 4 | { 5 | Feature feature; 6 | 7 | public FeatureBuilder(IGherkinParserEvents gherkinParser) 8 | { 9 | gherkinParser.FeatureEvent += (s, e) => { feature = e.EventInfo; }; 10 | gherkinParser.ScenarioEvent += (s, e) => 11 | { 12 | CreateFeatureIfNull(e.EventInfo.Source); 13 | feature.AddScenario(e.EventInfo); 14 | }; 15 | gherkinParser.BackgroundEvent += (s, e) => 16 | { 17 | CreateFeatureIfNull(e.EventInfo.Source); 18 | feature.AddBackground(e.EventInfo); 19 | }; 20 | gherkinParser.EofEvent += (s, e) => { feature = null; }; 21 | } 22 | 23 | private void CreateFeatureIfNull(string source) 24 | { 25 | if (feature == null) 26 | feature = new Feature("", source); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/NBehave/TextParsing/TagFilterBuilder.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using NBehave.TextParsing.TagFilter; 4 | 5 | namespace NBehave.TextParsing 6 | { 7 | public static class TagFilterBuilder 8 | { 9 | public static TagFilter.TagFilter Build(IEnumerable tagsFilter) 10 | { 11 | if (tagsFilter.Any()) 12 | { 13 | IEnumerable filters = tagsFilter.Select(_ => new OrFilter(_) as TagFilter.TagFilter); 14 | return new AndFilter(filters.ToArray()); 15 | } 16 | return new NoFilter(); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/NBehave/paket.references: -------------------------------------------------------------------------------- 1 | GurkBurk 2 | TinyIoC 3 | -------------------------------------------------------------------------------- /src/TestLib/ConfigFileActionSteps.fs: -------------------------------------------------------------------------------- 1 | [] 2 | module TestLib.ConfigFileActionSteps 3 | open NBehave 4 | open System.Configuration 5 | open Should 6 | 7 | [] 8 | let ``an assembly with a matching configuration file`` (action:string) (person:string) = 9 | () 10 | 11 | [] 12 | let ``the value of setting $key is read`` (key:string) = 13 | let value = ConfigurationManager.AppSettings.[key] 14 | ScenarioContext.Current.Add("configValue", value) 15 | 16 | [] 17 | let ``the value should be $actionPerformed`` (actionPerformed:string) = 18 | let value = ScenarioContext.Current.["configValue"] |> string 19 | value.ShouldStartWith(actionPerformed) 20 | -------------------------------------------------------------------------------- /src/TestLib/GreetingSystemSteps.fs: -------------------------------------------------------------------------------- 1 | [] 2 | module GreetingSystemSteps 3 | open NBehave 4 | open NBehave.Hooks 5 | open System.Configuration 6 | open Should 7 | 8 | type GreetingSystem() = 9 | [] val mutable Name:string 10 | [] val mutable Greeting:string 11 | 12 | member this.GiveName name = 13 | this.Name <- name 14 | 15 | member this.BuildGreeting () = 16 | this.Greeting <- sprintf "“Hello, %s!”" this.Name 17 | 18 | let greetingSystem () = 19 | ScenarioContext.Current.["greetings"] :?> GreetingSystem 20 | 21 | [] 22 | let ``my name is $name`` name = 23 | let greetingSystem = new GreetingSystem() 24 | greetingSystem.GiveName name 25 | ScenarioContext.Current.Add("greetings", greetingSystem) 26 | 27 | [] 28 | let ``I'm greeted`` () = 29 | greetingSystem().BuildGreeting() 30 | 31 | [] 32 | let ``I should be greeted with “Hello, $name!”$`` name = 33 | (sprintf "“Hello, %s!”" name).ShouldStartWith(greetingSystem().Greeting) 34 | -------------------------------------------------------------------------------- /src/TestLib/HelloSteps.fs: -------------------------------------------------------------------------------- 1 | [] 2 | module HelloSteps 3 | open NBehave 4 | open NBehave.Hooks 5 | open System.Configuration 6 | open Should 7 | 8 | [] 9 | let Setup() = 10 | FeatureContext.Current.Add("hellos", []) 11 | 12 | [] 13 | let ``an action:`` action person = 14 | let hellos = FeatureContext.Current.Get>("hellos") 15 | let x = sprintf "%s, %s" action person 16 | FeatureContext.Current.Add("hellos", x::hellos) 17 | 18 | 19 | [] 20 | let ``do it`` () = 21 | () 22 | 23 | [] 24 | let ``actions performed are:`` actionPerformed = 25 | let hellos = FeatureContext.Current.Get>("hellos") 26 | hellos.ShouldContain(actionPerformed); 27 | -------------------------------------------------------------------------------- /src/TestLib/paket.references: -------------------------------------------------------------------------------- 1 | Should 2 | FSharp.Core --------------------------------------------------------------------------------