@@ -24,6 +24,59 @@ FM3ClassTest >> testAllProperties [
2424 self denyEmpty: element allProperties
2525]
2626
27+ { #category : ' tests' }
28+ FM3ClassTest >> testAllPropertiesDoGiveSameElementsAsAllProperties [
29+
30+ | superclass class listWithPropDo listWithoutPropDo |
31+ superclass := self actualClass named: ' Superclass' .
32+ class := self actualClass named: ' Class' .
33+ class superclass: superclass.
34+
35+ superclass properties: {
36+ (FM3Property named: #isDead ).
37+ (FM3Property named: #numberOfLinesOfCode ) }.
38+ class properties: {
39+ (FM3Property named: #isDead ).
40+ (FM3Property named: #cc ) }.
41+
42+ " collecting with allPropertiesDo:"
43+ listWithPropDo := OrderedCollection new .
44+ class allPropertiesDo: [ :prop | listWithPropDo add: prop name ].
45+
46+ " collecting with allProperties"
47+ listWithoutPropDo := class allProperties collect: [ :prop |
48+ prop name ].
49+
50+ " the two lists should be equals"
51+ self
52+ assert: listWithPropDo asArray sorted equals: listWithoutPropDo asArray sorted
53+ ]
54+
55+ { #category : ' tests' }
56+ FM3ClassTest >> testAllPropertiesHasNoDuplication [
57+
58+ | superclass class numberOfProperties expectedNumberOfProperties |
59+ superclass := self actualClass named: ' Superclass' .
60+ class := self actualClass named: ' Class' .
61+ class superclass: superclass.
62+
63+ superclass properties: {
64+ (FM3Property named: #isDead ).
65+ (FM3Property named: #numberOfLinesOfCode ) }.
66+ class properties: {
67+ (FM3Property named: #isDead ).
68+ (FM3Property named: #cc ) }.
69+
70+ numberOfProperties := 0 .
71+ class allPropertiesDo: [ :each |
72+ numberOfProperties := numberOfProperties + 1 ].
73+
74+ expectedNumberOfProperties := class allProperties size.
75+
76+ self assert: numberOfProperties equals: expectedNumberOfProperties.
77+ self assert: numberOfProperties equals: 3
78+ ]
79+
2780{ #category : ' tests' }
2881FM3ClassTest >> testAllPropertiesMoreThanProperties [
2982 element := metaMetamodel elementNamed: ' FM3.Class' .
0 commit comments