-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit test that tests ApplyCalibration runs re #5797
Also ApplyCalibration that uses Geometry::ComponentHelper::moveComponent Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk>
- Loading branch information
1 parent
a58d83d
commit 50c7203
Showing
3 changed files
with
94 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
Code/Mantid/Framework/Algorithms/test/ApplyCalibrationTest.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#ifndef APPLYCALIBRATIONTEST_H_ | ||
#define APPLYCALIBRATIONTEST_H_ | ||
|
||
#include <cxxtest/TestSuite.h> | ||
|
||
#include "MantidDataHandling/LoadInstrument.h" | ||
#include "MantidAPI/IAlgorithm.h" | ||
#include "MantidAlgorithms/ApplyCalibration.h" | ||
#include "MantidAPI/Workspace.h" | ||
#include "MantidDataObjects/Workspace2D.h" | ||
#include "MantidAPI/MatrixWorkspace.h" | ||
#include "WorkspaceCreationHelperTest.h" | ||
#include "MantidAPI/AnalysisDataService.h" | ||
#include "MantidAPI/ITableWorkspace.h" | ||
#include "MantidAPI/TableRow.h" | ||
#include "MantidKernel/V3D.h" | ||
#include "MantidGeometry/Instrument.h" | ||
#include "MantidGeometry/Instrument/Component.h" | ||
#include <stdexcept> | ||
|
||
using namespace Mantid::Algorithms; | ||
using namespace Mantid::API; | ||
using namespace Mantid::Kernel; | ||
using namespace Mantid::DataObjects; | ||
|
||
class ApplyCalibrationTest : public CxxTest::TestSuite | ||
{ | ||
public: | ||
|
||
void testName() | ||
{ | ||
TS_ASSERT_EQUALS( appCalib.name(), "ApplyCalibration" ) | ||
} | ||
|
||
void testInit() | ||
{ | ||
appCalib.initialize(); | ||
TS_ASSERT( appCalib.isInitialized() ) | ||
} | ||
|
||
void testExec() | ||
{ | ||
// Create workspace with paremeterised instrument | ||
Workspace2D_sptr ws = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(3, 10, true); | ||
|
||
// Create Calibration Table | ||
ITableWorkspace_sptr posTableWs = WorkspaceFactory::Instance().createTable(); | ||
posTableWs->addColumn("int","Detector ID"); | ||
posTableWs->addColumn("V3D","Detector Position"); | ||
|
||
for(int i=0; i < 3; ++i) | ||
{ | ||
TableRow row = posTableWs->appendRow(); | ||
row << i << V3D(1.0,0.01*i,1.0); | ||
} | ||
TS_ASSERT_THROWS_NOTHING(appCalib.setProperty<Workspace2D_sptr>("Workspace", ws )); | ||
TS_ASSERT_THROWS_NOTHING(appCalib.setProperty<ITableWorkspace_sptr>("PositionTable", posTableWs )); | ||
try | ||
{ | ||
TS_ASSERT_EQUALS(appCalib.execute(),true); | ||
} | ||
catch(std::runtime_error & e) | ||
{ | ||
TS_FAIL(e.what()); | ||
} | ||
TS_ASSERT( appCalib.isExecuted() ); | ||
|
||
} | ||
|
||
private: | ||
ApplyCalibration appCalib; | ||
|
||
|
||
}; | ||
|
||
#endif /*APPLYCALIBRATIONTEST_H_*/ |