LoadILLSANSTest.h 2.81 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
#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;

11
class LoadILLSANSTest : public CxxTest::TestSuite {
12
public:
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
  // 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()
      : m_testFileTof("ILLD33_001030.nxs"),
        m_testFileNonTof("ILLD33_041714_NonTof.nxs") {}
  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())
  }

  void test_exec_TOF() {
    LoadILLSANS loader;
    loader.initialize();
    loader.setPropertyValue("Filename", m_testFileTof);

    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(), 100);
    TS_ASSERT_DIFFERS(output2D->run().getPropertyValueAsType<double>("monitor"),
                      0.0);
    AnalysisDataService::Instance().clear();
  }

  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);
    TS_ASSERT_DIFFERS(output2D->run().getPropertyValueAsType<double>("monitor"),
                      0.0);
    AnalysisDataService::Instance().clear();
  }

private:
  std::string m_testFileTof;
  std::string m_testFileNonTof;
88
89
90
};

#endif /* MANTID_DATAHANDLING_LOADILLSANSTEST_H_ */