From 630b9f051528d79622580a5341e020f13ce0327d Mon Sep 17 00:00:00 2001 From: MaximilianoTabacman <mtabacman@gmail.com> Date: Fri, 5 Jan 2024 15:48:27 -0300 Subject: [PATCH] Added tests to check behavior when storing repeated elements --- .../RepositoryBasedTest.class.st | 32 +++++++++++++++++++ .../GemStoneRepository.class.st | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/source/Sagan-Core-Tests/RepositoryBasedTest.class.st b/source/Sagan-Core-Tests/RepositoryBasedTest.class.st index 3f1b539..2f94d18 100644 --- a/source/Sagan-Core-Tests/RepositoryBasedTest.class.st +++ b/source/Sagan-Core-Tests/RepositoryBasedTest.class.st @@ -310,6 +310,38 @@ RepositoryBasedTest >> testStore [ else: [ self fail ] ] +{ #category : 'tests - conflict checking' } +RepositoryBasedTest >> testStoreIdentical [ + + | found instance | + + self setUpRepositoryWithNoConflictChecking. + instance := self silvesterStallone. + self extraterrestrials store: instance. + self extraterrestrials store: instance. + + found := self extraterrestrials findAll. + self assert: found size equals: 2. + self assert: ( found allSatisfy: [ :extraterrestrial | + extraterrestrial firstName = 'Silvester' and: [ extraterrestrial lastName = 'Stallone' ] ] ) +] + +{ #category : 'tests - conflict checking' } +RepositoryBasedTest >> testStoreRepeated [ + + | found | + + self setUpRepositoryWithNoConflictChecking. + + self extraterrestrials store: self silvesterStallone. + self extraterrestrials store: self silvesterStallone. + + found := self extraterrestrials findAll. + self assert: found size equals: 2. + self assert: ( found allSatisfy: [ :extraterrestrial | + extraterrestrial firstName = 'Silvester' and: [ extraterrestrial lastName = 'Stallone' ] ] ) +] + { #category : 'tests - conflict checking' } RepositoryBasedTest >> testStoreWithConflict [ diff --git a/source/Sagan-GemStone/GemStoneRepository.class.st b/source/Sagan-GemStone/GemStoneRepository.class.st index c304bc7..bb369b1 100644 --- a/source/Sagan-GemStone/GemStoneRepository.class.st +++ b/source/Sagan-GemStone/GemStoneRepository.class.st @@ -66,7 +66,7 @@ GemStoneRepository >> findAllMatching: aCriteriaOrBlock sortedBy: aSortFunction GemStoneRepository >> initializeCheckingConflictsAccordingTo: aConflictCheckingStrategy [ conflictCheckingStrategy := aConflictCheckingStrategy. - contents := Bag new + contents := Set new ] { #category : 'private - accessing' }