BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ProjectTest Class Reference

Tests for Project class. More...

Inheritance diagram for ProjectTest:
[legend]
Collaboration diagram for ProjectTest:
[legend]

Public Member Functions

 ProjectTest ()
 
 ~ProjectTest ()
 
ProjectContext createContext ()
 
std::string createEmptyDir (const std::string &subdir) const
 Creates an empty directory in main test folder. More...
 
std::vector< SessionModel * > models () const
 
std::string testDir () const
 
std::string testPath () const
 Return full path to the test folder. Located in CMAKE_BINARY_DIR/test_output/<m_test_dir>. More...
 

Public Attributes

std::unique_ptr< SessionModelmaterial_model
 
std::unique_ptr< SessionModelsample_model
 

Protected Attributes

std::string m_test_dir
 

Detailed Description

Tests for Project class.

Definition at line 43 of file project.test.cpp.

Constructor & Destructor Documentation

◆ ProjectTest()

ProjectTest::ProjectTest ( )
inline

Definition at line 45 of file project.test.cpp.

46  : FolderBasedTest("test_ProjectTest")
47  , sample_model(std::make_unique<SessionModel>(samplemodel_name))
48  , material_model(std::make_unique<SessionModel>(materialmodel_name))
49  {
50  }
FolderBasedTest(const std::string &test_dir)
std::unique_ptr< SessionModel > material_model
std::unique_ptr< SessionModel > sample_model

◆ ~ProjectTest()

ProjectTest::~ProjectTest ( )
default

Member Function Documentation

◆ createContext()

ProjectContext ProjectTest::createContext ( )
inline

Definition at line 58 of file project.test.cpp.

59  {
60  ProjectContext result;
61  result.m_models_callback = [this]() { return models(); };
62  return result;
63  }
std::vector< SessionModel * > models() const
Provides necessary information for Project construction.
Definition: project_types.h:32
models_callback_t m_models_callback
Definition: project_types.h:42

References ModelView::ProjectContext::m_models_callback.

◆ createEmptyDir()

std::string FolderBasedTest::createEmptyDir ( const std::string &  subdir) const
inherited

Creates an empty directory in main test folder.

Remove recursively previous one with the same name, if exist.

Definition at line 39 of file folderbasedtest.cpp.

40 {
41  auto path = ModelView::Utils::join(testPath(), subdir);
44  return path;
45 }
std::string testPath() const
Return full path to the test folder. Located in CMAKE_BINARY_DIR/test_output/<m_test_dir>.
MVVM_MODEL_EXPORT void remove_all(const std::string &path)
Removes directory with all its content.
Definition: fileutils.cpp:67
MVVM_MODEL_EXPORT std::string join(const std::string &part1, const std::string &part2)
Joins two path elements into the path.
Definition: fileutils.cpp:37
MVVM_MODEL_EXPORT bool create_directory(const std::string &path)
Create directory, parent directory must exist.
Definition: fileutils.cpp:47

References ModelView::Utils::create_directory(), ModelView::Utils::join(), ModelView::Utils::remove_all(), and FolderBasedTest::testPath().

Here is the call graph for this function:

◆ models()

std::vector<SessionModel*> ProjectTest::models ( ) const
inline

Definition at line 53 of file project.test.cpp.

54  {
55  return {sample_model.get(), material_model.get()};
56  };

◆ testDir()

std::string FolderBasedTest::testDir ( ) const
inherited

Definition at line 24 of file folderbasedtest.cpp.

25 {
26  return m_test_dir;
27 }
std::string m_test_dir

References FolderBasedTest::m_test_dir.

◆ testPath()

std::string FolderBasedTest::testPath ( ) const
inherited

Return full path to the test folder. Located in CMAKE_BINARY_DIR/test_output/<m_test_dir>.

Definition at line 31 of file folderbasedtest.cpp.

32 {
34 }
std::string TestDirectoryPath(const std::string &test_sub_dir)
Returns full path to the main test folder in CMAKE_BINARY_DIR.
Definition: test_utils.cpp:47

References FolderBasedTest::m_test_dir, and TestUtils::TestDirectoryPath().

Referenced by FolderBasedTest::createEmptyDir().

Here is the call graph for this function:

Member Data Documentation

◆ m_test_dir

std::string FolderBasedTest::m_test_dir
protectedinherited

◆ material_model

std::unique_ptr<SessionModel> ProjectTest::material_model

Definition at line 66 of file project.test.cpp.

◆ sample_model

std::unique_ptr<SessionModel> ProjectTest::sample_model

Definition at line 65 of file project.test.cpp.


The documentation for this class was generated from the following file: