| 1 |
package element |
| 2 |
|
| 3 |
import "testing" |
| 4 |
|
| 5 |
func TestPinTanBusinessTransactionParametersUnmarshalHBCI(t *testing.T) { |
| 6 |
test := "HKSAL:N:HKUEB:J" |
| 7 |
|
| 8 |
param1 := &PinTanBusinessTransactionParameter{ |
| 9 |
SegmentID: NewAlphaNumeric("HKSAL", 6), |
| 10 |
NeedsTAN: NewBoolean(false), |
| 11 |
} |
| 12 |
param1.DataElement = NewGroupDataElementGroup(pinTanBusinessTransactionParameterGDEG, 2, param1) |
| 13 |
param2 := &PinTanBusinessTransactionParameter{ |
| 14 |
SegmentID: NewAlphaNumeric("HKUEB", 6), |
| 15 |
NeedsTAN: NewBoolean(true), |
| 16 |
} |
| 17 |
param2.DataElement = NewGroupDataElementGroup(pinTanBusinessTransactionParameterGDEG, 2, param2) |
| 18 |
expectedElement := &PinTanBusinessTransactionParameters{} |
| 19 |
expectedElement.arrayElementGroup = newArrayElementGroup(pinTanBusinessTransactionParameterGDEG, 2, 2, []DataElement{param1, param2}) |
| 20 |
|
| 21 |
expected := expectedElement.String() |
| 22 |
|
| 23 |
element := &PinTanBusinessTransactionParameters{} |
| 24 |
|
| 25 |
err := element.UnmarshalHBCI([]byte(test)) |
| 26 |
|
| 27 |
if err != nil { |
| 28 |
t.Logf("Expected no error, got %T:%v\n", err, err) |
| 29 |
t.Fail() |
| 30 |
} |
| 31 |
|
| 32 |
actual := element.String() |
| 33 |
|
| 34 |
if actual != expected { |
| 35 |
t.Logf("Expected unmarshaled value to equal\n%q\n\tgot\n%q\n", expected, actual) |
| 36 |
t.Fail() |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
func TestPinTanBusinessTransactionParameterUnmarshalHBCI(t *testing.T) { |
| 41 |
test := "HKSAL:N" |
| 42 |
|
| 43 |
expectedElement := &PinTanBusinessTransactionParameter{ |
| 44 |
SegmentID: NewAlphaNumeric("HKSAL", 6), |
| 45 |
NeedsTAN: NewBoolean(false), |
| 46 |
} |
| 47 |
expectedElement.DataElement = NewGroupDataElementGroup(pinTanBusinessTransactionParameterGDEG, 2, expectedElement) |
| 48 |
|
| 49 |
expected := expectedElement.String() |
| 50 |
|
| 51 |
element := &PinTanBusinessTransactionParameter{} |
| 52 |
|
| 53 |
err := element.UnmarshalHBCI([]byte(test)) |
| 54 |
|
| 55 |
if err != nil { |
| 56 |
t.Logf("Expected no error, got %T:%v\n", err, err) |
| 57 |
t.Fail() |
| 58 |
} |
| 59 |
|
| 60 |
actual := element.String() |
| 61 |
|
| 62 |
if actual != expected { |
| 63 |
t.Logf("Expected unmarshaled value to equal\n%q\n\tgot\n%q\n", expected, actual) |
| 64 |
t.Fail() |
| 65 |
} |
| 66 |
} |