Skip to content

Commit

Permalink
Add Unit Test for parameter file of IDF file re #6281
Browse files Browse the repository at this point in the history
This test loads an IDF not in the instrument folder and checks that it uses a parameter file that is in the instrument folder.

Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk>
  • Loading branch information
KarlPalmen committed Dec 13, 2012
1 parent 91fc311 commit 5c4376d
Show file tree
Hide file tree
Showing 2 changed files with 1,034 additions and 0 deletions.
47 changes: 47 additions & 0 deletions Code/Mantid/Framework/DataHandling/test/LoadInstrumentTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,53 @@ class LoadInstrumentTest : public CxxTest::TestSuite
AnalysisDataService::Instance().remove(wsName);
}

void testExecHRP2()
{
// Test Parameter file in instrument folder is used by an IDF file not in the instrument folder
InstrumentDataService::Instance().clear();

LoadInstrument loaderHRP2;

TS_ASSERT_THROWS_NOTHING(loaderHRP2.initialize());

//create a workspace with some sample data
wsName = "LoadInstrumentTestHRPD2";
Workspace_sptr ws = WorkspaceFactory::Instance().create("Workspace2D",1,1,1);
Workspace2D_sptr ws2D = boost::dynamic_pointer_cast<Workspace2D>(ws);

//put this workspace in the data service
TS_ASSERT_THROWS_NOTHING(AnalysisDataService::Instance().add(wsName, ws2D));

loaderHRP2.setPropertyValue("Filename", "IDFs_for_UNIT_TESTING/HRPD_Definition.xml");
// loaderHRP2.setPropertyValue("Filename", "HRPD_Definition.xml");
inputFile = loaderHRP2.getPropertyValue("Filename");

loaderHRP2.setPropertyValue("Workspace", wsName);

TS_ASSERT_THROWS_NOTHING(loaderHRP2.execute());

TS_ASSERT( loaderHRP2.isExecuted() );

// Get back the saved workspace
MatrixWorkspace_sptr output;
TS_ASSERT_THROWS_NOTHING(output = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(wsName));

boost::shared_ptr<const Instrument> i = output->getInstrument();

// test if a dummy parameter has been read in
boost::shared_ptr<const IComponent> comp = i->getComponentByName("bank_90degnew");
TS_ASSERT_EQUALS( comp->getName(), "bank_90degnew");

ParameterMap& paramMap = output->instrumentParameters();

Parameter_sptr param = paramMap.getRecursive(&(*comp), "S", "fitting");
const FitParameter& fitParam4 = param->value<FitParameter>();
TS_ASSERT( fitParam4.getTie().compare("") == 0 );
TS_ASSERT( fitParam4.getFunction().compare("BackToBackExponential") == 0 );

AnalysisDataService::Instance().remove(wsName);
}

void testNeutronicPositions()
{
// Make sure the IDS is empty
Expand Down

0 comments on commit 5c4376d

Please sign in to comment.