Skip to content

Commit 39b701f

Browse files
author
Gurpreet Singh
committed
additional coverage
1 parent 0f56380 commit 39b701f

File tree

5 files changed

+46
-18
lines changed

5 files changed

+46
-18
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ obj/
1616
packages/*
1717
PackageBuild/*
1818
Build/*
19-
TestResult.xml
19+
TestResult*
20+
CoverageReport
2021
TestStack.BDDfy.sln.ide/graph
2122
_NCrunch_TestStack.BDDfy/
2223
TestStack.BDDfy.sln.ide/

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,43 @@ public class AccountHasInsufficientFund
1010

1111
// You can override step text using executable attributes
1212
[Given("Given the Account Balance is $10")]
13-
void GivenTheAccountBalanceIs10()
13+
internal void GivenTheAccountBalanceIs10()
1414
{
1515
_card = new Card(true, 10);
1616
}
1717

18-
void And_given_the_Card_is_valid()
18+
internal void And_given_the_Card_is_valid()
1919
{
2020
}
2121

22-
void AndGivenTheMachineContainsEnoughMoney()
22+
internal void AndGivenTheMachineContainsEnoughMoney()
2323
{
2424
_atm = new Atm(100);
2525
}
2626

2727
[When("When the Account Holder requests $20")]
28-
void WhenTheAccountHolderRequests20()
28+
internal void WhenTheAccountHolderRequests20()
2929
{
3030
_atm.RequestMoney(_card, 20);
3131
}
3232

33-
void Then_the_ATM_should_not_dispense_any_Money()
33+
internal void Then_the_ATM_should_not_dispense_any_Money()
3434
{
3535
_atm.DispenseValue.ShouldBe(0);
3636
}
3737

38-
void And_the_ATM_should_say_there_are_Insufficient_Funds()
38+
internal void And_the_ATM_should_say_there_are_Insufficient_Funds()
3939
{
4040
_atm.Message.ShouldBe(DisplayMessage.InsufficientFunds);
4141
}
4242

4343
[AndThen("And the Account Balance should be $20")]
44-
void AndTheAccountBalanceShouldBe20()
44+
internal void AndTheAccountBalanceShouldBe20()
4545
{
4646
_card.AccountBalance.ShouldBe(10);
4747
}
4848

49-
void And_the_Card_should_be_returned()
49+
internal void And_the_Card_should_be_returned()
5050
{
5151
_atm.CardIsRetained.ShouldBe(false);
5252
}
@@ -56,5 +56,12 @@ public void Verify()
5656
{
5757
this.BDDfy<AccountHolderWithdrawsCash>();
5858
}
59+
60+
[Fact]
61+
public void VerifyLazy()
62+
{
63+
var engine = this.LazyBDDfy<AccountHolderWithdrawsCash>();
64+
engine.Run();
65+
}
5966
}
6067
}

src/TestStack.BDDfy.Tests/Configuration/TestRunnerTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
using System.Linq;
33
using Shouldly;
44
using TestStack.BDDfy.Configuration;
5+
using TestStack.BDDfy.Tests.Concurrency;
56
using Xunit;
67

78
namespace TestStack.BDDfy.Tests.Configuration
89
{
9-
[Collection("ExclusiveAccessToConfigurator")]
1010
public class TestRunnerTests
1111
{
1212
public class ScenarioWithFailingThen
@@ -33,6 +33,9 @@ public void PassingAndThen()
3333
}
3434
}
3535

36+
37+
[Collection(TestCollectionName.ModifiesConfigurator)]
38+
3639
public class When_StopExecutionOnFailingThen_IsSetToTrue
3740
{
3841
[Fact]

src/TestStack.BDDfy/BDDfyExtensions.cs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,20 @@ public static Engine LazyBDDfy<TStory>(this object testObject, string scenarioTi
5050
/// <param name="scenarioTitle">Overrides the default scenario title and is displayed in the reports.</param>
5151
/// <param name="caller">Caller (populated by [CallerMemberName])</param>
5252
/// <returns></returns>
53-
public static Story BDDfy(this object testObject, string scenarioTitle = null, [System.Runtime.CompilerServices.CallerMemberName] string caller = null)
53+
public static Story BDDfy(
54+
this object testObject,
55+
string scenarioTitle = null,
56+
[System.Runtime.CompilerServices.CallerMemberName]
57+
string caller = null)
5458
{
5559
return InternalLazyBDDfy(testObject, scenarioTitle ?? Configurator.Humanizer.Humanize(caller)).Run();
5660
}
5761

58-
public static Engine LazyBDDfy(this object testObject, string scenarioTitle = null, [System.Runtime.CompilerServices.CallerMemberName] string caller = null)
62+
public static Engine LazyBDDfy(
63+
this object testObject,
64+
string scenarioTitle = null,
65+
[System.Runtime.CompilerServices.CallerMemberName]
66+
string caller = null)
5967
{
6068
return InternalLazyBDDfy(testObject, scenarioTitle ?? Configurator.Humanizer.Humanize(caller));
6169
}
@@ -68,22 +76,30 @@ public static Engine LazyBDDfy(this object testObject, string scenarioTitle = nu
6876
/// <param name="scenarioTitle">Overrides the default scenario title and is displayed in the reports.</param>
6977
/// <param name="caller">Caller (populated by [CallerMemberName])</param>
7078
/// <returns></returns>
71-
public static Story BDDfy<TStory>(this object testObject, string scenarioTitle = null, [System.Runtime.CompilerServices.CallerMemberName] string caller = null)
72-
where TStory : class
79+
public static Story BDDfy<TStory>(
80+
this object testObject,
81+
string scenarioTitle = null,
82+
[System.Runtime.CompilerServices.CallerMemberName]
83+
string caller = null)
84+
where TStory : class
7385
{
7486
return InternalLazyBDDfy(testObject, scenarioTitle ?? Configurator.Humanizer.Humanize(caller), typeof(TStory)).Run();
7587
}
7688

77-
public static Engine LazyBDDfy<TStory>(this object testObject, string scenarioTitle = null, [System.Runtime.CompilerServices.CallerMemberName] string caller = null)
78-
where TStory : class
89+
public static Engine LazyBDDfy<TStory>(
90+
this object testObject,
91+
string scenarioTitle = null,
92+
[System.Runtime.CompilerServices.CallerMemberName]
93+
string caller = null)
94+
where TStory : class
7995
{
8096
return InternalLazyBDDfy(testObject, scenarioTitle ?? Configurator.Humanizer.Humanize(caller), typeof(TStory));
8197
}
8298
#endif
8399

84100
static Engine InternalLazyBDDfy(
85-
object testObject,
86-
string scenarioTitle,
101+
object testObject,
102+
string scenarioTitle,
87103
Type explicitStoryType = null)
88104
{
89105
var testContext = TestContext.GetContext(testObject);

src/TestStack.BDDfy/Properties/Annotations.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ public enum ImplicitUseTargetFlags
331331
/// which should not be removed and so is treated as used
332332
/// </summary>
333333
[MeansImplicitUse]
334+
[ExcludeFromCodeCoverage]
334335
public sealed class PublicAPIAttribute : Attribute
335336
{
336337
public PublicAPIAttribute() { }

0 commit comments

Comments
 (0)