add csharp version to the exercice

This commit is contained in:
Anis CHAABANI
2019-08-12 18:14:48 +02:00
parent 06fb74cfb3
commit 112854cc8a
10 changed files with 236 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using ApprovalTests;
using ApprovalTests.Reporters;
using Xunit;
namespace TheatricalPlayersRefactoringKata.Tests
{
public class StatementPrinterTests
{
[Fact]
[UseReporter(typeof(DiffReporter))]
public void test_statement_exemple()
{
var plays = new Dictionary<string, Play>();
plays.Add("hamlet", new Play("Hamlet", "tragedy"));
plays.Add("as-like", new Play("As You Like It", "comedy"));
plays.Add("othello", new Play("Othello", "tragedy"));
Invoice invoice = new Invoice("BigCo", new List<Performance>{new Performance("hamlet", 55),
new Performance("as-like", 35),
new Performance("othello", 40)});
StatementPrinter statementPrinter = new StatementPrinter();
var result = statementPrinter.Print(invoice, plays);
Approvals.Verify(result);
}
[Fact]
public void test_statement_with_new_play_types()
{
var plays = new Dictionary<string, Play>();
plays.Add("henry-v", new Play("Henry V", "history"));
plays.Add("as-like", new Play("As You Like It", "pastoral"));
Invoice invoice = new Invoice("BigCoII", new List<Performance>{new Performance("henry-v", 53),
new Performance("as-like", 55)});
StatementPrinter statementPrinter = new StatementPrinter();
Assert.Throws<Exception>(() => statementPrinter.Print(invoice, plays));
}
}
}

View File

@@ -0,0 +1,6 @@
Statement for BigCo
Hamlet: $650.00 (55 seats)
As You Like It: $580.00 (35 seats)
Othello: $500.00 (40 seats)
Amount owed is $1,730.00
You earned 47 credits

View File

@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ApprovalTests" Version="4.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TheatricalPlayersRefactoringKata\TheatricalPlayersRefactoringKata.csproj" />
</ItemGroup>
</Project>