Skip to content

Commit

Permalink
Refs #11690 Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonPiccardoSelg committed May 6, 2015
1 parent 1f72ffa commit 0b0df2c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions Code/Mantid/Vates/VatesAPI/CMakeLists.txt
Expand Up @@ -144,6 +144,7 @@ test/vtkMDHistoHex4DFactoryTest.h
test/vtkMDHistoHexFactoryTest.h
test/vtkMDHistoLineFactoryTest.h
test/vtkMDHistoQuadFactoryTest.h
test/vtkMD0DFactoryTest.h
test/FieldDataToMetadataTest.h
test/FilteringUpdateProgressActionTest.h
test/LoadVTKTest.h
Expand Down
2 changes: 2 additions & 0 deletions Code/Mantid/Vates/VatesAPI/src/vtkMD0DFactory.cpp
@@ -1,6 +1,7 @@
#include "MantidVatesAPI/vtkMD0DFactory.h"
#include "MantidAPI/IMDWorkspace.h"
#include "MantidVatesAPI/vtkNullUnstructuredGrid.h"
#include "MantidVatesAPI/ProgressAction.h"

using namespace Mantid::API;

Expand Down Expand Up @@ -29,6 +30,7 @@ namespace Mantid
*/
vtkDataSet* vtkMD0DFactory::create(ProgressAction& progressUpdating) const
{
(void) progressUpdating;
vtkNullUnstructuredGrid nullGrid;
vtkUnstructuredGrid *visualDataSet = nullGrid.createNullData();
return visualDataSet;
Expand Down
43 changes: 43 additions & 0 deletions Code/Mantid/Vates/VatesAPI/test/vtkMD0DFactoryTest.h
@@ -0,0 +1,43 @@
#ifndef VTK_MD_0D_FACTORY_TEST
#define VTK_MD_0D_FACTORY_TEST
#include <cxxtest/TestSuite.h>

#include "MantidVatesAPI/vtkMD0DFactory.h"
#include "MantidTestHelpers/MDEventsTestHelper.h"
#include "MantidVatesAPI/UserDefinedThresholdRange.h"
#include "MantidVatesAPI/NoThresholdRange.h"

#include "MockObjects.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>

#include "MantidVatesAPI/vtkStructuredGrid_Silent.h"

using namespace Mantid;
using namespace Mantid::VATES;
using namespace Mantid::API;
using namespace Mantid::DataObjects;
using namespace testing;


class vtkMD0DFactoryTest : public CxxTest::TestSuite
{
public:

void testCreatesA0DDataSet()
{
// Arrange
FakeProgressAction progressUpdater;
vtkMD0DFactory factory(ThresholdRange_scptr(new UserDefinedThresholdRange(0, 1)), "signal");

vtkDataSet* dataSet = NULL;

// Assert
TSM_ASSERT_THROWS_NOTHING("0D factory should create data set without exceptions", dataSet = factory.create(progressUpdater));
TSM_ASSERT("Should have exactly one point", dataSet->GetNumberOfPoints() == 1);
TSM_ASSERT("Should have exactly one cell", dataSet->GetNumberOfCells() == 1);
}
};


#endif

0 comments on commit 0b0df2c

Please sign in to comment.