Skip to content

Commit

Permalink
Refs #11814 make unit test more efficient
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonPiccardoSelg committed May 26, 2015
1 parent d18fe6a commit 191ad69
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 40 deletions.
2 changes: 1 addition & 1 deletion Code/Mantid/Vates/VatesAPI/CMakeLists.txt
Expand Up @@ -227,7 +227,7 @@ if( CXXTEST_FOUND AND GMOCK_FOUND AND GTEST_FOUND )
../../Framework/TestHelpers/src/MDEventsTestHelper.cpp
../../Framework/TestHelpers/src/StartFrameworkManager.cpp )
cxxtest_add_test( VatesAPITest ${TEST_FILES} )
target_link_libraries( VatesAPITest VatesAPI DataHandling Kernel DataObjects MDAlgorithms ${GMOCK_LIBRARIES} ${GTEST_LIBRARIES} )
target_link_libraries( VatesAPITest VatesAPI DataHandling Kernel DataObjects ${GMOCK_LIBRARIES} ${GTEST_LIBRARIES} )
add_dependencies( AllTests VatesAPITest )
# Add to the 'UnitTests' group in VS
set_property ( TARGET VatesAPITest PROPERTY FOLDER "UnitTests" )
Expand Down
47 changes: 8 additions & 39 deletions Code/Mantid/Vates/VatesAPI/test/BoxInfoTest.h
@@ -1,12 +1,11 @@
#ifndef COMOPOSITE_PEAKS_BOX_INFO_TEST_H_
#define COMOPOSITE_PEAKS_BOX_INFO_TEST_H_
#ifndef VATES_API_BOX_INFO_TEST_H_
#define VATES_API_BOX_INFO_TEST_H_

#include <cxxtest/TestSuite.h>
#include "MantidVatesAPI/BoxInfo.h"
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/AlgorithmManager.h"
#include "MantidAPI/BoxController.h"
#include "MantidKernel/PropertyWithValue.h"
#include "MantidMDAlgorithms/ConvertToMD.h"
#include "MantidTestHelpers/MDEventsTestHelper.h"
#include "MantidDataObjects/MDLeanEvent.h"

Expand Down Expand Up @@ -46,7 +45,11 @@ class BoxInfoTest : public CxxTest::TestSuite {
void test_initial_recursion_depth_is_1_for_MD_Event_w_split() {
// Arrange
const std::string wsName = "MD_EVENT_WS_WITH_SPLITTING";
provideMDEventWorspaceWithTopLevelSplitting(wsName);
auto ws = makeAnyMDEW<MDLeanEvent<3>, 3>(10, 0.0, 10.0, 1, wsName);
BoxController_sptr boxController = ws->getBoxController();
boxController->setSplitTopInto(0,10);
boxController->setSplitTopInto(1, 20);
boxController->setSplitTopInto(2,30);

// Act
auto result = Mantid::VATES::findRecursionDepthForTopLevelSplitting(wsName);
Expand All @@ -57,40 +60,6 @@ class BoxInfoTest : public CxxTest::TestSuite {
// Clean up
AnalysisDataService::Instance().remove(wsName);
}

private:
void provideMDEventWorspaceWithTopLevelSplitting(std::string wsName) {

auto alg = Mantid::API::AlgorithmManager::Instance().create(
"CreateSampleWorkspace");
alg->initialize();
alg->setChild(true);
alg->setProperty("WorkspaceType", "Event");
alg->setPropertyValue("OutputWorkspace", wsName);
alg->execute();

Mantid::API::MatrixWorkspace_sptr ws = alg->getProperty("OutputWorkspace");
Mantid::API::Run &run = ws->mutableRun();
auto eiLog = new PropertyWithValue<double>("Ei", 12.0);
run.addLogData(eiLog);

Mantid::MDAlgorithms::ConvertToMD convertAlg;
convertAlg.setChild(true);
convertAlg.initialize();
convertAlg.setPropertyValue("OutputWorkspace",wsName);
convertAlg.setProperty("InputWorkspace", ws);
convertAlg.setProperty("QDimensions", "Q3D");
convertAlg.setProperty("dEAnalysisMode", "Direct");
convertAlg.setPropertyValue("MinValues","-10,-10,-10, 0");
convertAlg.setPropertyValue("MaxValues"," 10, 10, 10, 1");
convertAlg.setPropertyValue("TopLevelSplitting", "1");
convertAlg.execute();

if (!AnalysisDataService::Instance().doesExist(wsName)) {
IMDEventWorkspace_sptr ws_new = convertAlg.getProperty("OutputWorkspace");
AnalysisDataService::Instance().addOrReplace(wsName, ws_new);
}
}
};

#endif

0 comments on commit 191ad69

Please sign in to comment.