-
Notifications
You must be signed in to change notification settings - Fork 3
/
text_parse_node_test.go
45 lines (37 loc) · 1.19 KB
/
text_parse_node_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
package textserialization
import (
testing "testing"
absser "github.com/microsoft/kiota-abstractions-go/serialization"
assert "github.com/stretchr/testify/assert"
)
func TestTree(t *testing.T) {
source := "\"stringValue\""
sourceArray := []byte(source)
parseNode, err := NewTextParseNode(sourceArray)
if err != nil {
t.Errorf("Error creating parse node: %s", err.Error())
}
someProp, err := parseNode.GetChildNode("someProp")
assert.NotNil(t, err)
assert.Nil(t, someProp)
stringValue, err := parseNode.GetStringValue()
assert.Nil(t, err)
assert.NotNil(t, stringValue)
assert.Equal(t, "stringValue", *stringValue)
}
func TestTextParseNodeHonoursInterface(t *testing.T) {
source := "\"stringValue\""
sourceArray := []byte(source)
instance, err := NewTextParseNode(sourceArray)
assert.Nil(t, err)
assert.Implements(t, (*absser.ParseNode)(nil), instance)
action := func(parsable absser.Parsable) error {
return nil
}
err = instance.SetOnBeforeAssignFieldValues(action)
assert.NoError(t, err)
assert.NotNil(t, instance.GetOnBeforeAssignFieldValues())
err = instance.SetOnAfterAssignFieldValues(action)
assert.NoError(t, err)
assert.NotNil(t, instance.GetOnAfterAssignFieldValues())
}