TestCase subclass: #PruebasClub instanceVariableNames: 'club' classVariableNames: '' package: 'tp0.5-test'! !PruebasClub commentStamp: 'tomas 4/25/2020 11:52' prior: 0! Pruebas unitarias del Club Social y Deportivo Orientado a Objetos! !PruebasClub methodsFor: 'tests' stamp: 'tomas 4/25/2020 11:41'! test02SeAgreganDosSociosAlClubYSeDevuelveElConjuntoDeSusNombres " Arrange " | socio1 socio2 nombresSocios | socio1 := Socio new. socio1 establecerNombre: 'Carlos'. club agregarSocio: socio1. socio2 := Socio new. socio2 establecerNombre: 'Marcio'. club agregarSocioVIP: socio2. " Act " nombresSocios := club nombresSocios. " Assert " self assertCollection: nombresSocios equals: (Set withAll: #('Marcio' 'Carlos'))! ! !PruebasClub methodsFor: 'tests' stamp: 'tomas 4/25/2020 11:41'! test05SeAgreganTresSociosAlClubYLaCantidadDeSociosEsTres " Arrange " | socio1 socio2 socio3 cantidadDeSocios | socio1 := Socio new. socio1 establecerNombre: 'Carlos'. club agregarSocio: socio1. socio2 := Socio new. socio2 establecerNombre: 'Marcio'. club agregarSocioVIP: socio2. socio3 := Socio new. socio3 establecerNombre: 'Pablo'. club agregarSocio: socio3. " Act " cantidadDeSocios := club cantidadDeSocios. " Assert " self assert: cantidadDeSocios equals: 3! ! !PruebasClub methodsFor: 'tests' stamp: 'tomas 4/25/2020 11:41'! test04SeAgregaUnSocioComunYOtroVipYRealizanUnPagoCadaUnoYLaRecaudacionTotalEs1200 " Arrange " | socio1 socio2 recaudacionTotal | socio1 := Socio new. socio1 establecerNombre: 'Carlos'. club agregarSocio: socio1. socio2 := Socio new. socio2 establecerNombre: 'Marcio'. club agregarSocioVIP: socio2. club recibirPagoDe: 'Carlos'. club recibirPagoDe: 'Marcio'. " Act " recaudacionTotal := club recaudacionTotal. " Assert " self assert: recaudacionTotal equals: 1200! ! !PruebasClub methodsFor: 'tests' stamp: 'tomas 4/25/2020 11:44'! test09SeAgreganDosSociosComunesYOtroVipYRealizanSietePagosComunYLaCantidadPagadaPorElSocioVipEs2800 " Arrange " | socio1 socio2 socio3 cantidadPagada | socio1 := Socio new. socio1 establecerNombre: 'Carlos'. socio2 := Socio new. socio2 establecerNombre: 'Marcio'. socio3 := Socio new. socio3 establecerNombre: 'Pablo'. club agregarSocio: socio1; agregarSocioVIP: socio2; agregarSocio: socio3. 4 timesRepeat: [ club recibirPagoDe: 'Carlos'. " 500 " club recibirPagoDe: 'Marcio'. " 700 " ]. 3 timesRepeat: [ club recibirPagoDe: 'Pablo'. " 500 " ]. " Act " cantidadPagada := club cantidadPagadaPor: 'Marcio'. " Assert " self assert: cantidadPagada equals: 2800! ! !PruebasClub methodsFor: 'tests' stamp: 'tomas 4/25/2020 11:41'! test07SeAgreganDosSociosComunesYOtroVipYRealizanTresPagosCadaUnoYLaRecaudacionTotalEs5100 " Arrange " | socio1 socio2 socio3 recaudacionTotal | socio1 := Socio new. socio1 establecerNombre: 'Carlos'. socio2 := Socio new. socio2 establecerNombre: 'Marcio'. socio3 := Socio new. socio3 establecerNombre: 'Pablo'. club agregarSocio: socio1; agregarSocioVIP: socio2; agregarSocio: socio3. 3 timesRepeat: [ club recibirPagoDe: 'Pablo'. " 500 " club recibirPagoDe: 'Carlos'. " 500 " club recibirPagoDe: 'Marcio'. " 700 " ]. " Act " recaudacionTotal := club recaudacionTotal. " Assert " self assert: recaudacionTotal equals: 5100! ! !PruebasClub methodsFor: 'tests' stamp: 'tomas 4/25/2020 11:31'! test06SeAgreganTresSociosAlClubYSeDevuelveElConjuntoDeSusNombres " Arrange " | socio1 socio2 socio3 nombresSocios | socio1 := Socio new. socio1 establecerNombre: 'Carlos'. club agregarSocio: socio1. socio2 := Socio new. socio2 establecerNombre: 'Marcio'. club agregarSocioVIP: socio2. socio3 := Socio new. socio3 establecerNombre: 'Pablo'. club agregarSocio: socio3. " Act " nombresSocios := club nombresSocios. " Assert " self assertCollection: nombresSocios equals: (Set withAll: #('Marcio' 'Carlos' 'Pablo'))! ! !PruebasClub methodsFor: 'tests' stamp: 'tomas 4/25/2020 11:22'! test01LaRecaudacionInicialDelClubDebeSerCero " Arrange " | recaudacion | " Act " recaudacion := club recaudacionTotal. " Assert " self assert: recaudacion equals: 0! ! !PruebasClub methodsFor: 'tests' stamp: 'tomas 4/25/2020 11:40'! test08SeAgreganDosSociosComunesYOtroVipYRealizanSietePagosComunYCuatroVipYLaRecaudacionEs6300 " Arrange " | socio1 socio2 socio3 recaudacionTotal | socio1 := Socio new. socio1 establecerNombre: 'Carlos'. socio2 := Socio new. socio2 establecerNombre: 'Marcio'. socio3 := Socio new. socio3 establecerNombre: 'Pablo'. club agregarSocio: socio1; agregarSocioVIP: socio2; agregarSocio: socio3. club recibirPagoDe: 'Carlos'. " 500 " club recibirPagoDe: 'Marcio'. " 700 " 3 timesRepeat: [ club recibirPagoDe: 'Pablo'. " 500 " club recibirPagoDe: 'Carlos'. " 500 " club recibirPagoDe: 'Marcio'. " 700 " ]. " Act " recaudacionTotal := club recaudacionTotal. " Assert " self assert: recaudacionTotal equals: 6300! ! !PruebasClub methodsFor: 'tests' stamp: 'tomas 4/25/2020 11:46'! test10SeAgreganDosSociosComunesYOtroVipYRealizanSietePagosComunYLaCantidadPagadaPorElPrimerSocioComunEs2000 " Arrange " | socio1 socio2 socio3 cantidadPagada | socio1 := Socio new. socio1 establecerNombre: 'Carlos'. socio2 := Socio new. socio2 establecerNombre: 'Marcio'. socio3 := Socio new. socio3 establecerNombre: 'Pablo'. club agregarSocio: socio1; agregarSocioVIP: socio2; agregarSocio: socio3. 4 timesRepeat: [ club recibirPagoDe: 'Carlos'. " 500 " club recibirPagoDe: 'Marcio'. " 700 " ]. 3 timesRepeat: [ club recibirPagoDe: 'Pablo'. " 500 " ]. " Act " cantidadPagada := club cantidadPagadaPor: 'Carlos'. " Assert " self assert: cantidadPagada equals: 2000! ! !PruebasClub methodsFor: 'tests' stamp: 'tomas 4/25/2020 11:41'! test03SeAgreganDosSociosAlClubYLaCantidadDeSociosEsDos " Arrange " | socio1 socio2 cantidadDeSocios | socio1 := Socio new. socio1 establecerNombre: 'Carlos'. club agregarSocio: socio1. socio2 := Socio new. socio2 establecerNombre: 'Marcio'. club agregarSocioVIP: socio2. " Act " cantidadDeSocios := club cantidadDeSocios. " Assert " self assert: cantidadDeSocios equals: 2! ! !PruebasClub methodsFor: 'tests' stamp: 'tomas 4/25/2020 11:47'! test11SeAgreganDosSociosComunesYOtroVipYRealizanSietePagosComunYLaCantidadPagadaPorElSegundoSocioComunEs1500 " Arrange " | socio1 socio2 socio3 cantidadPagada | socio1 := Socio new. socio1 establecerNombre: 'Carlos'. socio2 := Socio new. socio2 establecerNombre: 'Marcio'. socio3 := Socio new. socio3 establecerNombre: 'Pablo'. club agregarSocio: socio1; agregarSocioVIP: socio2; agregarSocio: socio3. 4 timesRepeat: [ club recibirPagoDe: 'Carlos'. " 500 " club recibirPagoDe: 'Marcio'. " 700 " ]. 3 timesRepeat: [ club recibirPagoDe: 'Pablo'. " 500 " ]. " Act " cantidadPagada := club cantidadPagadaPor: 'Pablo'. " Assert " self assert: cantidadPagada equals: 1500! ! !PruebasClub methodsFor: 'running' stamp: 'tomas 4/25/2020 11:22'! setUp club := Club new. club establecerNombre: 'Club Social y Deportivo Orientado a Objetos'. club establecerTarifaSocio: 500. club establecerTarifaSocioVIP: 700.! ! TestCase subclass: #PruebasSocio instanceVariableNames: '' classVariableNames: '' package: 'tp0.5-test'! !PruebasSocio methodsFor: 'tests' stamp: 'Joaquin 4/30/2020 12:24'! test04CreoUnSocioPaga5VecesLaCantidadQuePagoDebeSerDistintaDeCero " Arrange " | cantidadPagada persona| persona := Socio new. persona establecerTarifaAPagar: 500. " Act " 5 timesRepeat: [ persona pagar. " 500 " ]. cantidadPagada := persona cantidadQuePago. " Assert " self deny: cantidadPagada equals: 0. ! ! !PruebasSocio methodsFor: 'tests' stamp: 'Joaquin 4/30/2020 12:16'! test02CreoUnSocioPaga5VecesDeberiaDevolver2500 " Arrange " | cantidadPagada persona| persona := Socio new. persona establecerTarifaAPagar: 500. " Act " 5 timesRepeat: [ persona pagar. " 500 " ]. cantidadPagada := persona cantidadQuePago. " Assert " self assert: cantidadPagada equals: 2500 ! ! !PruebasSocio methodsFor: 'tests' stamp: 'Joaquin 4/30/2020 12:19'! test03CreoUnSocioLeAsignoUnNombreYDespuesSeLoPido " Arrange " | nombre persona| persona := Socio new. persona establecerNombre: 'Juan'. " Act " nombre := persona obtenerNombre. " Assert " self assert: nombre equals: 'Juan'! ! !PruebasSocio methodsFor: 'tests' stamp: 'Joaquin 4/30/2020 12:16'! test01CreoUnSocioNoDeberiaHaberPagadoNada " Arrange " | cantidadPagada persona| persona := Socio new. persona establecerTarifaAPagar: 500. " Act " 5 timesRepeat: [ persona pagar. " 500 " ]. cantidadPagada := persona cantidadQuePago. " Assert " self assert: cantidadPagada equals: 2500 ! ! Object subclass: #Club instanceVariableNames: 'nombre tarifaSocio tarifaSocioVIP recaudacionTotal socios' classVariableNames: '' package: 'tp0.5'! !Club methodsFor: 'as yet unclassified' stamp: 'Joaquin 4/30/2020 11:49'! recibirPagoDe: unNombre |socioBuscado| socioBuscado := self buscarSocio: unNombre. recaudacionTotal := recaudacionTotal + (socioBuscado pagar).! ! !Club methodsFor: 'as yet unclassified' stamp: 'Joaquin 4/30/2020 11:16'! nombresSocios |nombres| nombres := socios collect: [ :socio | socio obtenerNombre ]. ^nombres.! ! !Club methodsFor: 'as yet unclassified' stamp: 'Joaquin 4/30/2020 11:43'! buscarSocio: unNombre. ^socios detect: [:socio | socio obtenerNombre == unNombre ]. ! ! !Club methodsFor: 'as yet unclassified' stamp: 'Joaquin 4/30/2020 10:05'! establecerNombre: unNombre nombre := unNombre .! ! !Club methodsFor: 'as yet unclassified' stamp: 'Joaquin 4/30/2020 10:07'! establecerTarifaSocio: unaTarifa tarifaSocio := unaTarifa. ! ! !Club methodsFor: 'as yet unclassified' stamp: 'Joaquin 4/30/2020 11:54'! agregarSocioVIP: unSocio unSocio establecerTarifaAPagar: tarifaSocioVIP. socios add: unSocio.! ! !Club methodsFor: 'as yet unclassified' stamp: 'Joaquin 4/30/2020 10:56'! cantidadDeSocios ^socios size.! ! !Club methodsFor: 'as yet unclassified' stamp: 'Joaquin 4/30/2020 10:07'! establecerTarifaSocioVIP: unaTarifa tarifaSocioVIP := unaTarifa. ! ! !Club methodsFor: 'as yet unclassified' stamp: 'Joaquin 4/30/2020 11:50'! cantidadPagadaPor: unNombre |socioBuscado| socioBuscado := self buscarSocio: unNombre. ^socioBuscado cantidadQuePago.! ! !Club methodsFor: 'as yet unclassified' stamp: 'Joaquin 4/30/2020 11:54'! agregarSocio: unSocio unSocio establecerTarifaAPagar: tarifaSocio. socios add: unSocio . ! ! !Club methodsFor: 'accessing' stamp: 'Joaquin 4/30/2020 10:08'! recaudacionTotal ^recaudacionTotal.! ! !Club methodsFor: 'accessing' stamp: 'Joaquin 4/30/2020 11:40'! initialize recaudacionTotal := 0. socios := Set new. ! ! Object subclass: #Socio instanceVariableNames: 'nombre tarifaAPagar cantidadPagada' classVariableNames: '' package: 'tp0.5'! !Socio methodsFor: 'as yet unclassified' stamp: 'Joaquin 4/30/2020 11:45'! pagar cantidadPagada := cantidadPagada + tarifaAPagar. ^tarifaAPagar .! ! !Socio methodsFor: 'as yet unclassified' stamp: 'Joaquin 4/30/2020 11:50'! cantidadQuePago ^cantidadPagada.! ! !Socio methodsFor: 'as yet unclassified' stamp: 'Joaquin 4/30/2020 10:10'! establecerNombre: unNombre nombre := unNombre .! ! !Socio methodsFor: 'as yet unclassified' stamp: 'Joaquin 4/30/2020 10:15'! establecerTarifaAPagar: unaTarifa tarifaAPagar := unaTarifa.! ! !Socio methodsFor: 'as yet unclassified' stamp: 'Joaquin 4/30/2020 11:16'! obtenerNombre ^nombre.! ! !Socio methodsFor: 'initialization' stamp: 'Joaquin 4/30/2020 11:41'! initialize cantidadPagada := 0.! !