Skip to content

Commit

Permalink
Refs #7178. Add a test for existing log properties.
Browse files Browse the repository at this point in the history
Though http://www.mantidproject.org/Run#ISIS_Muon_data does have
a list of run properties read from the Muon files, it wasn't checked
in any of tests before.
  • Loading branch information
arturbekasov committed Jan 22, 2014
1 parent 750af37 commit 8f75f52
Showing 1 changed file with 57 additions and 1 deletion.
58 changes: 57 additions & 1 deletion Code/Mantid/Framework/DataHandling/test/LoadMuonNexus1Test.h
Expand Up @@ -8,7 +8,8 @@
#include "MantidDataObjects/WorkspaceSingleValue.h"
#include "MantidDataObjects/TableWorkspace.h"
#include "MantidDataHandling/LoadInstrument.h"
//

#include "MantidAPI/ScopedWorkspace.h"

#include <fstream>
#include <cxxtest/TestSuite.h>
Expand Down Expand Up @@ -620,6 +621,61 @@ class LoadMuonNexus1Test : public CxxTest::TestSuite
AnalysisDataService::Instance().deepRemoveGroup(outWSName);
AnalysisDataService::Instance().deepRemoveGroup(detectorGroupingWSName);
}

void test_loadRunInformation()
{
ScopedWorkspace outWsEntry;

LoadMuonNexus1 alg;

TS_ASSERT_THROWS_NOTHING( alg.initialize() );
TS_ASSERT( alg.isInitialized() );

TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("Filename", "emu00006473.nxs") );
TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("OutputWorkspace", outWsEntry.name()) );

TS_ASSERT_THROWS_NOTHING( alg.execute() );
TS_ASSERT( alg.isExecuted() );

Workspace_sptr outWs = outWsEntry.retrieve();
TS_ASSERT(outWs);

if (!outWs)
return;

auto ws = boost::dynamic_pointer_cast<MatrixWorkspace>(outWs);
TS_ASSERT(ws);

if (!ws)
return;

const Run& run = ws->run();

// Check expected properties
checkProperty(run, "run_number", std::string("6473"));
checkProperty(run, "run_title", std::string("Cr2.7Co0.3Si T=200.0 F=5.0"));
checkProperty(run, "run_start", std::string("2006-11-21T07:04:30"));
checkProperty(run, "run_end", std::string("2006-11-21T09:29:28"));
checkProperty(run, "dur_secs", std::string("8697"));
checkProperty(run, "nspectra", 32);
checkProperty(run, "goodfrm", 417485);
}

template<typename T>
void checkProperty(const Run& run, const std::string& property, const T& expectedValue)
{
if ( run.hasProperty(property) )
{
T propertyValue = run.getPropertyValueAsType<T>(property);

TSM_ASSERT_EQUALS("Property value mismatch: " + property, propertyValue, expectedValue);
}
else
{
TS_FAIL("No property: " + property);
}
}

private:
LoadMuonNexus1 nxLoad,nxload2,nxload3;
std::string outputSpace;
Expand Down

0 comments on commit 8f75f52

Please sign in to comment.