Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Dario Ocles
ing1-2018-1c
Commits
02361a36
Commit
02361a36
authored
6 years ago
by
istng
Browse files
Options
Download
Email Patches
Plain Diff
tuslibros con carrito andando
parent
9151f7f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
129 additions
and
40 deletions
+129
-40
09-TusLibros.com/TusLibros.st
09-TusLibros.com/TusLibros.st
+129
-40
No files found.
09-TusLibros.com/TusLibros.st
View file @
02361a36
...
...
@@ -5,79 +5,168 @@ TestCase subclass: #CartTest
poolDictionaries:
''
category:
'TusLibros'
!
!
CartTest
methodsFor:
'as yet unclassified'
stamp:
'ig 6/
4
/2018
21:28:06
'
!
test01Created
New
CartIsEmpty
!
CartTest
methodsFor:
'as yet unclassified'
stamp:
'ig 6/
6
/2018
17:01:40
'
!
test01
New
CreatedCartIsEmpty
|
cart
|
|
cart
market catalog
|
cart
:=
Cart
new
.
catalog
:=
Catalog
new
.
market
:=
Market
with:
catalog
.
cart
:=
Cart
with:
market
.
self
assert:
cart
isEmpty
.
! !
!
CartTest
methodsFor:
'as yet unclassified'
stamp:
'ig 6/
4
/2018
21:45:32
'
!
test02Adding
ABook
ToACart
!
CartTest
methodsFor:
'as yet unclassified'
stamp:
'ig 6/
6
/2018
17:02:14
'
!
test02Adding
OneProduct
ToACart
|
cart
isbn quantity cosa
|
|
cart
market catalog product
|
cart
:=
Cart
new
.
isbn
:=
'123123'
.
quantity
:=
'2'
.
product
:=
Object
new
.
catalog
:=
Catalog
new
.
catalog
add:
product
.
market
:=
Market
with:
catalog
.
cart
:=
Cart
with:
market
.
cart
add:
quantity
of:
isbn
.
cart
add:
product
.
cosa
:=
(
Pair
with:
isbn
with:
quantity
).
self
deny:
cart
isEmpty
.
self
assert:
((
cart
books
)
at:
1
)
=
cosa
.
! !
self
assert:
((
cart
products
)
includesKey:
product
)
.
! !
!
CartTest
methodsFor:
'as yet unclassified'
stamp:
'ig 6/
4
/2018
21:42:29
'
!
test03
ListingCartListsAddedBooks
!
CartTest
methodsFor:
'as yet unclassified'
stamp:
'ig 6/
6
/2018
17:02:38
'
!
test03
AddingMoreOfTheSameProductToACart
|
cart
isbn quantity
|
|
cart
market catalog product
|
cart
:=
Cart
new
.
isbn
:=
'123123'
.
quantity
:=
'2'
.
product
:=
Object
new
.
catalog
:=
Catalog
new
.
catalog
add:
product
.
market
:=
Market
with:
catalog
.
cart
:=
Cart
with:
market
.
cart
add:
product
quantity:
4
.
cart
add:
quantity
of:
isbn
.
self
deny:
cart
isEmpty
.
self
assert:
((
cart
products
)
includesKey:
product
).
self
assert:
(((
cart
products
)
at:
product
)
=
4
)
! !
!
CartTest
methodsFor:
'as yet unclassified'
stamp:
'ig 6/6/2018 17:03:12'
!
test04CheckingProductIsInCatalog
|
cart market catalog product
|
self
assert:
cart
list
=
'0|123123|2'
product
:=
Object
new
.
catalog
:=
Catalog
new
.
market
:=
Market
with:
catalog
.
cart
:=
Cart
with:
market
.
! !
self
should:
[
cart
add:
product
]
raise:
Error
-
MessageNotUnderstood
withExceptionDo:
[
:
anError
|
self
assert:
Cart
canNotAddProductOustideTheCatalog
equals:
anError
messageText
.
].
! !
!
classDefinition:
#Cart
category:
#TusLibros
!
Object
subclass:
#Cart
instanceVariableNames:
'
books
'
instanceVariableNames:
'
products market
'
classVariableNames:
''
poolDictionaries:
''
category:
'TusLibros'
!
!
Cart
methodsFor:
'as yet unclassified'
stamp:
'ig 6/
4
/2018
21:35:47
'
!
add:
a
Quantity
of:
anIsbn
!
Cart
methodsFor:
'as yet unclassified'
stamp:
'ig 6/
6
/2018
16:58:59
'
!
add:
a
Product
books
add:
(
Pair
with:
anIsbn
with:
aQuantity
).
! !
(
market
has:
aProduct
)
ifFalse:
[
self
error:
(
self
class
canNotAddProductOustideTheCatalog
)].
products
add:
aProduct
->
1
.
! !
!
Cart
methodsFor:
'as yet unclassified'
stamp:
'ig 6/
4
/2018
21:20
:0
7
'
!
books
!
Cart
methodsFor:
'as yet unclassified'
stamp:
'ig 6/
6
/2018
16:59
:0
3
'
!
add:
aProduct
quantity:
aQuantity
^
books
! !
(
market
has:
aProduct
)
ifFalse:
[
self
error:
(
self
class
canNotAddProductOustideTheCatalog
)].
products
add:
aProduct
->
aQuantity
.
! !
!
Cart
methodsFor:
'as yet unclassified'
stamp:
'ig 6/
4
/2018
21:19:06
'
!
initialize
!
Cart
methodsFor:
'as yet unclassified'
stamp:
'ig 6/
6
/2018
17:00:23
'
!
initialize
With:
aMarket
books
:=
OrderedCollection
new
.
! !
products
:=
Dictionary
new
.
market
:=
aMarket
.
! !
!
Cart
methodsFor:
'as yet unclassified'
stamp:
'ig 6/
4
/2018
21:19:13
'
!
!
Cart
methodsFor:
'as yet unclassified'
stamp:
'ig 6/
6
/2018
15:50:01
'
!
isEmpty
^
books
isEmpty
! !
^
(
products
hasContentsInExplorer
)
not
! !
!
Cart
methodsFor:
'as yet unclassified'
stamp:
'ig 6/6/2018 15:53:59'
!
products
^
products
copy
! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "
!
!
classDefinition:
'Cart class'
category:
#TusLibros
!
Cart
class
instanceVariableNames:
''
!
!
Cart
class
methodsFor:
'as yet unclassified'
stamp:
'ig 6/6/2018 16:07:26'
!
canNotAddProductOustideTheCatalog
^
'No se puede agregar un producto que no pertenece al catalogo'
! !
!
Cart
class
methodsFor:
'as yet unclassified'
stamp:
'ig 6/6/2018 17:00:35'
!
with:
aMarket
^
self
new
initializeWith:
aMarket
! !
!
classDefinition:
#Catalog
category:
#TusLibros
!
Object
subclass:
#Catalog
instanceVariableNames:
'products'
classVariableNames:
''
poolDictionaries:
''
category:
'TusLibros'
!
!
Catalog
methodsFor:
'as yet unclassified'
stamp:
'ig 6/6/2018 16:36:23'
!
add:
aProduct
!
Cart
methodsFor:
'as yet unclassified'
stamp:
'ig 6/4/2018 21:42:06'
!
list
products
add:
aProduct
.
! !
!
Catalog
methodsFor:
'as yet unclassified'
stamp:
'ig 6/6/2018 16:46:05'
!
has:
aProduct
^
products
includes:
aProduct
! !
|
list
|
!
Catalog
methodsFor:
'as yet unclassified'
stamp:
'ig 6/6/2018 16:36:09'
!
initialize
products
:=
Set
new
.
! !
!
classDefinition:
#Market
category:
#TusLibros
!
Object
subclass:
#Market
instanceVariableNames:
'catalog'
classVariableNames:
''
poolDictionaries:
''
category:
'TusLibros'
!
list
:=
'0'
.
books
do:
[
:
book
|
list
,
'|'
,
(
book
first
asString
)
,
'|'
,
(
book
second
asString
)].
!
Market
methodsFor:
'as yet unclassified'
stamp:
'ig 6/6/2018 16:59:18'
!
has:
aProduct
^
list
! !
^
catalog
has:
aProduct
! !
!
Market
methodsFor:
'as yet unclassified'
stamp:
'ig 6/6/2018 16:59:39'
!
initializeWith:
aCatalog
catalog
:=
aCatalog
! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "
!
!
classDefinition:
'Market class'
category:
#TusLibros
!
Market
class
instanceVariableNames:
''
!
!
Market
class
methodsFor:
'as yet unclassified'
stamp:
'ig 6/6/2018 16:59:58'
!
with:
aCatalog
^
self
new
initializeWith:
aCatalog
! !
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment