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

Tests for ProjectManager class. More...

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

Public Member Functions

 ProjectManagerDecoratorTest ()
 
 ~ProjectManagerDecoratorTest ()
 
std::string createEmptyDir (const std::string &subdir) const
 Creates an empty directory in main test folder. More...
 
std::vector< SessionModel * > models () const
 
ProjectContext projectContext ()
 
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...
 
UserInteractionContext userContext (const std::string &create_dir={}, const std::string &select_dir={})
 

Public Attributes

std::unique_ptr< SessionModelsample_model
 

Protected Attributes

std::string m_test_dir
 

Detailed Description

Tests for ProjectManager class.

Definition at line 33 of file projectmanagerdecorator.test.cpp.

Constructor & Destructor Documentation

◆ ProjectManagerDecoratorTest()

ProjectManagerDecoratorTest::ProjectManagerDecoratorTest ( )
inline

Definition at line 35 of file projectmanagerdecorator.test.cpp.

36  : FolderBasedTest("test_ProjectManagerDecorator")
37  , sample_model(std::make_unique<ModelView::SessionModel>(samplemodel_name))
38  {
39  }
FolderBasedTest(const std::string &test_dir)
std::unique_ptr< SessionModel > sample_model

◆ ~ProjectManagerDecoratorTest()

ProjectManagerDecoratorTest::~ProjectManagerDecoratorTest ( )
default

Member Function Documentation

◆ 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*> ProjectManagerDecoratorTest::models ( ) const
inline

Definition at line 42 of file projectmanagerdecorator.test.cpp.

42 { return {sample_model.get()}; };

◆ projectContext()

ProjectContext ProjectManagerDecoratorTest::projectContext ( )
inline

Definition at line 44 of file projectmanagerdecorator.test.cpp.

45  {
46  ProjectContext result;
47  result.m_models_callback = [this]() { return models(); };
48  return result;
49  }
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.

◆ 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:

◆ userContext()

UserInteractionContext ProjectManagerDecoratorTest::userContext ( const std::string &  create_dir = {},
const std::string &  select_dir = {} 
)
inline

Definition at line 51 of file projectmanagerdecorator.test.cpp.

51  {},
52  const std::string& select_dir = {})
53  {
55  result.m_create_dir_callback = [create_dir]() -> std::string { return create_dir; };
56  result.m_select_dir_callback = [select_dir]() -> std::string { return select_dir; };
57  return result;
58  }
Defines the context to interact with the user regarding save/save-as/create-new project scenarious.
Definition: project_types.h:48
select_dir_callback_t m_select_dir_callback
Definition: project_types.h:58
create_dir_callback_t m_create_dir_callback
Definition: project_types.h:59

Member Data Documentation

◆ m_test_dir

std::string FolderBasedTest::m_test_dir
protectedinherited

◆ sample_model

std::unique_ptr<SessionModel> ProjectManagerDecoratorTest::sample_model

Definition at line 60 of file projectmanagerdecorator.test.cpp.


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