-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clrInvoice: removed wrong object.free clrLoadData: removed unnecessary lines clrPerformance: added necessary create statement clrPlay: added necessary create statement clrStatementPrinter: removed unnecessary lines TestTheatricalPlayers.dpr: removed unnecessary units from 3d-party product uTestStatementPrinter: - removed unittests, that are part of the challange - changed the other tests to match the tests in the java-version - released objects after using them removed unnecessary files updated gitignore
- Loading branch information
1 parent
d6fd803
commit a5e06af
Showing
11 changed files
with
110 additions
and
220 deletions.
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
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
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
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,148 +1,98 @@ | ||
unit uTestStatementPrinter; | ||
|
||
interface | ||
|
||
uses | ||
System.SysUtils, | ||
DUnitX.TestFramework, | ||
clrInvoice, | ||
clrPlay, | ||
clrPerformance, | ||
clrStatementPrinter; | ||
|
||
type | ||
[TestFixture] | ||
TTestStatementPrinter = class | ||
public | ||
[Test] | ||
procedure TestTragedy; | ||
|
||
[Test] | ||
procedure TestComedy; | ||
|
||
[Test] | ||
procedure TestUnknownPlay; | ||
|
||
[Test] | ||
procedure TestMultiplePerformances; | ||
end; | ||
|
||
implementation | ||
|
||
procedure TTestStatementPrinter.TestTragedy; | ||
var | ||
Actual: string; | ||
Invoice: TInvoice; | ||
Plays: TPlays; | ||
Performances: TPerformances; | ||
const | ||
Expected = ''' | ||
Statement for BigCo | ||
Hamlet: $650.00 (55 seats) | ||
Amount owed is $650.00 | ||
You earned 25 credits | ||
'''; | ||
begin | ||
Performances := TPerformances.Create; | ||
Performances.Add(TPerformance.Create('hamlet', 55)); | ||
|
||
Invoice := TInvoice.Create('BigCo', Performances); | ||
|
||
Plays := TPlays.Create; | ||
Plays.Add(TPlay.Create('hamlet', 'Hamlet', 'tragedy')); | ||
|
||
Actual := TStatementPrinter.Print(Invoice, Plays); | ||
Assert.AreEqual(Expected, Actual); | ||
end; | ||
|
||
procedure TTestStatementPrinter.TestComedy; | ||
var | ||
Actual: string; | ||
Invoice: TInvoice; | ||
Plays: TPlays; | ||
Performances: TPerformances; | ||
const | ||
Expected = ''' | ||
Statement for BigCo | ||
As You Like It: $580.00 (35 seats) | ||
Amount owed is $580.00 | ||
You earned 12 credits | ||
'''; | ||
begin | ||
Performances := TPerformances.Create; | ||
Performances.Add(TPerformance.Create('as-like', 35)); | ||
|
||
Invoice := TInvoice.Create('BigCo', Performances); | ||
|
||
Plays := TPlays.Create; | ||
Plays.Add(TPlay.Create('as-like', 'As You Like It', 'comedy')); | ||
|
||
Actual := TStatementPrinter.Print(Invoice, Plays); | ||
Assert.AreEqual(Expected, Actual); | ||
end; | ||
|
||
procedure TTestStatementPrinter.TestUnknownPlay; | ||
var | ||
Actual: string; | ||
Invoice: TInvoice; | ||
Plays: TPlays; | ||
Performances: TPerformances; | ||
const | ||
UnknownPlay = 'unknown-play'; | ||
UnknownType = 'unknown-type'; | ||
begin | ||
Performances := TPerformances.Create; | ||
Performances.Add(TPerformance.Create(UnknownPlay, 10)); | ||
|
||
Invoice := TInvoice.Create('BigCo', Performances); | ||
|
||
Plays := TPlays.Create; | ||
Plays.Add(TPlay.Create(UnknownPlay, 'Unknown Play', UnknownType)); | ||
|
||
Assert.WillRaise( | ||
procedure | ||
begin | ||
TStatementPrinter.Print(Invoice, Plays); | ||
end, Exception, 'unknown type: ' + UnknownType | ||
); | ||
end; | ||
|
||
procedure TTestStatementPrinter.TestMultiplePerformances; | ||
var | ||
Actual: string; | ||
Invoice: TInvoice; | ||
Plays: TPlays; | ||
Performances: TPerformances; | ||
const | ||
Expected = ''' | ||
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 | ||
'''; | ||
begin | ||
Performances := TPerformances.Create; | ||
Performances.Add(TPerformance.Create('hamlet', 55)); | ||
Performances.Add(TPerformance.Create('as-like', 35)); | ||
Performances.Add(TPerformance.Create('othello', 40)); | ||
|
||
Invoice := TInvoice.Create('BigCo', Performances); | ||
|
||
Plays := TPlays.Create; | ||
Plays.Add(TPlay.Create('hamlet', 'Hamlet', 'tragedy')); | ||
Plays.Add(TPlay.Create('as-like', 'As You Like It', 'comedy')); | ||
Plays.Add(TPlay.Create('othello', 'Othello', 'tragedy')); | ||
|
||
Actual := TStatementPrinter.Print(Invoice, Plays); | ||
Assert.AreEqual(Expected, Actual); | ||
end; | ||
|
||
initialization | ||
TDUnitX.RegisterTestFixture(TTestStatementPrinter); | ||
|
||
end. | ||
|
||
unit uTestStatementPrinter; | ||
|
||
interface | ||
|
||
uses | ||
System.SysUtils, | ||
DUnitX.TestFramework, | ||
clrInvoice, | ||
clrPlay, | ||
clrPerformance, | ||
clrStatementPrinter; | ||
|
||
type | ||
[TestFixture] | ||
TTestStatementPrinter = class | ||
public | ||
[Test] | ||
procedure ExampleStatement; | ||
|
||
[Test] | ||
procedure StatementWithNewPlayTypes; | ||
end; | ||
|
||
implementation | ||
|
||
procedure TTestStatementPrinter.ExampleStatement; | ||
var | ||
Actual: string; | ||
Invoice: TInvoice; | ||
Plays: TPlays; | ||
Performances: TPerformances; | ||
const | ||
Expected = ''' | ||
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 | ||
'''; | ||
begin | ||
Performances := TPerformances.Create; | ||
Plays := TPlays.Create; | ||
Invoice := TInvoice.Create('BigCo', Performances); | ||
try | ||
Plays.Add(TPlay.Create('hamlet', 'Hamlet', 'tragedy')); | ||
Plays.Add(TPlay.Create('as-like', 'As You Like It', 'comedy')); | ||
Plays.Add(TPlay.Create('othello', 'Othello', 'tragedy')); | ||
|
||
Performances.Add(TPerformance.Create('hamlet', 55)); | ||
Performances.Add(TPerformance.Create('as-like', 35)); | ||
Performances.Add(TPerformance.Create('othello', 40)); | ||
|
||
Actual := TStatementPrinter.Print(Invoice, Plays); | ||
Assert.AreEqual(Expected, Actual); | ||
finally | ||
Invoice.Free; | ||
Plays.Free; | ||
Performances.Free; | ||
end; | ||
end; | ||
|
||
procedure TTestStatementPrinter.StatementWithNewPlayTypes; | ||
var | ||
Actual: string; | ||
Invoice: TInvoice; | ||
Plays: TPlays; | ||
Performances: TPerformances; | ||
begin | ||
Performances := TPerformances.Create; | ||
Plays := TPlays.Create; | ||
Invoice := TInvoice.Create('BigCo', Performances); | ||
try | ||
Plays.Add(TPlay.Create('henry-v', 'Henry V', 'history')); | ||
Plays.Add(TPlay.Create('as-like', 'As You Like It', 'pastoral')); | ||
|
||
Performances.Add(TPerformance.Create('henry-v', 53)); | ||
Performances.Add(TPerformance.Create('as-like', 55)); | ||
|
||
Assert.WillRaise( | ||
procedure | ||
begin | ||
TStatementPrinter.Print(Invoice, Plays); | ||
end, Exception, 'unknown type: ' + 'henry-v' | ||
); | ||
finally | ||
Invoice.Free; | ||
Plays.Free; | ||
Performances.Free; | ||
end; | ||
end; | ||
|
||
initialization | ||
TDUnitX.RegisterTestFixture(TTestStatementPrinter); | ||
|
||
end. | ||
|