/
SampleShapeValidatorTest.h
46 lines (33 loc) · 1.51 KB
/
SampleShapeValidatorTest.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef MANTID_API_SAMPLESHAPEVALIDATORTEST_H_
#define MANTID_API_SAMPLESHAPEVALIDATORTEST_H_
#include <cxxtest/TestSuite.h>
#include "MantidAPI/SampleShapeValidator.h"
#include "MantidTestHelpers/ComponentCreationHelper.h"
#include "MantidTestHelpers/FakeObjects.h"
#include "boost/make_shared.hpp"
using Mantid::API::SampleShapeValidator;
class SampleShapeValidatorTest : public CxxTest::TestSuite
{
public:
// This pair of boilerplate methods prevent the suite being created statically
// This means the constructor isn't called when running other tests
static SampleShapeValidatorTest *createSuite() { return new SampleShapeValidatorTest(); }
static void destroySuite( SampleShapeValidatorTest *suite ) { delete suite; }
void test_validator_passes_for_workspace_with_defined_sample_shape()
{
auto fakeWS = boost::make_shared<WorkspaceTester>();
// Add a sample shape
auto sphere = ComponentCreationHelper::createSphere(1.0, V3D(), "sphere");
fakeWS->mutableSample().setShape(*sphere);
auto sampleValidator = boost::make_shared<SampleShapeValidator>();
TS_ASSERT_EQUALS( sampleValidator->isValid(fakeWS), "" );
}
void test_validator_throws_error_for_workspace_without_shape()
{
auto fakeWS = boost::make_shared<WorkspaceTester>();
auto sampleValidator = boost::make_shared<SampleShapeValidator>();
TS_ASSERT_EQUALS( sampleValidator->isValid(fakeWS),
"Invalid or no shape defined for sample" );
}
};
#endif /* MANTID_API_SAMPLESHAPEVALIDATORTEST_H_ */