Skip to content
Snippets Groups Projects
MuonRemoveExpDecayTest.h 2.28 KiB
Newer Older
#ifndef MUONREMOVEEXPDECAYTEST_H_
#define MUONREMOVEEXPDECAYTEST_H_

#include <cxxtest/TestSuite.h>

#include "MantidDataHandling/LoadInstrument.h"
#include "MantidNexus/LoadMuonNexus.h"
#include "MantidAlgorithms/MuonRemoveExpDecay.h"
#include "MantidAPI/Workspace.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidAPI/AnalysisDataService.h"
#include <stdexcept>

using namespace Mantid::Algorithms;
using namespace Mantid::API;

class MuonRemoveExpDecayTest : public CxxTest::TestSuite
{
public:

  void testName()
  {
Matt Clarke's avatar
Matt Clarke committed
    TS_ASSERT_EQUALS( alg.name(), "RemoveExpDecay" )
  }

  void testCategory()
  {
    TS_ASSERT_EQUALS( alg.category(), "Muon" )
  }

  void testInit()
  {
    alg.initialize();
    TS_ASSERT( alg.isInitialized() )
  }

  void testLoadNexusAndSetProperties()
  {
Nick Draper's avatar
Nick Draper committed
  //This test does not run on Windows64 as is does not support HDF4 files

    loader.setPropertyValue("Filename", "emu00006473.nxs");
    loader.setPropertyValue("OutputWorkspace", "EMU6473");
    TS_ASSERT_THROWS_NOTHING( loader.execute() );
    TS_ASSERT_EQUALS(loader.isExecuted(),true);

    alg.setPropertyValue("InputWorkspace", "EMU6473");
    alg.setPropertyValue("OutputWorkspace", "Result");
    alg.setPropertyValue("Spectra", "0");
  }

  void testProperties()
  {
Nick Draper's avatar
Nick Draper committed
    //This test does not run on Windows64 as is does not support HDF4 files
    TS_ASSERT_EQUALS( alg.getPropertyValue("Spectra"), "0");
  }

  void testExecute()
  {
Nick Draper's avatar
Nick Draper committed
      //This test does not run on Windows64 as is does not support HDF4 files
    try 
    {
      TS_ASSERT_EQUALS(alg.execute(),true);
    }
    catch(std::runtime_error e)
    {
      TS_FAIL(e.what());
    }

    Workspace_const_sptr outputWS = AnalysisDataService::Instance().retrieve("Result");
  }

  void testWhereOptional3rdArgNotSet()
  {
  //This test does not run on Windows64 as is does not support HDF4 files

    MuonRemoveExpDecay alg2;
    alg2.initialize();

    alg2.setPropertyValue("InputWorkspace", "EMU6473");
    alg2.setPropertyValue("OutputWorkspace", "MuonRemoveExpDecayResult");

    try 
    {
      TS_ASSERT_EQUALS(alg2.execute(),true);
    }
    catch(std::runtime_error e)
    {
      TS_FAIL(e.what());
    }
  }


private:
  MuonRemoveExpDecay alg;
  Mantid::NeXus::LoadMuonNexus loader;

};
Nick Draper's avatar
Nick Draper committed

#endif /*MUONREMOVEEXPDECAYTEST_H_*/