Adds LightBDD
This commit is contained in:
parent
099f6467d2
commit
104187fcac
16 changed files with 344 additions and 158 deletions
73
PlanTempus.X.BDD/FeatureFixtures/UserRegistrationSpecs.cs
Normal file
73
PlanTempus.X.BDD/FeatureFixtures/UserRegistrationSpecs.cs
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
using LightBDD.Framework;
|
||||
using LightBDD.Framework.Scenarios;
|
||||
using LightBDD.MsTest3;
|
||||
using Shouldly;
|
||||
|
||||
namespace PlanTempus.X.BDD.FeatureFixtures;
|
||||
[TestClass]
|
||||
public partial class UserRegistrationSpecs : FeatureFixture
|
||||
{
|
||||
//private CalculatorContext _context;
|
||||
|
||||
public UserRegistrationSpecs()
|
||||
{
|
||||
//_context = new CalculatorContext();
|
||||
}
|
||||
//[Scenario]
|
||||
//[TestMethod]
|
||||
//public void Successful_user_registration_with_valid_email()
|
||||
//{
|
||||
// // Runner.RunScenario(
|
||||
// // _ => Given_no_user_exists_with_email("test@example.com")
|
||||
|
||||
// //);
|
||||
// //await Runner.RunScenarioAsync(
|
||||
// // _ => Given_no_user_exists_with_email("test@example.com"),
|
||||
// // _ => When_I_submit_registration_with_name_and_email("Test User", "test@example.com"),
|
||||
// // _ => Then_a_new_user_should_be_created_with_email_and_confirmation_status("test@example.com", false),
|
||||
// // _ => Then_a_confirmation_email_should_be_sent()
|
||||
// //);
|
||||
//}
|
||||
protected async Task Given_no_user_exists_with_email(string email)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
|
||||
});
|
||||
//Assert.IsFalse(await _context.UserExistsAsync(email), $"User with email {email} should not exist");
|
||||
true.ShouldBe(true);
|
||||
}
|
||||
|
||||
protected async Task When_I_submit_registration_with_name_and_email(string name, string email)
|
||||
{
|
||||
//await _context.RegisterUserAsync(name, email);
|
||||
await Task.Run(() =>
|
||||
{
|
||||
|
||||
});
|
||||
true.ShouldBe(true);
|
||||
}
|
||||
|
||||
protected async Task Then_a_new_user_should_be_created_with_email_and_confirmation_status(string email, bool emailConfirmed)
|
||||
{
|
||||
//var user = await _context.GetUserByEmailAsync(email);
|
||||
//Assert.IsNotNull(user);
|
||||
//Assert.AreEqual(email, user.Email);
|
||||
//Assert.AreEqual(emailConfirmed, user.EmailConfirmed);
|
||||
await Task.Run(() =>
|
||||
{
|
||||
|
||||
});
|
||||
true.ShouldBe(true);
|
||||
}
|
||||
|
||||
protected async Task Then_a_confirmation_email_should_be_sent()
|
||||
{
|
||||
//Assert.IsTrue(await _context.WasConfirmationEmailSentAsync(), "Confirmation email should be sent");
|
||||
await Task.Run(() =>
|
||||
{
|
||||
|
||||
});
|
||||
true.ShouldBe(true);
|
||||
}
|
||||
}
|
||||
29
PlanTempus.X.BDD/LightBddIntegration.cs
Normal file
29
PlanTempus.X.BDD/LightBddIntegration.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
using LightBDD.Core.Configuration;
|
||||
using LightBDD.Framework.Configuration;
|
||||
using LightBDD.Framework.Reporting.Formatters;
|
||||
using LightBDD.MsTest3;
|
||||
|
||||
namespace PlanTempus.X.BDD
|
||||
{
|
||||
[TestClass]
|
||||
public class LightBddIntegration
|
||||
{
|
||||
[AssemblyInitialize]
|
||||
public static void Setup(TestContext testContext) { LightBddScope.Initialize(OnConfigure); }
|
||||
[AssemblyCleanup]
|
||||
public static void Cleanup() { LightBddScope.Cleanup(); }
|
||||
|
||||
/// <summary>
|
||||
/// This method allows to customize LightBDD behavior.
|
||||
/// The code below configures LightBDD to produce also a plain text report after all tests are done.
|
||||
/// More information on what can be customized can be found on wiki: https://github.com/LightBDD/LightBDD/wiki/LightBDD-Configuration#configurable-lightbdd-features
|
||||
/// </summary>
|
||||
private static void OnConfigure(LightBddConfiguration configuration)
|
||||
{
|
||||
configuration
|
||||
.ReportWritersConfiguration()
|
||||
.AddFileWriter<HtmlReportFormatter>("~\\Reports\\FeaturesReport.html");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
43
PlanTempus.X.BDD/PlanTempus.X.BDD.csproj
Normal file
43
PlanTempus.X.BDD/PlanTempus.X.BDD.csproj
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
<PackageReference Include="LightBDD.Core" Version="3.10.0" />
|
||||
<PackageReference Include="LightBDD.MSTest3" Version="3.10.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="moq" Version="4.20.72" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
|
||||
<PackageReference Include="Shouldly" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Application\PlanTempus.Application.csproj" />
|
||||
<ProjectReference Include="..\Database\PlanTempus.Database.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="appconfiguration.dev.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="ConfigurationTests\appconfiguration.dev.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="ConfigurationTests\appconfiguration.dev.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
21
PlanTempus.X.BDD/Scenarios/UserRegistrationSpecs.cs
Normal file
21
PlanTempus.X.BDD/Scenarios/UserRegistrationSpecs.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using LightBDD.Framework;
|
||||
using LightBDD.Framework.Scenarios;
|
||||
using LightBDD.MsTest3;
|
||||
|
||||
namespace PlanTempus.X.BDD.Scenarios;
|
||||
|
||||
[TestClass]
|
||||
public partial class UserRegistrationSpecs : FeatureFixtures.UserRegistrationSpecs
|
||||
{
|
||||
[Scenario]
|
||||
[TestMethod]
|
||||
public async Task Successful_user_registration_with_valid_email()
|
||||
{
|
||||
await Runner.RunScenarioAsync(
|
||||
_ => Given_no_user_exists_with_email("test@example.com"),
|
||||
_ => When_I_submit_registration_with_name_and_email("Test User", "test@example.com"),
|
||||
_ => Then_a_new_user_should_be_created_with_email_and_confirmation_status("test@example.com", false),
|
||||
_ => Then_a_confirmation_email_should_be_sent()
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue