| 1 |
package element |
| 2 |
|
| 3 |
import ( |
| 4 |
"testing" |
| 5 |
|
| 6 |
"github.com/mitch000001/go-hbci/domain" |
| 7 |
) |
| 8 |
|
| 9 |
func TestAcknowledgementDataElementUnmarshalHBCI(t *testing.T) { |
| 10 |
test := "0300:7,2:Syntaxerror:test1" |
| 11 |
|
| 12 |
acknowledgement := &AcknowledgementDataElement{} |
| 13 |
|
| 14 |
err := acknowledgement.UnmarshalHBCI([]byte(test)) |
| 15 |
|
| 16 |
if err != nil { |
| 17 |
t.Logf("Expected no error, got %T:%v\n", err, err) |
| 18 |
t.Fail() |
| 19 |
} |
| 20 |
|
| 21 |
expected := NewAcknowledgement(domain.NewMessageAcknowledgement(300, "7,2", "Syntaxerror", []string{"test1"})).String() |
| 22 |
actual := acknowledgement.String() |
| 23 |
|
| 24 |
if expected != actual { |
| 25 |
t.Logf("Expected\n%q\n\tgot\n%q\n", expected, actual) |
| 26 |
t.Fail() |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
func TestParamsDataElementUnmarshalHBCI(t *testing.T) { |
| 31 |
test := "test1:test2:test3" |
| 32 |
|
| 33 |
params := &ParamsDataElement{} |
| 34 |
|
| 35 |
err := params.UnmarshalHBCI([]byte(test)) |
| 36 |
|
| 37 |
if err != nil { |
| 38 |
t.Logf("Expected no error, got %T:%v\n", err, err) |
| 39 |
t.Fail() |
| 40 |
} |
| 41 |
|
| 42 |
expected := NewParams(10, 10, "test1", "test2", "test3").String() |
| 43 |
actual := params.String() |
| 44 |
|
| 45 |
if expected != actual { |
| 46 |
t.Logf("Expected\n%q\n\tgot\n%q\n", expected, actual) |
| 47 |
t.Fail() |
| 48 |
} |
| 49 |
} |