Skip to content

Commit 7ac863f

Browse files
committed
Merge pull request #89 from TestStack/examples
Examples
2 parents 00a1485 + 327cfec commit 7ac863f

146 files changed

Lines changed: 5752 additions & 3135 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@
1717

1818
# Denote all files that are truly binary and should not be modified.
1919
*.exe binary
20-
*.dll binary
20+
*.dll binary
21+
22+
*.approved.* binary

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ bin/
33
obj/
44
*.user
55
*.suo
6-
*.DotSettings
76
*~
87
*.swp
98
*.orig

Samples/TestStack.BDDfy.Samples/BDDfyConfiguration.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using NUnit.Framework;
22
using TestStack.BDDfy.Configuration;
33
using TestStack.BDDfy.Reporters.Html;
4-
using TestStack.BDDfy.Reporters.HtmlMetro;
54
using TestStack.BDDfy.Samples.Atm;
65

76
namespace TestStack.BDDfy.Samples
@@ -15,7 +14,7 @@ public void Config()
1514
Configurator.Processors.Add(() => new CustomTextReporter());
1615
Configurator.BatchProcessors.MarkDownReport.Enable();
1716
Configurator.BatchProcessors.DiagnosticsReport.Enable();
18-
Configurator.BatchProcessors.Add(new HtmlReporter(new AtmHtmlReportConfig(), new HtmlMetroReportBuilder()));
17+
Configurator.BatchProcessors.Add(new HtmlReporter(new AtmHtmlReportConfig(), new MetroReportBuilder()));
1918
}
2019
}
2120
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using NUnit.Framework;
2+
using TestStack.BDDfy.Samples.BuyingTrainFares;
3+
4+
namespace TestStack.BDDfy.Samples
5+
{
6+
[TestFixture]
7+
public class BuyingTrainFareWithExamples
8+
{
9+
private Fare fare;
10+
private BuyerCategory _buyerCategory;
11+
Money Price { get; set; }
12+
13+
[Test]
14+
public void SuccessfulRailCardPurchases()
15+
{
16+
this.Given(_ => TheBuyerIsA(_buyerCategory))
17+
.And(_ => TheBuyerSelectsA(fare))
18+
.When(_ => TheBuyerPays())
19+
.Then(_ => ASaleOccursWithAnAmountOf(Price))
20+
.WithExamples(new ExampleTable(
21+
"Buyer Category", "Fare", "Price")
22+
{
23+
{BuyerCategory.Student, new MonthlyPass(), new Money(76)},
24+
{BuyerCategory.Senior, new MonthlyPass(), new Money(98)},
25+
{BuyerCategory.Standard, new MonthlyPass(), new Money(146)},
26+
{BuyerCategory.Student, new WeeklyPass(), new Money(23)},
27+
{BuyerCategory.Senior, new WeeklyPass(), new Money(30)},
28+
{BuyerCategory.Standard, new WeeklyPass(), new Money(44)},
29+
{BuyerCategory.Student, new DayPass(), new Money(4)},
30+
{BuyerCategory.Senior, new DayPass(), new Money(5)},
31+
{BuyerCategory.Standard, new DayPass(), new Money(7)},
32+
{BuyerCategory.Student, new SingleTicket(), new Money(1.5m)},
33+
{BuyerCategory.Senior, new SingleTicket(), new Money(2m)},
34+
{BuyerCategory.Standard, new SingleTicket(), new Money(3m)}
35+
})
36+
.BDDfy("Successful rail card purchases");
37+
}
38+
39+
void TheBuyerIsA(BuyerCategory buyerCategory)
40+
{
41+
42+
}
43+
44+
void TheBuyerSelectsA(Fare fare)
45+
{
46+
47+
}
48+
49+
void TheBuyerPays()
50+
{
51+
52+
}
53+
54+
void ASaleOccursWithAnAmountOf(Money price)
55+
{
56+
57+
}
58+
}
59+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace TestStack.BDDfy.Samples.BuyingTrainFares
2+
{
3+
enum BuyerCategory
4+
{
5+
Student,
6+
Senior,
7+
Standard
8+
}
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace TestStack.BDDfy.Samples.BuyingTrainFares
2+
{
3+
class DayPass : Fare
4+
{
5+
public override string ToString()
6+
{
7+
return "Day Pass";
8+
}
9+
}
10+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace TestStack.BDDfy.Samples.BuyingTrainFares
2+
{
3+
class Fare
4+
{
5+
6+
}
7+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System.Globalization;
2+
3+
namespace TestStack.BDDfy.Samples.BuyingTrainFares
4+
{
5+
class Money
6+
{
7+
public Money(decimal amount)
8+
{
9+
Amount = amount;
10+
}
11+
12+
public decimal Amount { get; set; }
13+
14+
protected bool Equals(Money other)
15+
{
16+
return Amount == other.Amount;
17+
}
18+
19+
public override bool Equals(object obj)
20+
{
21+
if (ReferenceEquals(null, obj)) return false;
22+
if (ReferenceEquals(this, obj)) return true;
23+
if (obj.GetType() != GetType()) return false;
24+
return Equals((Money)obj);
25+
}
26+
27+
public override int GetHashCode()
28+
{
29+
return Amount.GetHashCode();
30+
}
31+
32+
public static bool operator ==(Money left, Money right)
33+
{
34+
return Equals(left, right);
35+
}
36+
37+
public static bool operator !=(Money left, Money right)
38+
{
39+
return !Equals(left, right);
40+
}
41+
42+
public override string ToString()
43+
{
44+
return Amount.ToString("C", CultureInfo.CreateSpecificCulture("EN-US"));
45+
}
46+
}
47+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace TestStack.BDDfy.Samples.BuyingTrainFares
2+
{
3+
class MonthlyPass : Fare
4+
{
5+
public override string ToString()
6+
{
7+
return "Monthly Pass";
8+
}
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace TestStack.BDDfy.Samples.BuyingTrainFares
2+
{
3+
class SingleTicket : Fare
4+
{
5+
public override string ToString()
6+
{
7+
return "Day Pass";
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)