From a8c85dad72b323251adbc6bf8f26e07485eb6809 Mon Sep 17 00:00:00 2001
From: Harry Jeffery <henry.jeffery@stfc.ac.uk>
Date: Wed, 26 Nov 2014 15:37:32 +0000
Subject: [PATCH] Refs #10238 Test plotting warnings

---
 .../test/ReflMainViewPresenterTest.h          | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/Code/Mantid/MantidQt/CustomInterfaces/test/ReflMainViewPresenterTest.h b/Code/Mantid/MantidQt/CustomInterfaces/test/ReflMainViewPresenterTest.h
index 5963ba6cd31..cd5fc7c0091 100644
--- a/Code/Mantid/MantidQt/CustomInterfaces/test/ReflMainViewPresenterTest.h
+++ b/Code/Mantid/MantidQt/CustomInterfaces/test/ReflMainViewPresenterTest.h
@@ -1204,6 +1204,58 @@ public:
     EXPECT_CALL(mockView, showAlgorithmDialog("SaveReflTBL"));
     presenter.notify(IReflPresenter::ExportTableFlag);
   }
+
+  void testPlotRowWarn()
+  {
+    MockView mockView;
+    ReflMainViewPresenter presenter(&mockView);
+
+    createPrefilledWorkspace("TestWorkspace");
+    createTOFWorkspace("TOF_12345", "12345");
+    EXPECT_CALL(mockView, getWorkspaceToOpen()).Times(1).WillRepeatedly(Return("TestWorkspace"));
+    presenter.notify(IReflPresenter::OpenTableFlag);
+
+    std::set<int> rowlist;
+    rowlist.insert(0);
+
+    //We should be warned
+    EXPECT_CALL(mockView, giveUserWarning(_,_));
+
+    //The user hits "plot rows" with the first row selected
+    EXPECT_CALL(mockView, getSelectedRows()).Times(1).WillRepeatedly(Return(rowlist));
+    presenter.notify(IReflPresenter::PlotRowFlag);
+
+    //Tidy up
+    AnalysisDataService::Instance().remove("TestWorkspace");
+    AnalysisDataService::Instance().remove("TOF_12345");
+  }
+
+  void testPlotGroupWarn()
+  {
+    MockView mockView;
+    ReflMainViewPresenter presenter(&mockView);
+
+    createPrefilledWorkspace("TestWorkspace");
+    createTOFWorkspace("TOF_12345", "12345");
+    createTOFWorkspace("TOF_12346", "12346");
+    EXPECT_CALL(mockView, getWorkspaceToOpen()).Times(1).WillRepeatedly(Return("TestWorkspace"));
+    presenter.notify(IReflPresenter::OpenTableFlag);
+
+    std::set<int> rowlist;
+    rowlist.insert(0);
+
+    //We should be warned
+    EXPECT_CALL(mockView, giveUserWarning(_,_));
+
+    //The user hits "plot groups" with the first row selected
+    EXPECT_CALL(mockView, getSelectedRows()).Times(1).WillRepeatedly(Return(rowlist));
+    presenter.notify(IReflPresenter::PlotGroupFlag);
+
+    //Tidy up
+    AnalysisDataService::Instance().remove("TestWorkspace");
+    AnalysisDataService::Instance().remove("TOF_12345");
+    AnalysisDataService::Instance().remove("TOF_12346");
+  }
 };
 
 #endif /* MANTID_CUSTOMINTERFACES_REFLMAINVIEWPRESENTERTEST_H */
-- 
GitLab