-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
954c3ee
commit c8480b3
Showing
174 changed files
with
27,216 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": 1, | ||
"isRoot": true, | ||
"tools": { | ||
"specflow.plus.livingdoc.cli": { | ||
"version": "3.7.141", | ||
"commands": [ | ||
"livingdoc" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2013-2021 Spec Solutions and Gaspar Nagy, https://www.specsolutions.eu | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Spec Overflow - Sample application for the SpecFlow Masterclass | ||
|
||
A simple Q&A site where people can ask questions and post answers. | ||
|
||
**Features:** | ||
|
||
* User management & Home page | ||
* Questions | ||
* List & Details | ||
* Ask & Answer | ||
* Vote questions & answers | ||
|
||
**Technology:** | ||
|
||
* ASP.NET MVC | ||
* Backend with REST API | ||
* Simple web frontend accessing the backend using basic jQuery | ||
|
||
**Open-source:** Explore, fork, play, contribute! | ||
|
||
|
||
## See Also | ||
|
||
* [SpecFlow Masterclass page at specflow.org](https://specflow.org/community/webinars/masterclass/) | ||
* [BDD & SpecFlow training services by Gaspar Nagy](https://www.specsolutions.eu/courses/) | ||
|
||
## License | ||
|
||
The Spec Overflow sample application is licensed under the [MIT license](LICENSE). | ||
|
||
Copyright (c) 2013-2021 Spec Solutions and Gaspar Nagy, https://www.specsolutions.eu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.29609.76 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpecFlowMasterClass.SpecOverflow.Web", "SpecFlowMasterClass.SpecOverflow.Web\SpecFlowMasterClass.SpecOverflow.Web.csproj", "{BCC4E7F9-9CD9-4E71-8F74-ABA87623FF34}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpecFlowMasterClass.SpecOverflow.Specs.Controller", "SpecFlowMasterClass.SpecOverflow.Specs.Controller\SpecFlowMasterClass.SpecOverflow.Specs.Controller.csproj", "{4472FA94-91CF-481F-8527-1CF44A7D0D9F}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpecFlowMasterClass.SpecOverflow.Tests", "SpecFlowMasterClass.SpecOverflow.Tests\SpecFlowMasterClass.SpecOverflow.Tests.csproj", "{BEACB170-C8E2-4AFE-86CE-F2723B496DBC}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{BCC4E7F9-9CD9-4E71-8F74-ABA87623FF34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{BCC4E7F9-9CD9-4E71-8F74-ABA87623FF34}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{BCC4E7F9-9CD9-4E71-8F74-ABA87623FF34}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{BCC4E7F9-9CD9-4E71-8F74-ABA87623FF34}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{4472FA94-91CF-481F-8527-1CF44A7D0D9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4472FA94-91CF-481F-8527-1CF44A7D0D9F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4472FA94-91CF-481F-8527-1CF44A7D0D9F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4472FA94-91CF-481F-8527-1CF44A7D0D9F}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{BEACB170-C8E2-4AFE-86CE-F2723B496DBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{BEACB170-C8E2-4AFE-86CE-F2723B496DBC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{BEACB170-C8E2-4AFE-86CE-F2723B496DBC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{BEACB170-C8E2-4AFE-86CE-F2723B496DBC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {02C8B3DB-D290-40F6-88DF-38EABFF39937} | ||
EndGlobalSection | ||
EndGlobal |
56 changes: 56 additions & 0 deletions
56
SpecFlowMasterClass.SpecOverflow.Specs.API/Drivers/AuthApiDriver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Net; | ||
using FluentAssertions; | ||
using SpecFlowMasterClass.SpecOverflow.Specs.API.Support; | ||
using SpecFlowMasterClass.SpecOverflow.Web.Models; | ||
using SpecFlowMasterClass.SpecOverflow.Specs.Support; | ||
using SpecFlowMasterClass.SpecOverflow.Web.Utils; | ||
|
||
namespace SpecFlowMasterClass.SpecOverflow.Specs.API.Drivers | ||
{ | ||
public class AuthApiDriver | ||
{ | ||
public class LoginDriver : ActionAttempt<LoginInputModel, string> | ||
{ | ||
private readonly WebApiContext _webApiContext; | ||
|
||
public LoginDriver(WebApiContext webApiContext) | ||
{ | ||
_webApiContext = webApiContext; | ||
} | ||
|
||
public event Action<LoginInputModel, string> OnAuthenticated; | ||
|
||
protected override string DoAction(LoginInputModel loginInput) | ||
{ | ||
var response = _webApiContext.ExecutePost<string>("api/auth", loginInput); | ||
response.StatusCode.Should().Be(HttpStatusCode.OK); | ||
var authToken = response.ResponseData; | ||
OnAuthenticated?.Invoke(loginInput, authToken); | ||
return authToken; | ||
} | ||
} | ||
|
||
private readonly WebApiContext _webApiContext; | ||
|
||
public LoginDriver Login { get; } | ||
|
||
public AuthApiDriver(WebApiContext webApiContext, LoginDriver login) | ||
{ | ||
_webApiContext = webApiContext; | ||
Login = login; | ||
} | ||
|
||
public UserReferenceModel GetCurrentUser() | ||
{ | ||
try | ||
{ | ||
return _webApiContext.ExecuteGet<UserReferenceModel>("/api/auth"); | ||
} | ||
catch (HttpResponseException e) when (e.StatusCode == HttpStatusCode.NotFound) | ||
{ | ||
return null; | ||
} | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
SpecFlowMasterClass.SpecOverflow.Specs.API/Drivers/HomeApiDriver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using SpecFlowMasterClass.SpecOverflow.Specs.API.Support; | ||
using SpecFlowMasterClass.SpecOverflow.Web.Models; | ||
|
||
namespace SpecFlowMasterClass.SpecOverflow.Specs.API.Drivers | ||
{ | ||
public class HomeApiDriver | ||
{ | ||
private readonly WebApiContext _webApiContext; | ||
|
||
public HomeApiDriver(WebApiContext webApiContext) | ||
{ | ||
_webApiContext = webApiContext; | ||
} | ||
|
||
public HomePageModel GetHomePageModel() | ||
{ | ||
return _webApiContext.ExecuteGet<HomePageModel>("/api/home"); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
SpecFlowMasterClass.SpecOverflow.Specs.API/Drivers/QuestionApiDriver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using SpecFlowMasterClass.SpecOverflow.Specs.API.Support; | ||
using SpecFlowMasterClass.SpecOverflow.Specs.Support; | ||
using SpecFlowMasterClass.SpecOverflow.Web.Models; | ||
|
||
namespace SpecFlowMasterClass.SpecOverflow.Specs.API.Drivers | ||
{ | ||
public class QuestionApiDriver | ||
{ | ||
private readonly WebApiContext _webApiContext; | ||
public ActionAttempt<AskInputModel, QuestionSummaryModel> AskQuestion { get; } | ||
|
||
public QuestionApiDriver(WebApiContext webApiContext, ActionAttemptFactory actionAttemptFactory) | ||
{ | ||
_webApiContext = webApiContext; | ||
AskQuestion = actionAttemptFactory.CreateWithStatusCheck<AskInputModel, QuestionSummaryModel>( | ||
nameof(AskQuestion), | ||
askInput => webApiContext.ExecutePost<QuestionSummaryModel>("/api/question", askInput)); | ||
} | ||
|
||
public QuestionDetailModel GetQuestionDetails(Guid questionId) | ||
{ | ||
return _webApiContext.ExecuteGet<QuestionDetailModel>($"/api/question/{questionId}"); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
SpecFlowMasterClass.SpecOverflow.Specs.API/Drivers/UserApiDriver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using SpecFlowMasterClass.SpecOverflow.Specs.API.Support; | ||
using SpecFlowMasterClass.SpecOverflow.Specs.Support; | ||
using SpecFlowMasterClass.SpecOverflow.Web.Models; | ||
|
||
namespace SpecFlowMasterClass.SpecOverflow.Specs.API.Drivers | ||
{ | ||
public class UserApiDriver | ||
{ | ||
public ActionAttempt<RegisterInputModel, UserReferenceModel> Register { get; } | ||
|
||
public UserApiDriver(WebApiContext webApiContext, ActionAttemptFactory actionAttemptFactory) | ||
{ | ||
Register = actionAttemptFactory.CreateWithStatusCheck<RegisterInputModel, UserReferenceModel>( | ||
nameof(Register), | ||
registerInput => webApiContext.ExecutePost<UserReferenceModel>("/api/user", registerInput)); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
SpecFlowMasterClass.SpecOverflow.Specs.API/Features/Authentication.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@webapi | ||
Feature: Authentication | ||
|
||
Rule: Successful login authorizes for member-only services | ||
|
||
Scenario: User logs in with valid credentials | ||
Given there is a user registered with user name "Trillian" and password "139139" | ||
When the user attempts to log in with user name "Trillian" and password "139139" | ||
Then the login attempt should be successful | ||
And the user should be authenticated |
29 changes: 29 additions & 0 deletions
29
SpecFlowMasterClass.SpecOverflow.Specs.API/Features/Home.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@webapi | ||
Feature: Home | ||
|
||
Rule: A positive message should be shown on the home page | ||
|
||
Scenario: Welcome message is shown on home page | ||
When the user checks the home page | ||
Then the home page main message should be: "Welcome to Spec Overflow!" | ||
|
||
Rule: The user name should be shown on the home page if logged in | ||
|
||
Scenario: The logged-in user name is shown on home page | ||
Given the user is authenticated | ||
When the user checks the home page | ||
Then the user name of the user should be on the home page | ||
|
||
Rule: The latest 10 question should be shown on the home page | ||
|
||
Scenario: The latest question is shown on home page with details | ||
Given there is a question just asked as | ||
| title | votes | answers | views | asked by | | ||
| How to write better BDD scenarios? | 0 | 0 | 1 | Ford | | ||
When the user checks the home page | ||
Then the question should be listed among the latest questions as above | ||
|
||
Scenario: The latest 10 questions are shown on home page | ||
Given there are 12 questions asked | ||
When the user checks the home page | ||
Then the home page should contain the 10 latest questions ordered |
34 changes: 34 additions & 0 deletions
34
SpecFlowMasterClass.SpecOverflow.Specs.API/Features/Question/AskingQuestions.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
@webapi | ||
Feature: Asking questions | ||
|
||
Rule: Should be able to ask a question | ||
|
||
Scenario: The question is posted | ||
Given user Marvin is authenticated | ||
When the user asks a question as | ||
| title | body | tags | | ||
| How to write better BDD scenarios? | I need help | Gherkin,BDD | | ||
Then the question should be posted as above | ||
And the question meta data should be | ||
| votes | asked at | asked by | | ||
| 0 | now | Marvin | | ||
|
||
Rule: Only authenticated users can ask questions | ||
|
||
Scenario: Anonymous user cannot answer questions | ||
Given the user is not authenticated | ||
When the user attempts to ask a question | ||
Then the ask attempt should fail with error "not-logged-in" | ||
|
||
Rule: The question title and body are mandatory | ||
|
||
Scenario Outline: Cannot post an answer with empty content | ||
Given user Marvin is authenticated | ||
When the user attempts to ask a question as | ||
| title | body | | ||
| <title> | <body> | | ||
Then the ask attempt should fail with error "Title and Body cannot be empty" | ||
Examples: | ||
| description | title | body | | ||
| no title | | I need help | | ||
| no body | How to write better BDD scenarios? | | |
16 changes: 16 additions & 0 deletions
16
SpecFlowMasterClass.SpecOverflow.Specs.API/Features/Registration.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@webapi | ||
Feature: Registration | ||
|
||
Describes the behavior of the registration process. | ||
|
||
There are many rules involved (e.g. related to user name and password validity | ||
or password and re-entered password match). For the sake of the sample we only | ||
work with a single rule: Should be able to register with user name and password. | ||
|
||
Rule: Should be able to register with user name and password | ||
|
||
Scenario: User registers successfully | ||
When the user attempts to register with user name "Trillian" and password "139139" | ||
Then the registration should be successful | ||
|
||
|
Oops, something went wrong.