xml
(t *testing.T)
| 108 | |
| 109 | // xml |
| 110 | func TestBinder_Bind_xml(t *testing.T) { |
| 111 | |
| 112 | binder := newBinder() |
| 113 | |
| 114 | if binder == nil { |
| 115 | t.Error("binder can not be nil!") |
| 116 | } |
| 117 | |
| 118 | // init DotServer |
| 119 | app := New() |
| 120 | |
| 121 | if app == nil { |
| 122 | t.Error("app can not be nil!") |
| 123 | } |
| 124 | |
| 125 | // expected |
| 126 | expected := &Person{ |
| 127 | Hair: "Brown", |
| 128 | HasGlass: true, |
| 129 | Age: 10, |
| 130 | Legs: []string{"Left", "Right"}, |
| 131 | } |
| 132 | param := &InitContextParam{ |
| 133 | t, |
| 134 | expected, |
| 135 | "application/xml", |
| 136 | test.ToXML, |
| 137 | } |
| 138 | |
| 139 | // init param |
| 140 | context := initContext(param) |
| 141 | // actual |
| 142 | person := &Person{} |
| 143 | |
| 144 | err := binder.Bind(person, context) |
| 145 | |
| 146 | // check error must nil |
| 147 | test.Nil(t, err) |
| 148 | |
| 149 | // check expected |
| 150 | test.Equal(t, expected, person) |
| 151 | |
| 152 | t.Log("person:", person) |
| 153 | t.Log("expected:", expected) |
| 154 | |
| 155 | } |
| 156 | |
| 157 | // xml |
| 158 | func TestBinder_Bind_xml_error(t *testing.T) { |