Skip to content

Commit 10174ce

Browse files
committed
Fix obsolete messages
1 parent 84b0e3c commit 10174ce

File tree

4 files changed

+34
-12
lines changed

4 files changed

+34
-12
lines changed

Diff for: Tests/Features/MyHome.Spec/CategoryManagement/AddingACategorySteps.cs

+10-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ public class AddingACategorySteps
1616
private AccountingDataContext _context;
1717
private ICategoryService<DataClasses.Category> _categoryService;
1818
private string _categoryName;
19+
private readonly ScenarioContext _scenarioContext;
20+
21+
public AddingACategorySteps(ScenarioContext scenarioContext)
22+
{
23+
_scenarioContext = scenarioContext;
24+
}
1925

2026
[BeforeScenario]
2127
public void Setup()
@@ -73,7 +79,7 @@ public void GivenThereIsAnotherCategoryWithTheSameName()
7379
}
7480
catch (Exception e)
7581
{
76-
ScenarioContext.Current.Add("add_category_result", e);
82+
_scenarioContext.Add("add_category_result", e);
7783
}
7884
}
7985

@@ -86,7 +92,7 @@ public void GivenIHaveEnteredNothingForTheName()
8692
}
8793
catch (ArgumentException e)
8894
{
89-
ScenarioContext.Current.Add("add_category_result", e);
95+
_scenarioContext.Add("add_category_result", e);
9096
}
9197
}
9298

@@ -99,14 +105,14 @@ public void WhenIPressAdd()
99105
}
100106
catch (Exception e)
101107
{
102-
ScenarioContext.Current.Add("add_category_result", e);
108+
_scenarioContext.Add("add_category_result", e);
103109
}
104110
}
105111

106112
[Then(@"the handler returns an error indicator")]
107113
public void TheHandlerReturnsAnErrorIndicator()
108114
{
109-
var exception = ScenarioContext.Current.Get<Exception>("add_category_result");
115+
var exception = _scenarioContext.Get<Exception>("add_category_result");
110116
Assert.IsNotNull(exception);
111117
}
112118

Diff for: Tests/Features/MyHome.Spec/CategoryManagement/UpdatingCategorySteps.cs

+8-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace MyHome.Spec.CategoryManagement
1414
public class UpdatingCategorySteps
1515
{
1616
private const string AddCategoryResultKey = "add_category_result";
17-
17+
private readonly ScenarioContext _scenarioContext;
1818
private AccountingDataContext _context;
1919
private string _categoryName;
2020
private string _newName;
@@ -23,6 +23,10 @@ public class UpdatingCategorySteps
2323

2424
ICategoryService<DataClasses.Category> _categoryService;
2525

26+
public UpdatingCategorySteps(ScenarioContext scenarioContext)
27+
{
28+
_scenarioContext = scenarioContext;
29+
}
2630
[BeforeScenario]
2731
public void Setup()
2832
{
@@ -111,7 +115,7 @@ public void GivenIHaveEnteredNothingForTheName()
111115
}
112116
catch (Exception e)
113117
{
114-
ScenarioContext.Current.Add(AddCategoryResultKey, e);
118+
_scenarioContext.Add(AddCategoryResultKey, e);
115119
}
116120
}
117121

@@ -127,7 +131,7 @@ public void WhenIChangeTheNameTo(string newName)
127131
}
128132
catch (Exception e)
129133
{
130-
ScenarioContext.Current.Add(AddCategoryResultKey, e);
134+
_scenarioContext.Add(AddCategoryResultKey, e);
131135
}
132136
}
133137

@@ -142,7 +146,7 @@ public void ThenTheCategoryIsUpdated()
142146
[Then(@"the handler returns an error indicator")]
143147
public void TheHandlerReturnsAnErrorIndicator()
144148
{
145-
var exception = ScenarioContext.Current.Get<Exception>(AddCategoryResultKey);
149+
var exception = _scenarioContext.Get<Exception>(AddCategoryResultKey);
146150
Assert.IsNotNull(exception);
147151
}
148152

Diff for: Tests/Features/MyHome.Spec/TransactionManagement/AddingATransactionSteps.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace MyHome.Spec.TransactionManagement
1616
public class AddingATransactionSteps
1717
{
1818
const string ExceptionContextKey = "add_transaction_result";
19+
private readonly ScenarioContext _scenarioContext;
1920
private TransactionTypes _transactionType;
2021
private Transaction _transaction;
2122
private ITransactionService _transactionService;
@@ -25,6 +26,11 @@ public class AddingATransactionSteps
2526
private PaymentMethod _paymentMethod;
2627
private AccountingDataContext _context;
2728

29+
public AddingATransactionSteps(ScenarioContext scenarioContext)
30+
{
31+
_scenarioContext = scenarioContext;
32+
}
33+
2834
[BeforeScenario]
2935
public void Setup()
3036
{
@@ -109,7 +115,7 @@ public void WhenIPressAdd()
109115
}
110116
catch (Exception e)
111117
{
112-
ScenarioContext.Current.Add(ExceptionContextKey, e);
118+
_scenarioContext.Add(ExceptionContextKey, e);
113119
}
114120
}
115121

@@ -124,7 +130,7 @@ public void ThenTheTransactionShouldBeAddedToTheList()
124130
[Then(@"the handler returns an error indicator - '(.*)'")]
125131
public void ThenTheHandlerReturnsAnErrorIndicator(string errorMessage)
126132
{
127-
var e = ScenarioContext.Current.Get<Exception>(ExceptionContextKey);
133+
var e = _scenarioContext.Get<Exception>(ExceptionContextKey);
128134
Assert.IsNotNull(e);
129135
Assert.IsInstanceOfType(e, typeof(ArgumentException));
130136
Assert.AreEqual(errorMessage, e.Message, ignoreCase: true);

Diff for: Tests/Features/MyHome.Spec/TransactionManagement/EditingATransactionSteps.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public enum Properties
2626
public class EditingATransactionSteps
2727
{
2828
const string ExceptionContextKey = "edit_transaction_result";
29+
private readonly ScenarioContext _scenarioContext;
2930
private TransactionTypes _transactionType;
3031
private Transaction _transaction;
3132
private ITransactionService _transactionService;
@@ -35,6 +36,11 @@ public class EditingATransactionSteps
3536
private PaymentMethod _paymentMethod;
3637
private AccountingDataContext _context;
3738

39+
public EditingATransactionSteps(ScenarioContext scenarioContext)
40+
{
41+
_scenarioContext = scenarioContext;
42+
}
43+
3844
[BeforeScenario]
3945
public void Setup()
4046
{
@@ -135,7 +141,7 @@ public void WhenIChangeTheTo(Properties propChanging, string value)
135141
}
136142
catch (Exception e)
137143
{
138-
ScenarioContext.Current.Add(ExceptionContextKey, e);
144+
_scenarioContext.Add(ExceptionContextKey, e);
139145
}
140146
}
141147

@@ -175,7 +181,7 @@ public void ThenTheTransactionShouldBeAddedToTheList()
175181
[Then(@"the handler returns an error indicator - '(.*)'")]
176182
public void ThenTheHandlerReturnsAnErrorIndicator(string errorMessage)
177183
{
178-
var e = ScenarioContext.Current.Get<Exception>(ExceptionContextKey);
184+
var e = _scenarioContext.Get<Exception>(ExceptionContextKey);
179185
Assert.IsNotNull(e);
180186
Assert.IsInstanceOfType(e, typeof(ArgumentException));
181187
Assert.AreEqual(errorMessage, e.Message, true);

0 commit comments

Comments
 (0)