Skip to content

Commit e210c62

Browse files
committed
Merge pull request #192 from JakeGinnivan/XUnitConversion
XUnit conversion
2 parents ce426c8 + 201d54c commit e210c62

File tree

97 files changed

+966
-889
lines changed

Some content is hidden

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

97 files changed

+966
-889
lines changed

.nuget/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="NUnit.Runners" version="2.6.4" />
3+
<package id="xunit.runners" version="2.0.0-rc1-build2826" />
44
</packages>

Samples/TestStack.BDDfy.Samples/Atm/AccountHasInsufficientFund.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using NUnit.Framework;
1+
using Shouldly;
2+
using Xunit;
23

34
namespace TestStack.BDDfy.Samples.Atm
45
{
@@ -7,8 +8,8 @@ public class AccountHasInsufficientFund
78
private Card _card;
89
private Atm _atm;
910

10-
// You can override step text using executable attributes
11-
[Given("Given the Account Balance is $10")]
11+
// You can override step text using executable attributes
12+
[Given("Given the Account Balance is $10")]
1213
void GivenTheAccountBalanceIs10()
1314
{
1415
_card = new Card(true, 10);
@@ -23,34 +24,34 @@ void AndGivenTheMachineContainsEnoughMoney()
2324
_atm = new Atm(100);
2425
}
2526

26-
[When("When the Account Holder requests $20")]
27+
[When("When the Account Holder requests $20")]
2728
void WhenTheAccountHolderRequests20()
2829
{
2930
_atm.RequestMoney(_card, 20);
3031
}
3132

3233
void Then_the_ATM_should_not_dispense_any_Money()
3334
{
34-
Assert.AreEqual(0, _atm.DispenseValue);
35+
_atm.DispenseValue.ShouldBe(0);
3536
}
3637

3738
void And_the_ATM_should_say_there_are_Insufficient_Funds()
3839
{
39-
Assert.AreEqual(DisplayMessage.InsufficientFunds, _atm.Message);
40+
_atm.Message.ShouldBe(DisplayMessage.InsufficientFunds);
4041
}
4142

42-
[AndThen("And the Account Balance should be $20")]
43+
[AndThen("And the Account Balance should be $20")]
4344
void AndTheAccountBalanceShouldBe20()
4445
{
45-
Assert.AreEqual(10, _card.AccountBalance);
46+
_card.AccountBalance.ShouldBe(10);
4647
}
4748

4849
void And_the_Card_should_be_returned()
4950
{
50-
Assert.IsFalse(_atm.CardIsRetained);
51+
_atm.CardIsRetained.ShouldBe(false);
5152
}
5253

53-
[Test]
54+
[Fact]
5455
public void Verify()
5556
{
5657
this.BDDfy<AccountHolderWithdrawsCash>();

Samples/TestStack.BDDfy.Samples/Atm/AccountHolderWithdrawsCash.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
using NUnit.Framework;
1+
using Shouldly;
2+
using Xunit;
23

34
namespace TestStack.BDDfy.Samples.Atm
45
{
56
[Story(
67
AsA = "As an Account Holder",
78
IWant = "I want to withdraw cash from an ATM",
89
SoThat = "So that I can get money when the bank is closed")]
9-
[TestFixture]
1010
public class AccountHolderWithdrawsCash
1111
{
1212
private const string GivenTheAccountBalanceIsTitleTemplate = "Given the account balance is ${0}";
@@ -44,25 +44,25 @@ public void When_the_Account_Holder_requests(int moneyRequest)
4444

4545
public void The_ATM_should_dispense(int dispensedMoney)
4646
{
47-
Assert.AreEqual(dispensedMoney, _atm.DispenseValue);
47+
_atm.DispenseValue.ShouldBe(dispensedMoney);
4848
}
4949

5050
public void And_the_Account_Balance_should_be(int balance)
5151
{
52-
Assert.AreEqual(balance, _card.AccountBalance);
52+
_card.AccountBalance.ShouldBe(balance);
5353
}
5454

5555
public void Then_Card_is_retained(bool cardIsRetained)
5656
{
57-
Assert.AreEqual(cardIsRetained, _atm.CardIsRetained);
57+
_atm.CardIsRetained.ShouldBe(cardIsRetained);
5858
}
5959

6060
void And_the_ATM_should_say_the_Card_has_been_retained()
6161
{
62-
Assert.AreEqual(DisplayMessage.CardIsRetained, _atm.Message);
62+
_atm.Message.ShouldBe(DisplayMessage.CardIsRetained);
6363
}
6464

65-
[Test]
65+
[Fact]
6666
public void AccountHasSufficientFund()
6767
{
6868
this.Given(s => s.Given_the_Account_Balance_is(100), GivenTheAccountBalanceIsTitleTemplate)
@@ -75,7 +75,7 @@ public void AccountHasSufficientFund()
7575
.BDDfy();
7676
}
7777

78-
[Test]
78+
[Fact]
7979
public void CardHasBeenDisabled()
8080
{
8181
this.Given(s => s.Given_the_Card_is_disabled())

Samples/TestStack.BDDfy.Samples/BDDfyConfiguration.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

Samples/TestStack.BDDfy.Samples/BDDfy_Rocks.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using NUnit.Framework;
1+
using Xunit;
22

33
namespace TestStack.BDDfy.Samples
44
{
@@ -24,13 +24,13 @@ void AndTheQualityAndMaintainabilityOfMyTestSkyrocket()
2424
{
2525
}
2626

27-
[Test]
27+
[Fact]
2828
public void BDDfy_with_reflective_API()
2929
{
3030
this.BDDfy();
3131
}
3232

33-
[Test]
33+
[Fact]
3434
public void BDDfy_with_fluent_API()
3535
{
3636
this.Given(_ => Given_I_have_not_used_BDDfy_before())

Samples/TestStack.BDDfy.Samples/BuyingTrainFareWithExamples.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
using NUnit.Framework;
2-
using TestStack.BDDfy.Samples.BuyingTrainFares;
1+
using TestStack.BDDfy.Samples.BuyingTrainFares;
2+
using Xunit;
33

44
namespace TestStack.BDDfy.Samples
55
{
6-
[TestFixture]
76
public class BuyingTrainFareWithExamples
87
{
8+
#pragma warning disable 649
9+
// ReSharper disable once InconsistentNaming
910
private Fare fare;
1011
private BuyerCategory _buyerCategory;
12+
#pragma warning restore 649
1113
Money Price { get; set; }
1214

13-
[Test]
15+
[Fact]
1416
public void SuccessfulRailCardPurchases()
1517
{
1618
this.Given(_ => TheBuyerIsA(_buyerCategory))

Samples/TestStack.BDDfy.Samples/CanRunAsyncSteps.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Threading.Tasks;
3-
using NUnit.Framework;
3+
using Shouldly;
4+
using Xunit;
45

56
namespace TestStack.BDDfy.Samples
67
{
@@ -15,7 +16,7 @@ public async void GivenSomeAsyncSetup()
1516

1617
public void ThenBddfyHasWaitedForThatSetupToCompleteBeforeContinuing()
1718
{
18-
Assert.NotNull(_sut);
19+
_sut.ShouldNotBe(null);
1920
}
2021

2122
public async Task AndThenBddfyShouldCaptureExceptionsThrownInAsyncMethod()
@@ -30,13 +31,13 @@ private async Task<Sut> CreateSut()
3031
return new Sut();
3132
}
3233

33-
[Test]
34+
[Fact]
3435
public void Run()
3536
{
3637
var engine = this.LazyBDDfy();
37-
var exception = Assert.Throws<Exception>(() => engine.Run());
38+
var exception = Should.Throw<Exception>(() => engine.Run());
3839

39-
Assert.AreEqual("Exception in async void method!!", exception.Message);
40+
exception.Message.ShouldBe("Exception in async void method!!");
4041
}
4142

4243
internal class Sut

Samples/TestStack.BDDfy.Samples/CanWorkWithoutAStory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using NUnit.Framework;
1+
using Xunit;
22

33
namespace TestStack.BDDfy.Samples
44
{
@@ -16,7 +16,7 @@ public void Then_the_namespace_is_used_in_the_report()
1616
{
1717
}
1818

19-
[Test]
19+
[Fact]
2020
public void Execute()
2121
{
2222
this.BDDfy();
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Weavers>
3+
<ModuleInit />
4+
</Weavers>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using TestStack.BDDfy.Configuration;
2+
using TestStack.BDDfy.Reporters.Html;
3+
using TestStack.BDDfy.Samples;
4+
using TestStack.BDDfy.Samples.Atm;
5+
6+
/// <summary>
7+
/// Used by the ModuleInit. All code inside the Initialize method is ran as soon as the assembly is loaded.
8+
/// </summary>
9+
public static class ModuleInitializer
10+
{
11+
/// <summary>
12+
/// Initializes the module.
13+
/// </summary>
14+
public static void Initialize()
15+
{
16+
Configurator.Processors.Add(() => new CustomTextReporter());
17+
Configurator.BatchProcessors.MarkDownReport.Enable();
18+
Configurator.BatchProcessors.DiagnosticsReport.Enable();
19+
Configurator.BatchProcessors.Add(new HtmlReporter(new AtmHtmlReportConfig(), new MetroReportBuilder()));
20+
}
21+
}

0 commit comments

Comments
 (0)