Skip to content
Snippets Groups Projects
RemoveExpDecayTest.h 2.41 KiB
Newer Older
#ifndef MUONREMOVEEXPDECAYTEST_H_
#define MUONREMOVEEXPDECAYTEST_H_

#include <cxxtest/TestSuite.h>
#include "MantidAPI/FrameworkManager.h"
#include "MantidAPI/AlgorithmManager.h"
#include "MantidTestHelpers/WorkspaceCreationHelper.h"

const std::string outputName = "MuonRemoveExpDecay_Output";

class RemoveExpDecayTest : public CxxTest::TestSuite {
  // This pair of boilerplate methods prevent the suite being created statically
  // This means the constructor isn't called when running other tests
  static RemoveExpDecayTest *createSuite() { return new RemoveExpDecayTest(); }
  static void destroySuite(RemoveExpDecayTest *suite) { delete suite; }
  RemoveExpDecayTest() { FrameworkManager::Instance(); }
  void testInit() {
    IAlgorithm_sptr alg = AlgorithmManager::Instance().create("RemoveExpDecay");
    alg->initialize();
    TS_ASSERT(alg->isInitialized())
  void testExecute() {
    auto ws = WorkspaceCreationHelper::Create2DWorkspace(1, 1);
    IAlgorithm_sptr alg = AlgorithmManager::Instance().create("RemoveExpDecay");
    alg->initialize();
    alg->setChild(true);
    alg->setProperty("InputWorkspace", ws);
    alg->setPropertyValue("OutputWorkspace", outputName);
    alg->setPropertyValue("Spectra", "0");
    TS_ASSERT_THROWS_NOTHING(alg->execute());
    TS_ASSERT(alg->isExecuted());

    MatrixWorkspace_sptr outWS = alg->getProperty("OutputWorkspace");
  void testExecuteWhereSepctraNotSet() {
    auto ws = WorkspaceCreationHelper::Create2DWorkspace(1, 1);
    IAlgorithm_sptr alg = AlgorithmManager::Instance().create("RemoveExpDecay");
    alg->initialize();
    alg->setChild(true);
    alg->setProperty("InputWorkspace", ws);
    alg->setPropertyValue("OutputWorkspace", outputName);
    TS_ASSERT_THROWS_NOTHING(alg->execute());
    TS_ASSERT(alg->isExecuted())

    MatrixWorkspace_sptr outWS = alg->getProperty("OutputWorkspace");
  void test_yUnitLabel() {
    auto ws = WorkspaceCreationHelper::Create2DWorkspace(1, 1);
    IAlgorithm_sptr alg = AlgorithmManager::Instance().create("RemoveExpDecay");
    alg->initialize();
    alg->setChild(true);
    alg->setProperty("InputWorkspace", ws);
    alg->setPropertyValue("OutputWorkspace", outputName);
    alg->execute();
    MatrixWorkspace_sptr result = alg->getProperty("OutputWorkspace");
    TS_ASSERT_EQUALS(result->YUnitLabel(), "Asymmetry");
Nick Draper's avatar
Nick Draper committed

#endif /*MUONREMOVEEXPDECAYTEST_H_*/