Salome HOME
Merge multi-study removal branch.
[modules/kernel.git] / src / SALOMEDS / Test / SALOMEDSTest_AttributeStudyProperties.cxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 /*!
24  * Check all methods of SALOMEDS_AttributeStudyProperties
25  * Use code of SALOMEDS_AttributeStudyProperties.cxx
26  */
27 void SALOMEDSTest::testAttributeStudyProperties()
28 {
29   //Create Study
30   _PTR(Study) study(new SALOMEDS_Study(_study));
31
32   CPPUNIT_ASSERT(study);
33
34   //Create Study Builder
35   _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
36
37   CPPUNIT_ASSERT(studyBuilder);
38
39   //Create a SObject with entry 0:1:1
40   _PTR(SObject) so = study->CreateObjectID("0:1:1");
41
42   CPPUNIT_ASSERT(so);
43
44   //Create an attribute AttributeStudyProperties
45   _PTR(AttributeStudyProperties) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeStudyProperties");
46
47   //Check the attribute creation
48   CPPUNIT_ASSERT(_attr);
49
50   //Check method SetCreationDate
51   _attr->SetCreationDate(1, 2, 3, 4, 5);
52
53   //Check method GetCreationDate
54   int MN, H, D, MH, Y;
55   _attr->GetCreationDate(MN, H, D, MH, Y);
56
57   CPPUNIT_ASSERT(MN == 1 && H == 2 && D == 3 && MH == 4 && Y == 5);
58
59   //Check method SetUserName
60   _attr->SetUserName("srn");
61
62   //Check method GetUserName
63   CPPUNIT_ASSERT(_attr->GetUserName() == "srn");
64
65   //Check method SetCreationMode
66   std::string value = "from scratch";
67   _attr->SetCreationMode(value);
68
69   //Check method GetCreationMode
70   CPPUNIT_ASSERT(_attr->GetCreationMode() == value);
71
72   //Check method SetModified
73   _attr->SetModified(2);
74
75   //Check method IsModified
76   CPPUNIT_ASSERT(_attr->IsModified());
77
78   //Check method GetModified
79   CPPUNIT_ASSERT(_attr->GetModified() == 2);
80
81   //Check method SetLocked
82   _attr->SetLocked(true);
83
84   //Check method IsLocked
85   CPPUNIT_ASSERT(_attr->IsLocked());
86
87   _attr->SetLocked(false);
88
89   CPPUNIT_ASSERT(!_attr->IsLocked());
90
91   //Check method SetModification
92   _attr->SetModification("srn2", 6, 7, 8, 9, 10);
93
94   //Check method GetModificationsList
95   std::vector<std::string> vs;
96   std::vector<int> vi[5];
97   _attr->GetModificationsList(vs, vi[0], vi[1], vi[2], vi[3], vi[4], false);
98   CPPUNIT_ASSERT(vs[0] == "srn2" && vi[0][0] == 6 && vi[1][0] == 7 && vi[2][0] == 8 && vi[3][0] == 9 && vi[4][0] == 10);
99
100   vs.clear();
101   for(int i=0; i<5; i++) vi[i].clear();
102
103   _attr->GetModificationsList(vs, vi[0], vi[1], vi[2], vi[3], vi[4], true);
104   CPPUNIT_ASSERT(vs[0] == "srn" && vi[0][0] == 1 && vi[1][0] == 2 && vi[2][0] == 3 && vi[3][0] == 4 && vi[4][0] == 5);
105
106   study->Clear();
107 }
108
109
110