Skip to content
Snippets Groups Projects
LoadPreNexusTest.h 1.97 KiB
Newer Older
#ifndef MANTID_DATAHANDLING_LOADPRENEXUSTEST_H_
#define MANTID_DATAHANDLING_LOADPRENEXUSTEST_H_

#include <cxxtest/TestSuite.h>
#include "MantidKernel/Timer.h"
#include "MantidKernel/System.h"

#include "MantidDataHandling/LoadPreNexus.h"

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

class LoadPreNexusTest : 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 LoadPreNexusTest *createSuite() { return new LoadPreNexusTest(); }
  static void destroySuite(LoadPreNexusTest *suite) { delete suite; }
  void test_Init() {
    TS_ASSERT_THROWS_NOTHING(alg.initialize())
    TS_ASSERT(alg.isInitialized())

  void test_exec() {
    // Name of the output workspace.
    std::string outWSName("LoadPreNexusTest_OutputWS");
    TS_ASSERT_THROWS_NOTHING(alg.initialize())
    TS_ASSERT(alg.isInitialized())
    TS_ASSERT_THROWS_NOTHING(
        alg.setPropertyValue("Filename", "CNCS_7860_runinfo.xml"));
    TS_ASSERT_THROWS_NOTHING(
        alg.setPropertyValue("OutputWorkspace", outWSName));
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("ChunkNumber", 1));
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("TotalChunks", 5));
    TS_ASSERT_THROWS_NOTHING(alg.execute(););
    TS_ASSERT(alg.isExecuted());

    // Retrieve the workspace from data service. TODO: Change to your desired
    // type
    MatrixWorkspace_sptr ws;
    TS_ASSERT_THROWS_NOTHING(
        ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(
            outWSName));
    TS_ASSERT(ws);
    // TODO: Check the results
    // Check the monitor workspace is in there
    TS_ASSERT(ws->monitorWorkspace());
    // Remove workspace from the data service.
    AnalysisDataService::Instance().remove(outWSName);
  }
};

#endif /* MANTID_DATAHANDLING_LOADPRENEXUSTEST_H_ */