RegressionTests__CachedValueTest.st
author sr
Tue, 04 Feb 2020 12:27:07 +0100
changeset 2546 c4dbc7a9249b
parent 1447 2351db93aa5b
child 1567 e17701a073f9
permissions -rw-r--r--
#FEATURE by Stefan Reise class: RegressionTests::WebSocketTest removed: #byteArray500 #data500 #testCommunication100WithMasking #testCommunication100WithoutMasking #testCommunication500 #testCommunicationByteArray500 #testMask500 #testMask500Speed category of: #testCommunication100Speed #testMask100Speed #testParallelSocketWrite class: WebSocketTest changed: #testCommunicationFilename #testParallelSocketWrite

"{ Package: 'stx:goodies/regression' }"

"{ NameSpace: RegressionTests }"

TestCase subclass:#CachedValueTest
	instanceVariableNames:'subProcesses'
	classVariableNames:''
	poolDictionaries:''
	category:'tests-Regression'
!


!CachedValueTest methodsFor:'test'!

test01_validityDuration
        |cv didCompute|

        didCompute := false.
        cv := CachedValue compute:[didCompute := true. Date today dayOfWeek] validityDuration:(0.5 seconds).
        self assert:(cv isValid not).
        self assert:(didCompute not).
        self assert:(cv value = Date today dayOfWeek).
        self assert:(cv isValid).
        self assert:(didCompute).

        Delay waitForSeconds:1.
        didCompute := false.
        self assert:(cv isValid not).
        self assert:(didCompute not).
        self assert:(cv value = Date today dayOfWeek).
        self assert:(cv isValid).
        self assert:(didCompute).
!

test02_expirationTime
        |cv exceptionRaised|

        cv := CachedValue value:123 expirationTime:(Timestamp now + 0.5 seconds).
        self assert:(cv isValid).
        Delay waitForSeconds:1.
        self assert:(cv isValid not).

        exceptionRaised := false.
        CachedValue::ValueExpiredException handle:[:ex |
            exceptionRaised := true.
        ] do:[
            cv value
        ].
        self assert:exceptionRaised.
! !

!CachedValueTest class methodsFor:'documentation'!

version
    ^ '$Header$'
!

version_CVS
    ^ '$Header$'
! !