Skip to content

Commit

Permalink
Quickstart starting point
Browse files Browse the repository at this point in the history
  • Loading branch information
gasparnagy committed Jan 29, 2024
1 parent 7ca5a83 commit 7ac7827
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ReqnrollQuickstart.App/Currency.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace ReqnrollQuickstart.App;

// to be used later
public record Currency(string Symbol, decimal Value)
{
public static Currency operator+(Currency a, Currency b)
{
if (a.Symbol != b.Symbol)
throw new InvalidOperationException("Cannot add different currencies!");
return new Currency(a.Symbol, a.Value + b.Value);
}
public static Currency operator *(Currency a, int b)
{
return new Currency(a.Symbol, a.Value * b);
}
}
16 changes: 16 additions & 0 deletions ReqnrollQuickstart.App/PriceCalculator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace ReqnrollQuickstart.App;

public class PriceCalculator
{
// the item prices are hard coded for now
private readonly Dictionary<string, decimal> _priceTable = new()
{
{ "Electric guitar", 180.0m },
{ "Guitar pick", 1.5m }
};

public decimal CalculatePrice(Dictionary<string, int> basket)
{
throw new NotImplementedException();
}
}
9 changes: 9 additions & 0 deletions ReqnrollQuickstart.App/ReqnrollQuickstart.App.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
15 changes: 15 additions & 0 deletions ReqnrollQuickstart.Specs/Features/PriceCalculation.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Feature: Price calculation

This feature is about calculating the basket price

We work with fixed item prices for now:
* Electric guitar: $180
* Guitar pick: $1.5

Rule: The price for a basket with items can be calculated based on the item prices

Scenario: Client has a simple basket
Given the client started shopping
And the client added 1 pcs of "Electric guitar" to the basket
When the basket is prepared
Then the basket price should be $180.0
4 changes: 4 additions & 0 deletions ReqnrollQuickstart.Specs/ImplicitUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
global using FluentAssertions;
global using Microsoft.VisualStudio.TestTools.UnitTesting;
global using Reqnroll;
global using ReqnrollQuickstart.App;
26 changes: 26 additions & 0 deletions ReqnrollQuickstart.Specs/ReqnrollQuickstart.Specs.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Reqnroll.MsTest" Version="1.0.0-pre20240125-60" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ReqnrollQuickstart.App\ReqnrollQuickstart.App.csproj" />
</ItemGroup>

<ItemGroup>
<!-- hiding .gitkeep files in Visual Studio; they are only needed to ensure the existence of the empty folders in git -->
<None Update="**/.gitkeep" Visible="false" />
</ItemGroup>

</Project>
Empty file.
Empty file.
31 changes: 31 additions & 0 deletions ReqnrollQuickstart.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34316.72
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReqnrollQuickstart.Specs", "ReqnrollQuickstart.Specs\ReqnrollQuickstart.Specs.csproj", "{4408B957-D6D8-4334-8E40-A225DB7D5209}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReqnrollQuickstart.App", "ReqnrollQuickstart.App\ReqnrollQuickstart.App.csproj", "{98891CEA-0EED-4BDE-A884-C64A9CA388D5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4408B957-D6D8-4334-8E40-A225DB7D5209}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4408B957-D6D8-4334-8E40-A225DB7D5209}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4408B957-D6D8-4334-8E40-A225DB7D5209}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4408B957-D6D8-4334-8E40-A225DB7D5209}.Release|Any CPU.Build.0 = Release|Any CPU
{98891CEA-0EED-4BDE-A884-C64A9CA388D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{98891CEA-0EED-4BDE-A884-C64A9CA388D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{98891CEA-0EED-4BDE-A884-C64A9CA388D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{98891CEA-0EED-4BDE-A884-C64A9CA388D5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3A4151D1-FE77-4163-8587-0D803F3CA2F0}
EndGlobalSection
EndGlobal

0 comments on commit 7ac7827

Please sign in to comment.