Skip to content

Commit

Permalink
Add further tests for Parameter File Selection re #5635 re #6281
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlPalmen committed Dec 13, 2012
1 parent 2b00027 commit aa0d02c
Show file tree
Hide file tree
Showing 4 changed files with 2,100 additions and 10 deletions.
96 changes: 86 additions & 10 deletions Code/Mantid/Framework/DataHandling/test/LoadInstrumentTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,16 @@ class LoadInstrumentTest : public CxxTest::TestSuite
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 );
TS_ASSERT( param );
if( param != 0) {
const FitParameter& fitParam4 = param->value<FitParameter>();
TS_ASSERT( fitParam4.getTie().compare("") == 0 );
TS_ASSERT( fitParam4.getFunction().compare("BackToBackExponential") == 0 );
}
else
{
TS_FAIL( "Did not find HRPD_Parameter.xml for HRPD_Definition.xml");
}

AnalysisDataService::Instance().remove(wsName);
}
Expand Down Expand Up @@ -471,14 +478,21 @@ class LoadInstrumentTest : public CxxTest::TestSuite
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 );
TS_ASSERT( param );
if( param != 0) {
const FitParameter& fitParam4 = param->value<FitParameter>();
TS_ASSERT( fitParam4.getTie().compare("") == 0 );
TS_ASSERT( fitParam4.getFunction().compare("BackToBackExponential") == 0 );
}
else
{
TS_FAIL( "Did not find HRPD_Parameter.xml for IDFs_for_UNIT_TESTING/HRPD_Definition.xml");
}

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

void testExecHRP3()
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.
Expand Down Expand Up @@ -518,9 +532,71 @@ class LoadInstrumentTest : public CxxTest::TestSuite
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 );
TS_ASSERT( param );
if( param != 0) {
const FitParameter& fitParam4 = param->value<FitParameter>();
TS_ASSERT( fitParam4.getTie().compare("") == 0 );
TS_ASSERT( fitParam4.getFunction().compare("BackToBackExponential") == 0 );
}
else
{
TS_FAIL( "Did not find HRPD_Parameter.xml for IDFs_for_UNIT_TESTING/HRPD_Definition_Test3.xml");
}

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

void testExecHRP4()
{
// Test Parameter file outside of instrument folder is used by an IDF file in the same folder and
// with the seame extension ('_Test4') of its name after the 'Defintion' or 'Parameter'.
InstrumentDataService::Instance().clear();

LoadInstrument loaderHRP4;

TS_ASSERT_THROWS_NOTHING(loaderHRP4.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));

loaderHRP4.setPropertyValue("Filename", "IDFs_for_UNIT_TESTING/HRPD_Definition_Test4.xml");
inputFile = loaderHRP4.getPropertyValue("Filename");

loaderHRP4.setPropertyValue("Workspace", wsName);

TS_ASSERT_THROWS_NOTHING(loaderHRP4.execute());

TS_ASSERT( loaderHRP4.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();

// It's "X0" in parameter file IDFs_for_UNIT_TESTING/HRPD_Parameters_Test4.xml
Parameter_sptr param = paramMap.getRecursive(&(*comp), "X0", "fitting");
TS_ASSERT( param );
if( param != 0) {
const FitParameter& fitParam4 = param->value<FitParameter>();
TS_ASSERT( fitParam4.getTie().compare("") == 0 );
TS_ASSERT( fitParam4.getFunction().compare("BackToBackExponential") == 0 );
}
else
{
TS_FAIL( "Did not find IDFs_for_UNIT_TESTING/HRPD_Parameter_Test4.xml for IDFs_for_UNIT_TESTING/HRPD_Definition_Test4.xml");
}

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

0 comments on commit aa0d02c

Please sign in to comment.