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