Newer
Older
Steve Williams
committed
#ifndef ADDSAMPLELOGTEST_H_
#define ADDSAMPLELOGTEST_H_
#include <cxxtest/TestSuite.h>
#include <string>
Peterson, Peter
committed
#include "MantidDataObjects/Workspace2D.h"
Steve Williams
committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "MantidAlgorithms/AddSampleLog.h"
using namespace Mantid::Kernel;
using namespace Mantid::API;
using namespace Mantid::DataObjects;
using namespace Mantid::Algorithms;
class AddSampleLogTest : public CxxTest::TestSuite
{
public:
void testInsertion()
{
AddSampleLog alg;
TS_ASSERT_THROWS_NOTHING(alg.initialize());
TS_ASSERT( alg.isInitialized() )
Workspace2D_sptr testWS = makeDummyWorkspace2D();
alg.setPropertyValue("Workspace", "AddSampleLogTest_Temporary");
alg.setPropertyValue("LogName", "my name");
alg.setPropertyValue("LogText", "my data");
TS_ASSERT_THROWS_NOTHING(alg.execute())
TS_ASSERT( alg.isExecuted() )
MatrixWorkspace_sptr output = boost::dynamic_pointer_cast<MatrixWorkspace>(AnalysisDataService::Instance().retrieve(alg.getProperty("Workspace")));
Sample wSpaceSam = output->sample();
PropertyWithValue<std::string> *testProp =
dynamic_cast<PropertyWithValue<std::string>*>(wSpaceSam.getLogData("my name"));
TS_ASSERT(testProp)
TS_ASSERT_EQUALS(testProp->value(), "my data")
}
Workspace2D_sptr makeDummyWorkspace2D()
{
Workspace2D_sptr testWorkspace(new Workspace2D);
AnalysisDataService::Instance().add("AddSampleLogTest_Temporary", testWorkspace);
return testWorkspace;
}
};
#endif /*ADDSAMPLELOGTEST_H_*/