LoadILLSANSTest.h 2.72 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef MANTID_DATAHANDLING_LOADILLSANSTEST_H_
#define MANTID_DATAHANDLING_LOADILLSANSTEST_H_

#include <cxxtest/TestSuite.h>

#include "MantidDataHandling/LoadILLSANS.h"

using Mantid::DataHandling::LoadILLSANS;
using namespace Mantid::API;

class LoadILLSANSTest : public CxxTest::TestSuite
{
public:
	// This pair of boilerplate methods prevent the suite being created statically
		// This means the constructor isn't called when running other tests
		static LoadILLSANSTest *createSuite() {
			return new LoadILLSANSTest();
		}
		static void destroySuite(LoadILLSANSTest *suite) {
			delete suite;
		}

		LoadILLSANSTest() :
24
25
				m_testFileTof("ILLD33_001030.nxs"),
				m_testFileNonTof("ILLD33_041714_NonTof.nxs"){
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
		}
		void testName() {
			LoadILLSANS alg;
			TS_ASSERT_EQUALS(alg.name(), "LoadILLSANS");
		}

		void testVersion() {
			LoadILLSANS alg;
			TS_ASSERT_EQUALS(alg.version(), 1);
		}

		void test_Init() {
			LoadILLSANS alg;
			TS_ASSERT_THROWS_NOTHING(alg.initialize())
			TS_ASSERT(alg.isInitialized())
		}

43
		void test_exec_TOF() {
44
45
			LoadILLSANS loader;
			loader.initialize();
46
			loader.setPropertyValue("Filename", m_testFileTof);
47
48
49
50
51
52
53
54
55
56
57
58
59

			std::string outputSpace = "LoadILLSANSTest_out";
			loader.setPropertyValue("OutputWorkspace", outputSpace);
			TS_ASSERT_THROWS_NOTHING(loader.execute());

			//  test workspace, copied from LoadMuonNexusTest.h
			MatrixWorkspace_sptr output;

			(output = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(
					outputSpace));
			MatrixWorkspace_sptr output2D = boost::dynamic_pointer_cast<
					MatrixWorkspace>(output);

60
			TS_ASSERT_EQUALS(output2D->getNumberHistograms(), 65536+2);
61
			TS_ASSERT_EQUALS(output2D->blocksize(), 100);
62
			TS_ASSERT_DIFFERS(output2D->run().getPropertyValueAsType<double>("monitor"),0.0);
63
64
65
			AnalysisDataService::Instance().clear();
		}

66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
		void test_exec_nonTOF() {
			LoadILLSANS loader;
			loader.initialize();
			loader.setPropertyValue("Filename", m_testFileNonTof);

			std::string outputSpace = "LoadILLSANSTest_out";
			loader.setPropertyValue("OutputWorkspace", outputSpace);
			TS_ASSERT_THROWS_NOTHING(loader.execute());

			//  test workspace, copied from LoadMuonNexusTest.h
			MatrixWorkspace_sptr output;

			(output = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(
					outputSpace));
			MatrixWorkspace_sptr output2D = boost::dynamic_pointer_cast<
					MatrixWorkspace>(output);

			TS_ASSERT_EQUALS(output2D->getNumberHistograms(), 65536+2);
			TS_ASSERT_EQUALS(output2D->blocksize(), 1);
85
			TS_ASSERT_DIFFERS(output2D->run().getPropertyValueAsType<double>("monitor"),0.0);
86
87
88
			AnalysisDataService::Instance().clear();
		}

89
90

	private:
91
92
		std::string m_testFileTof;
		std::string m_testFileNonTof;
93
94
95
96
97
98


};


#endif /* MANTID_DATAHANDLING_LOADILLSANSTEST_H_ */