Skip to content

Commit

Permalink
Re #8107. Fix unit tests in release mode.
Browse files Browse the repository at this point in the history
Now that StartLiveData will only accept an instrument, not a listener
name, add fake instruments for testing purposes.
  • Loading branch information
RussellTaylor committed Oct 10, 2013
1 parent f9c512c commit bc72701
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
9 changes: 6 additions & 3 deletions Code/Mantid/Framework/LiveData/test/LiveDataAlgorithmTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <iomanip>
#include "MantidLiveData/LiveDataAlgorithm.h"
#include "MantidTestHelpers/WorkspaceCreationHelper.h"
#include "MantidTestHelpers/FacilityHelper.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidAPI/AlgorithmManager.h"
#include "MantidAPI/FrameworkManager.h"
Expand All @@ -25,8 +26,8 @@ class LiveDataAlgorithmImpl : public LiveDataAlgorithm
// Make all the members public so I can test them.
friend class LiveDataAlgorithmTest;
public:
virtual const std::string name() const { return "LiveDataAlgorithmImpl";};
virtual int version() const { return 1;};
virtual const std::string name() const { return "LiveDataAlgorithmImpl";}
virtual int version() const { return 1;}
virtual const std::string category() const { return "Testing";}
void init()
{ this->initProps(); }
Expand Down Expand Up @@ -66,6 +67,8 @@ class LiveDataAlgorithmTest : public CxxTest::TestSuite

void test_validateInputs()
{
FacilityHelper::ScopedFacilities loadTESTFacility("IDFs_for_UNIT_TESTING/UnitTestFacilities.xml", "TEST");

LiveDataAlgorithmImpl alg;
TS_ASSERT_THROWS_NOTHING( alg.initialize() )
TS_ASSERT( alg.isInitialized() )
Expand All @@ -87,7 +90,7 @@ class LiveDataAlgorithmTest : public CxxTest::TestSuite
alg.setPropertyValue("AccumulationWorkspace", "out_ws");
TSM_ASSERT("AccumulationWorkspace == OutputWorkspace", !alg.validateInputs()["AccumulationWorkspace"].empty() );

alg.setPropertyValue("Instrument", "ISISHistoDataListener");
alg.setPropertyValue("Instrument", "TESTHISTOLISTENER");
alg.setPropertyValue("AccumulationMethod","Add");
TSM_ASSERT("Shouldn't add histograms", !alg.validateInputs()["AccumulationMethod"].empty() );
}
Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/LiveData/test/LoadLiveDataTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "MantidDataObjects/Workspace2D.h"
#include "MantidKernel/ConfigService.h"
#include "MantidAPI/LiveListenerFactory.h"
#include "MantidTestHelpers/FacilityHelper.h"

using namespace Mantid;
using namespace Mantid::LiveData;
Expand Down Expand Up @@ -64,6 +65,8 @@ class LoadLiveDataTest : public CxxTest::TestSuite
bool makeThrow = false
)
{
FacilityHelper::ScopedFacilities loadTESTFacility("IDFs_for_UNIT_TESTING/UnitTestFacilities.xml", "TEST");

std::auto_ptr<LoadLiveDataImpl> alg(new LoadLiveDataImpl);
TS_ASSERT_THROWS_NOTHING( alg->initialize() )
TS_ASSERT( alg->isInitialized() )
Expand Down
7 changes: 7 additions & 0 deletions Code/Mantid/Framework/LiveData/test/MonitorLiveDataTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "MantidDataObjects/EventWorkspace.h"
#include "MantidKernel/ConfigService.h"
#include "MantidAPI/FrameworkManager.h"
#include "MantidTestHelpers/FacilityHelper.h"

using namespace Mantid;
using namespace Mantid::LiveData;
Expand All @@ -22,12 +23,18 @@ using namespace Mantid::Kernel;

class MonitorLiveDataTest : public CxxTest::TestSuite
{
private:
FacilityHelper::ScopedFacilities loadTESTFacility;

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

MonitorLiveDataTest() : loadTESTFacility("IDFs_for_UNIT_TESTING/UnitTestFacilities.xml", "TEST")
{}

void setUp()
{
// Register algorithms
Expand Down
6 changes: 6 additions & 0 deletions Code/Mantid/Framework/LiveData/test/StartLiveDataTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "MantidAPI/AlgorithmManager.h"
#include "MantidAPI/FrameworkManager.h"
#include "MantidTestHelpers/WorkspaceCreationHelper.h"
#include "MantidTestHelpers/FacilityHelper.h"

using namespace Mantid;
using namespace Mantid::LiveData;
Expand All @@ -21,12 +22,17 @@ using namespace Mantid::Kernel;

class StartLiveDataTest : public CxxTest::TestSuite
{
private:
FacilityHelper::ScopedFacilities loadTESTFacility;

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

StartLiveDataTest() : loadTESTFacility("IDFs_for_UNIT_TESTING/UnitTestFacilities.xml", "TEST")
{}

void test_Init()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
<livedata listener="ISISHistoDataListener" address="127.0.0.1:6789" />
</instrument>

<instrument name="TestDataListener">
<technique>Test Listener</technique>
<livedata listener="TestDataListener" address="127.0.0.1:0" />
</instrument>

<instrument name="FakeEventDataListener">
<technique>Test Listener</technique>
<livedata listener="FakeEventDataListener" address="127.0.0.1:0" />
</instrument>

</facility>

</facilities>
</facilities>

0 comments on commit bc72701

Please sign in to comment.