Skip to content

Commit

Permalink
Unit Test for Loading Instrument with Parameter File re #5635
Browse files Browse the repository at this point in the history
This one tests an IDF file not in the instrument folder with something extra added to its name uses the default parameter file in the instrument folder, because no parameter file has this extra part in its name.

Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk>
  • Loading branch information
KarlPalmen committed Dec 13, 2012
1 parent 5c4376d commit 2b00027
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion Code/Mantid/Framework/DataHandling/test/LoadInstrumentTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,6 @@ class LoadInstrumentTest : public CxxTest::TestSuite
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);
Expand Down Expand Up @@ -479,6 +478,53 @@ class LoadInstrumentTest : public CxxTest::TestSuite
AnalysisDataService::Instance().remove(wsName);
}

void testExecHRP3()
{
// Test Parameter file in instrument folder is used by an IDF file not in the instrument folder and
// with an extension of its name after the 'Defintion' not present in a parameter file.
InstrumentDataService::Instance().clear();

LoadInstrument loaderHRP3;

TS_ASSERT_THROWS_NOTHING(loaderHRP3.initialize());

//create a workspace with some sample data
wsName = "LoadInstrumentTestHRPD3";
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));

loaderHRP3.setPropertyValue("Filename", "IDFs_for_UNIT_TESTING/HRPD_Definition_Test3.xml");
inputFile = loaderHRP3.getPropertyValue("Filename");

loaderHRP3.setPropertyValue("Workspace", wsName);

TS_ASSERT_THROWS_NOTHING(loaderHRP3.execute());

TS_ASSERT( loaderHRP3.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 2b00027

Please sign in to comment.