Newer
Older
Janik Zikovsky
committed
#ifndef MANTID_ALGORITHMS_CREATEPEAKSWORKSPACETEST_H_
#define MANTID_ALGORITHMS_CREATEPEAKSWORKSPACETEST_H_
#include "MantidAlgorithms/CreatePeaksWorkspace.h"
#include "MantidAPI/MatrixWorkspace.h"
Janik Zikovsky
committed
#include "MantidDataObjects/PeaksWorkspace.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidKernel/System.h"
#include "MantidKernel/Timer.h"
#include "MantidTestHelpers/WorkspaceCreationHelper.h"
#include <cxxtest/TestSuite.h>
Janik Zikovsky
committed
using namespace Mantid::Algorithms;
using namespace Mantid::API;
using namespace Mantid::DataObjects;
class CreatePeaksWorkspaceTest : public CxxTest::TestSuite {
Janik Zikovsky
committed
public:
Janik Zikovsky
committed
CreatePeaksWorkspace alg;
TS_ASSERT_THROWS_NOTHING(alg.initialize())
TS_ASSERT(alg.isInitialized())
Janik Zikovsky
committed
}
Janik Zikovsky
committed
// Name of the output workspace.
std::string outWSName("CreatePeaksWorkspaceTest_OutputWS");
Workspace2D_sptr instws =
WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(2, 10);
Janik Zikovsky
committed
CreatePeaksWorkspace alg;
TS_ASSERT_THROWS_NOTHING(alg.initialize())
TS_ASSERT(alg.isInitialized())
TS_ASSERT_THROWS_NOTHING(
alg.setProperty("InstrumentWorkspace",
boost::dynamic_pointer_cast<MatrixWorkspace>(instws)));
TS_ASSERT_THROWS_NOTHING(
alg.setPropertyValue("OutputWorkspace", outWSName));
TS_ASSERT_THROWS_NOTHING(alg.setProperty("NumberOfPeaks", 13));
TS_ASSERT_THROWS_NOTHING(alg.execute();)
TS_ASSERT(alg.isExecuted());
Janik Zikovsky
committed
// Retrieve the workspace from data service.
PeaksWorkspace_sptr ws;
TS_ASSERT_THROWS_NOTHING(
ws = AnalysisDataService::Instance().retrieveWS<PeaksWorkspace>(
outWSName));
Janik Zikovsky
committed
TS_ASSERT(ws);
Janik Zikovsky
committed
// Check the results
TS_ASSERT_EQUALS(ws->getNumberPeaks(), 13);
Janik Zikovsky
committed
// Remove workspace from the data service.
AnalysisDataService::Instance().remove(outWSName);
}
};
#endif /* MANTID_ALGORITHMS_CREATEPEAKSWORKSPACETEST_H_ */