Skip to content

Commit

Permalink
Add ZnEntity >> #asString
Browse files Browse the repository at this point in the history
  • Loading branch information
gcotelli committed Sep 28, 2023
1 parent a62dd66 commit 996277d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Class {
#name : #ZnEntityStargateExtensionsTest,
#superclass : #TestCase,
#category : #'Stargate-Model-Tests-Extensions'
}

{ #category : #tests }
ZnEntityStargateExtensionsTest >> testAsString [

self
assert: ( ZnEntity text: 'Regression test' ) asString
equals: 'text/plain;charset=utf-8 Regression test'.

self
assert: ( ZnEntity bytes: #[ 12 13 45 ] ) asString
equals: 'application/octet-stream 3B #[12 13 45]'.

self assert: ( ZnEntity json: '{"test":1}' ) asString equals: 'application/json {"test":1}'.

self
assert: ( ZnEntity xml: '<test><sub></sub></test>' ) asString
equals: 'application/xml <test><sub></sub></test>'
]
7 changes: 7 additions & 0 deletions source/Stargate-Zinc-Extensions/ZnEntity.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Extension { #name : #ZnEntity }

{ #category : #'*Stargate-Zinc-Extensions' }
ZnEntity >> asString [

^ String streamContents: [ :stream | self printContentsOn: stream ]
]

0 comments on commit 996277d

Please sign in to comment.