Created
August 8, 2012 22:41
-
-
Save jasonaden/3299489 to your computer and use it in GitHub Desktop.
Testing of toSerializable method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <cfscript> | |
| component accessors="true" extends="Base" { | |
| property string name; | |
| property State state; | |
| } | |
| </cfscript> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <cfscript> | |
| component accessors="true" extends="Base" { | |
| property string name; | |
| } | |
| </cfscript> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <cfscript> | |
| component accessors="true" extends="Base" { | |
| property string name; | |
| property StudySite studySite; | |
| } | |
| </cfscript> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <cfscript> | |
| component accessors="true" extends="Base" { | |
| property string name; | |
| } | |
| </cfscript> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <cfscript> | |
| component accessors="true" extends="Base" { | |
| property string name; | |
| property array studyEvents; | |
| property Site site; | |
| } | |
| </cfscript> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <cfscript> | |
| component extends="mxunit.framework.TestCase" { | |
| function testSerialize() { | |
| // Create the data structure to test | |
| var study = new Study({ | |
| name = 'New Study' | |
| }); | |
| // Create the StudySite with site and state | |
| var studySite = new StudySite({ | |
| name = 'New Study Site', | |
| site = new Site({name = 'New Site', state = new State({name = 'VA'})}) | |
| }); | |
| study.setStudySite(studySite); | |
| // Create an array of Study Events and assign to the StudySite | |
| var aStudyEvents = []; | |
| for(var i = 1 ; i <= 12 ; i++) { | |
| arrayAppend(aStudyEvents, new StudyEvent(name = 'New StudyEvent #i#')); | |
| } | |
| studySite.setStudyEvents(aStudyEvents); | |
| var serializableStruct = study.toSerializable({depth=3}); | |
| debug(serializableStruct); | |
| var serializedWithIncludes = study.includePath('study.studySite.studyEvents') | |
| .includePath('study.studySite.site.state') | |
| .toSerializable(); | |
| debug(serializedWithIncludes); | |
| } | |
| } | |
| </cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment