Skip to content
Snippets Groups Projects
NDRandomNumberGeneratorTest.h 1.44 KiB
Newer Older
#ifndef NDRandomNumberGeneratorTEST_H_
#define NDRandomNumberGeneratorTEST_H_

#include <cxxtest/TestSuite.h>
#include "MantidKernel/NDRandomNumberGenerator.h"

#include <boost/scoped_ptr.hpp>
class NDRandomNumberGeneratorTest : public CxxTest::TestSuite
{
private:
  // RandomNumberGenerator is an interface so provide a trivial implementation 
  // for the test
  class Mock3DRandomNumberGenerator : public Mantid::Kernel::NDRandomNumberGenerator
    Mock3DRandomNumberGenerator()
      : Mantid::Kernel::NDRandomNumberGenerator(3)
    {}
    MOCK_METHOD0(generateNextPoint, void());
    MOCK_METHOD0(restart, void());
    MOCK_METHOD0(save, void());
    MOCK_METHOD0(restore, void());
  void test_That_nextPoint_Calls_generateNextPoint_Exactly_Once()
    using namespace Mantid::Kernel;
    Mock3DRandomNumberGenerator randImpl;
    NDRandomNumberGenerator & randGen = randImpl;

    EXPECT_CALL(randImpl, generateNextPoint()).Times(1);
    randGen.nextPoint();
    TSM_ASSERT("nextPoint was called an unexpected number of times",
              ::testing::Mock::VerifyAndClearExpectations(&randImpl));
  }

  void test_That_nextPoint_Vector_Is_Same_Size_As_Number_Of_Dimenions()
  {
    using namespace Mantid::Kernel;
    Mock3DRandomNumberGenerator randImpl;
    NDRandomNumberGenerator & randGen = randImpl;

    TS_ASSERT_EQUALS(randGen.nextPoint().size(), randGen.numberOfDimensions());