Skip to content

Commit

Permalink
Refs #10438. Added test with a WorkspaceGroup.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfpeterson committed Nov 5, 2014
1 parent 7f2786d commit 0059a8e
Showing 1 changed file with 39 additions and 5 deletions.
44 changes: 39 additions & 5 deletions Code/Mantid/Framework/DataHandling/test/SavePDFGuiTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <Poco/File.h>
#include <fstream>

#include "MantidAPI/AlgorithmManager.h"
#include "MantidDataHandling/SavePDFGui.h"
#include "MantidDataHandling/LoadNexusProcessed.h"

Expand Down Expand Up @@ -56,6 +57,16 @@ class SavePDFGuiTest : public CxxTest::TestSuite
return n;
}

bool loadWorkspace(const std::string &filename, const std::string wsName)
{
LoadNexusProcessed load;
load.initialize();
load.setProperty("Filename", filename);
load.setProperty("OutputWorkspace", wsName);
load.execute();
return load.isExecuted();
}

void test_exec()
{
// name of workspace to create and save
Expand All @@ -64,11 +75,7 @@ class SavePDFGuiTest : public CxxTest::TestSuite
const std::string outFilename("SavePDFGuiTest_Output.gr");

// Load a file to save out
LoadNexusProcessed load;
load.initialize();
load.setProperty("Filename", "nom_gr.nxs");
load.setProperty("OutputWorkspace", wsName);
load.execute();
TS_ASSERT(loadWorkspace("nom_gr.nxs", wsName));

// save the file
SavePDFGui alg;
Expand All @@ -91,6 +98,33 @@ class SavePDFGuiTest : public CxxTest::TestSuite
outFile.remove(false);
}

void test_exec_ws_group()
{
// Create a group
const std::string groupName("SavePDFGUIGroup");
TS_ASSERT(loadWorkspace("nom_gr.nxs", groupName+"_1"));
TS_ASSERT(loadWorkspace("nom_gr.nxs", groupName+"_2"));

auto grpAlg = AlgorithmManager::Instance().createUnmanaged("GroupWorkspaces");
grpAlg->initialize();
grpAlg->setPropertyValue("InputWorkspaces", groupName+"_1,"+groupName+"_2");
grpAlg->setPropertyValue("OutputWorkspace", groupName);
grpAlg->execute();

// name of the output file
const std::string outFilename("SavePDFGUIGroup.gr");

// run the algorithm with a group
SavePDFGui alg;
TS_ASSERT_THROWS_NOTHING( alg.initialize() );
TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("InputWorkspace", groupName) );
TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("Filename","SavePDFGUIGroup.gr") );
TS_ASSERT_THROWS_NOTHING( alg.execute() );
TS_ASSERT( alg.isExecuted() );

// remove the workspace group
AnalysisDataService::Instance().deepRemoveGroup(groupName);
}
};


Expand Down

0 comments on commit 0059a8e

Please sign in to comment.