Skip to content

Commit 327afb5

Browse files
committed
Additional test cases
1 parent d385224 commit 327afb5

File tree

7 files changed

+147
-53
lines changed

7 files changed

+147
-53
lines changed

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
<!-- Default versions for targets not listed above -->
5353
<PropertyGroup>
54-
<NUnitVersion Condition="'$(NUnitVersion)'==''">4.3.2</NUnitVersion>
54+
<NUnitVersion Condition="'$(NUnitVersion)'==''">4.4.0</NUnitVersion>
5555
<NSubstituteVersion Condition="'$(NSubstituteVersion)'==''">5.3.0</NSubstituteVersion>
5656
<NUnitEngineVersion Condition="'$(NUnitEngineVersion)'==''">4.0.0-beta.1.39</NUnitEngineVersion>
5757
</PropertyGroup>

src/GuiRunner/TestCentric.Gui.Tests/Presenters/AgentSelectionControllerTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public void SetUp()
2626
// Ensure that model always has at least an empty package with no settings
2727
var options = new GuiOptions();
2828
_model.Options.Returns(options);
29+
_model.IsProjectLoaded.Returns(true);
2930
_model.TestCentricProject.Returns(new TestCentricProject(options));
3031
_model.TopLevelPackage.Returns(new NUnit.Engine.TestPackage());
3132

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// ***********************************************************************
2+
// Copyright (c) Charlie Poole and TestCentric contributors.
3+
// Licensed under the MIT License. See LICENSE file in root directory.
4+
// ***********************************************************************
5+
6+
using NSubstitute;
7+
using NUnit.Framework;
8+
9+
namespace TestCentric.Gui.Presenters.TestTree
10+
{
11+
using System.Windows.Forms;
12+
using Model;
13+
14+
public class BeforeTestsAreReloaded : TreeViewPresenterTestBase
15+
{
16+
[OneTimeSetUp]
17+
public void Setup()
18+
{
19+
_treeDisplayStrategyFactory = new TreeDisplayStrategyFactory();
20+
}
21+
22+
[TestCase("NUNIT_TREE", "UNGROUPED")]
23+
[TestCase("NUNIT_TREE", "ASSEMBLY")]
24+
[TestCase("NUNIT_TREE", "CATEGORY")]
25+
[TestCase("NUNIT_TREE", "OUTCOME")]
26+
[TestCase("NUNIT_TREE", "DURATION")]
27+
//[TestCase("TEST_LIST", "UNGROUPED")]
28+
[TestCase("TEST_LIST", "ASSEMBLY")]
29+
[TestCase("TEST_LIST", "CATEGORY")]
30+
[TestCase("TEST_LIST", "OUTCOME")]
31+
[TestCase("TEST_LIST", "DURATION")]
32+
public void VisualState_IsSaved(string displayFormat, string groupBy)
33+
{
34+
// Arrange
35+
//ITreeDisplayStrategy strategy = Substitute.For<ITreeDisplayStrategy>();
36+
//_treeDisplayStrategyFactory.Create(null, null, null).ReturnsForAnyArgs(strategy);
37+
_view.InvokeIfRequired(Arg.Do<MethodInvoker>(x => x.Invoke()));
38+
_settings.Gui.TestTree.DisplayFormat = displayFormat;
39+
_settings.Gui.TestTree.TestList.GroupBy = groupBy;
40+
_settings.Gui.TestTree.NUnitGroupBy = groupBy;
41+
var tv = new TreeView();
42+
_view.TreeView.Returns(tv);
43+
44+
var project = new TestCentricProject(new GuiOptions("dummy.dll"));
45+
_model.TestCentricProject.Returns(project);
46+
TestNode testNode = new TestNode("<test-suite id='1'/>");
47+
_model.LoadedTests.Returns(testNode);
48+
_model.TestsInRun.Returns(new TestSelection());
49+
FireTestLoadedEvent(testNode);
50+
51+
// Act
52+
FireTestsReloadingEvent();
53+
54+
// Assert
55+
//strategy.Received().SaveVisualState();
56+
string fileName = VisualState.GetVisualStateFileName("dummy.dll");
57+
VisualState visualState = VisualState.LoadFrom(fileName);
58+
Assert.That(visualState.DisplayStrategy, Is.EqualTo(displayFormat));
59+
Assert.That(visualState.GroupBy, Is.EqualTo(groupBy));
60+
}
61+
}
62+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// ***********************************************************************
2+
// Copyright (c) Charlie Poole and TestCentric contributors.
3+
// Licensed under the MIT License. See LICENSE file in root directory.
4+
// ***********************************************************************
5+
6+
using NSubstitute;
7+
using NUnit.Framework;
8+
9+
namespace TestCentric.Gui.Presenters.TestTree
10+
{
11+
using System.Windows.Forms;
12+
using Model;
13+
14+
public class BeforeTestsAreUnloaded : TreeViewPresenterTestBase
15+
{
16+
[OneTimeSetUp]
17+
public void Setup()
18+
{
19+
_treeDisplayStrategyFactory = new TreeDisplayStrategyFactory();
20+
}
21+
22+
[TestCase("NUNIT_TREE", "UNGROUPED")]
23+
[TestCase("NUNIT_TREE", "ASSEMBLY")]
24+
[TestCase("NUNIT_TREE", "CATEGORY")]
25+
[TestCase("NUNIT_TREE", "OUTCOME")]
26+
[TestCase("NUNIT_TREE", "DURATION")]
27+
//[TestCase("TEST_LIST", "UNGROUPED")]
28+
[TestCase("TEST_LIST", "ASSEMBLY")]
29+
[TestCase("TEST_LIST", "CATEGORY")]
30+
[TestCase("TEST_LIST", "OUTCOME")]
31+
[TestCase("TEST_LIST", "DURATION")]
32+
public void VisualState_IsSaved(string displayFormat, string groupBy)
33+
{
34+
// Arrange
35+
//ITreeDisplayStrategy strategy = Substitute.For<ITreeDisplayStrategy>();
36+
//_treeDisplayStrategyFactory.Create(null, null, null).ReturnsForAnyArgs(strategy);
37+
_view.InvokeIfRequired(Arg.Do<MethodInvoker>(x => x.Invoke()));
38+
_settings.Gui.TestTree.DisplayFormat = displayFormat;
39+
_settings.Gui.TestTree.TestList.GroupBy = groupBy;
40+
_settings.Gui.TestTree.NUnitGroupBy = groupBy;
41+
var tv = new TreeView();
42+
_view.TreeView.Returns(tv);
43+
44+
var project = new TestCentricProject(new GuiOptions("dummy.dll"));
45+
_model.TestCentricProject.Returns(project);
46+
TestNode testNode = new TestNode("<test-suite id='1'/>");
47+
_model.LoadedTests.Returns(testNode);
48+
_model.TestsInRun.Returns(new TestSelection());
49+
FireTestLoadedEvent(testNode);
50+
51+
// Act
52+
FireTestsUnloadingEvent();
53+
54+
// Assert
55+
//strategy.Received().SaveVisualState();
56+
string fileName = VisualState.GetVisualStateFileName("dummy.dll");
57+
VisualState visualState = VisualState.LoadFrom(fileName);
58+
Assert.That(visualState.DisplayStrategy, Is.EqualTo(displayFormat));
59+
Assert.That(visualState.GroupBy, Is.EqualTo(groupBy));
60+
}
61+
}
62+
}

src/GuiRunner/TestCentric.Gui.Tests/Presenters/TestTree/WhenTestRunBegins.cs

Lines changed: 16 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void TearDown()
3535
}
3636

3737
[Test]
38-
public void WhenTestRunStarts_TreeNodeImageIconsAreSet()
38+
public void TreeNodeImageIconsAreSet()
3939
{
4040
// Arrange
4141
var tv = new TreeView();
@@ -92,7 +92,7 @@ public void WhenTestRunStarts_TreeNodeImageIconsAreSet()
9292
[TestCase("Failed", TestTreeView.FailureIndex_NotLatestRun)]
9393
[TestCase("Warning", TestTreeView.WarningIndex_NotLatestRun)]
9494
[TestCase("Skipped", TestTreeView.SkippedIndex)]
95-
public void WhenTestRunStarts_TreeNodeWithResults_ImageIconsAreSet_ToPreviousOutcomeIcon(string resultState, int expectedImageIndex)
95+
public void TreeNodeWithResults_ImageIconsAreSet_ToPreviousOutcomeIcon(string resultState, int expectedImageIndex)
9696
{
9797
// Arrange
9898
var tv = new TreeView();
@@ -149,7 +149,7 @@ public void WhenTestRunStarts_TreeNodeWithResults_ImageIconsAreSet_ToPreviousOut
149149

150150
[TestCase("NUNIT_TREE")]
151151
[TestCase("TEST_LIST")]
152-
public void WhenTestRunStarts_CurrentDisplayFormat_IsSaved_InVisualFile(string displayFormat)
152+
public void CurrentDisplayFormat_IsSaved_InVisualFile(string displayFormat)
153153
{
154154
// Arrange
155155
_view.InvokeIfRequired(Arg.Do<MethodInvoker>(x => x.Invoke()));
@@ -173,48 +173,23 @@ public void WhenTestRunStarts_CurrentDisplayFormat_IsSaved_InVisualFile(string d
173173
Assert.That(visualState.DisplayStrategy, Is.EqualTo(displayFormat));
174174
}
175175

176-
// TODO: This is failing BUT manual tests show that the UNGROUPED display
177-
// persists after closing and re-opening the app. Error in test itself?
178-
//[TestCase("UNGROUPED")]
179-
[TestCase("ASSEMBLY")]
180-
[TestCase("CATEGORY")]
181-
[TestCase("OUTCOME")]
182-
public void WhenTestRunStarts_CurrentGroupBy_IsSaved_InVisualFile(string groupBy)
176+
[TestCase("NUNIT_TREE", "UNGROUPED")]
177+
[TestCase("NUNIT_TREE", "ASSEMBLY")]
178+
[TestCase("NUNIT_TREE", "CATEGORY")]
179+
[TestCase("NUNIT_TREE", "OUTCOME")]
180+
[TestCase("NUNIT_TREE", "DURATION")]
181+
//[TestCase("TEST_LIST", "UNGROUPED")]
182+
[TestCase("TEST_LIST", "ASSEMBLY")]
183+
[TestCase("TEST_LIST", "CATEGORY")]
184+
[TestCase("TEST_LIST", "OUTCOME")]
185+
[TestCase("TEST_LIST", "DURATION")]
186+
public void VisualStateIsSavedCorrectly(string displayFormat, string groupBy)
183187
{
184188
// Arrange
185189
_view.InvokeIfRequired(Arg.Do<MethodInvoker>(x => x.Invoke()));
186-
_settings.Gui.TestTree.DisplayFormat = "TEST_LIST";
190+
_settings.Gui.TestTree.DisplayFormat = displayFormat;
187191
_settings.Gui.TestTree.TestList.GroupBy = groupBy;
188-
189-
var tv = new TreeView();
190-
_view.TreeView.Returns(tv);
191-
192-
var project = new TestCentricProject(new GuiOptions(TestFileName));
193-
_model.TestCentricProject.Returns(project);
194-
TestNode testNode = new TestNode("<test-suite id='1'/>");
195-
_model.LoadedTests.Returns(testNode);
196-
FireTestLoadedEvent(testNode);
197-
198-
// Act
199-
FireRunStartingEvent(1234);
200-
201-
// Assert
202-
string fileName = VisualState.GetVisualStateFileName(TestFileName);
203-
VisualState visualState = VisualState.LoadFrom(fileName);
204-
Assert.That(visualState.GroupBy, Is.EqualTo(groupBy));
205-
}
206-
207-
[TestCase("UNGROUPED")]
208-
[TestCase("CATEGORY")]
209-
[TestCase("OUTCOME")]
210-
[TestCase("DURATION")]
211-
public void WhenTestRunStarts_NUnitTree_CurrentGroupBy_IsSaved_InVisualFile(string groupBy)
212-
{
213-
// Arrange
214-
_view.InvokeIfRequired(Arg.Do<MethodInvoker>(x => x.Invoke()));
215-
_settings.Gui.TestTree.DisplayFormat = "NUNIT_TREE";
216192
_settings.Gui.TestTree.NUnitGroupBy = groupBy;
217-
218193
var tv = new TreeView();
219194
_view.TreeView.Returns(tv);
220195

@@ -223,7 +198,6 @@ public void WhenTestRunStarts_NUnitTree_CurrentGroupBy_IsSaved_InVisualFile(stri
223198
TestNode testNode = new TestNode("<test-suite id='1'/>");
224199
_model.LoadedTests.Returns(testNode);
225200
_model.TestsInRun.Returns(new TestSelection());
226-
227201
FireTestLoadedEvent(testNode);
228202

229203
// Act
@@ -232,16 +206,8 @@ public void WhenTestRunStarts_NUnitTree_CurrentGroupBy_IsSaved_InVisualFile(stri
232206
// Assert
233207
string fileName = VisualState.GetVisualStateFileName(TestFileName);
234208
VisualState visualState = VisualState.LoadFrom(fileName);
209+
Assert.That(visualState.DisplayStrategy, Is.EqualTo(displayFormat));
235210
Assert.That(visualState.GroupBy, Is.EqualTo(groupBy));
236211
}
237-
238-
// TODO: Version 1 Test - Make it work if needed.
239-
//[Test]
240-
//public void WhenTestRunStarts_ResultsAreCleared()
241-
//{
242-
// _settings.RunStarting += Raise.Event<TestEventHandler>(new TestEventArgs(TestAction.RunStarting, "Dummy", 1234));
243-
244-
// _view.Received().ClearResults();
245-
//}
246212
}
247213
}

src/GuiRunner/TestCentric.Gui/Presenters/AgentSelectionController.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ public void PopulateMenu()
6161
public void UpdateMenuItems()
6262
{
6363
IPopup agentMenu = _view.SelectAgentMenu;
64+
agentMenu.Enabled = false;
65+
if (!_model.IsProjectLoaded)
66+
return;
67+
6468
IList<string> agentsToEnable = _model.GetAgentsForPackage(_model.TopLevelPackage);
6569
string selectedAgent = _model.TopLevelPackage.Settings.GetValueOrDefault(SettingDefinitions.SelectedAgentName);
6670
if (string.IsNullOrEmpty(selectedAgent))

src/GuiRunner/TestCentric.Gui/Presenters/TreeViewPresenter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,13 @@ private void WireUpEvents()
9696

9797
_model.Events.TestsUnloading += ea =>
9898
{
99-
var visualState = Strategy.CreateVisualState();
99+
SaveVisualState();
100100
ClosePropertiesDisplay();
101101
CloseXmlDisplay();
102102
};
103103

104104
_model.Events.TestsReloading += ea => SaveVisualState();
105105

106-
107106
_model.Events.RunStarting += (ea) =>
108107
{
109108
// Save the visual state in case test run causes an exception

0 commit comments

Comments
 (0)