Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace TestCentric.Gui.Presenters.Main
{
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using Elements;
using Model;
using NUnit.Common;
Expand Down Expand Up @@ -95,6 +97,17 @@ public void OpenTestCentricProjectCommand_NoFileSelected_DoesNotCreateProject(st
_model.DidNotReceiveWithAnyArgs().OpenExistingProject(null);
}

[Test]
public void OpenTestCentricProjectCommand_ThrowsException_ErrorMessage_IsDisplayed()
{
_view.DialogManager.GetFileOpenPath(null, null).ReturnsForAnyArgs("Test.dll");
_model.When(m => m.OpenExistingProject("Test.dll")).Do(x => throw new IOException("Disk error"));

_view.OpenTestCentricProjectCommand.Execute += Raise.Event<CommandHandler>();

_view.MessageDisplay.Received().Error(Arg.Any<string>());
}

[Test]
public void OpenTestCentricProjectCommand_IsEnabled()
{
Expand Down
12 changes: 10 additions & 2 deletions src/GuiRunner/TestCentric.Gui/Presenters/TestCentricPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,16 @@ private void OpenTestCentricProject()
var filter = "TestCentric Projects (*.tcproj)|*.tcproj";

string file = _view.DialogManager.GetFileOpenPath("Existing Project", filter);
if (!string.IsNullOrEmpty(file))
_model.OpenExistingProject(file);

try
{
if (!string.IsNullOrEmpty(file))
_model.OpenExistingProject(file);
}
catch (Exception exception)
{
_view.MessageDisplay.Error("Unable to open project\n\n" + MessageBuilder.FromException(exception));
}
}

private void OpenTestAssembly()
Expand Down