Newer
Older
Steve Williams
committed
#ifndef ADDSAMPLELOGTEST_H_
#define ADDSAMPLELOGTEST_H_
#include <cxxtest/TestSuite.h>
#include <string>
#include "MantidTestHelpers/WorkspaceCreationHelper.h"
Steve Williams
committed
#include "MantidAlgorithms/AddSampleLog.h"
using namespace Mantid::Kernel;
using namespace Mantid::API;
using namespace Mantid::Algorithms;
class AddSampleLogTest : public CxxTest::TestSuite
{
public:
Gigg, Martyn Anthony
committed
void testInsertion2D()
{
ExecuteAlgorithm(WorkspaceCreationHelper::Create2DWorkspace(10,10));
}
Gigg, Martyn Anthony
committed
{
ExecuteAlgorithm(WorkspaceCreationHelper::CreateEventWorkspace(10,10));
}
Gigg, Martyn Anthony
committed
{
//add the workspace to the ADS
AnalysisDataService::Instance().add("AddSampleLogTest_Temporary", testWS);
//execute algorithm
Gigg, Martyn Anthony
committed
AddSampleLog alg;
TS_ASSERT_THROWS_NOTHING(alg.initialize());
TS_ASSERT( alg.isInitialized() )
Steve Williams
committed
alg.setPropertyValue("Workspace", "AddSampleLogTest_Temporary");
Gigg, Martyn Anthony
committed
alg.setPropertyValue("LogName", "my name");
alg.setPropertyValue("LogText", "my data");
Steve Williams
committed
TS_ASSERT_THROWS_NOTHING(alg.execute())
TS_ASSERT( alg.isExecuted() )
Steve Williams
committed
MatrixWorkspace_sptr output = boost::dynamic_pointer_cast<MatrixWorkspace>(AnalysisDataService::Instance().retrieve(alg.getProperty("Workspace")));
Gigg, Martyn Anthony
committed
const Run& wSpaceRun = output->run();
PropertyWithValue<std::string> *testProp = dynamic_cast<PropertyWithValue<std::string>*>(wSpaceRun.getLogData("my name"));
Steve Williams
committed
TS_ASSERT(testProp)
TS_ASSERT_EQUALS(testProp->value(), "my data")
//cleanup
AnalysisDataService::Instance().remove(output->getName());
Steve Williams
committed
Gigg, Martyn Anthony
committed
}
Steve Williams
committed
Steve Williams
committed
};
#endif /*ADDSAMPLELOGTEST_H_*/