-
Notifications
You must be signed in to change notification settings - Fork 3
/
text_serialization_writer_test.go
50 lines (42 loc) · 1.32 KB
/
text_serialization_writer_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package textserialization
import (
"testing"
absser "github.com/microsoft/kiota-abstractions-go/serialization"
assert "github.com/stretchr/testify/assert"
)
func TestItDoesntWriteAnythingForAdditionalData(t *testing.T) {
serializer := NewTextSerializationWriter()
err := serializer.WriteAdditionalData(nil)
assert.NotNil(t, err)
}
func TestSerializationWriterHonoursInterface(t *testing.T) {
instance := NewTextSerializationWriter()
assert.Implements(t, (*absser.SerializationWriter)(nil), instance)
}
func TestTextSerializationWriter(t *testing.T) {
serializer := NewTextSerializationWriter()
countBefore := 0
onBefore := func(parsable absser.Parsable) error {
countBefore++
return nil
}
err := serializer.SetOnBeforeSerialization(onBefore)
assert.NoError(t, err)
assert.NotNil(t, serializer.GetOnBeforeSerialization())
countAfter := 0
onAfter := func(parsable absser.Parsable) error {
countAfter++
return nil
}
err = serializer.SetOnAfterObjectSerialization(onAfter)
assert.NoError(t, err)
assert.NotNil(t, serializer.GetOnAfterObjectSerialization())
countStart := 0
onStart := func(absser.Parsable, absser.SerializationWriter) error {
countStart++
return nil
}
err = serializer.SetOnStartObjectSerialization(onStart)
assert.NoError(t, err)
assert.NotNil(t, serializer.GetOnStartObjectSerialization())
}