File: bank_parameter_data_test.go

package info (click to toggle)
golang-github-mitch000001-go-hbci 0.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,468 kB
  • sloc: java: 1,092; makefile: 5
file content (66 lines) | stat: -rw-r--r-- 1,869 bytes parent folder | download | duplicates (2)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package element

import "testing"

func TestPinTanBusinessTransactionParametersUnmarshalHBCI(t *testing.T) {
	test := "HKSAL:N:HKUEB:J"

	param1 := &PinTanBusinessTransactionParameter{
		SegmentID: NewAlphaNumeric("HKSAL", 6),
		NeedsTAN:  NewBoolean(false),
	}
	param1.DataElement = NewGroupDataElementGroup(pinTanBusinessTransactionParameterGDEG, 2, param1)
	param2 := &PinTanBusinessTransactionParameter{
		SegmentID: NewAlphaNumeric("HKUEB", 6),
		NeedsTAN:  NewBoolean(true),
	}
	param2.DataElement = NewGroupDataElementGroup(pinTanBusinessTransactionParameterGDEG, 2, param2)
	expectedElement := &PinTanBusinessTransactionParameters{}
	expectedElement.arrayElementGroup = newArrayElementGroup(pinTanBusinessTransactionParameterGDEG, 2, 2, []DataElement{param1, param2})

	expected := expectedElement.String()

	element := &PinTanBusinessTransactionParameters{}

	err := element.UnmarshalHBCI([]byte(test))

	if err != nil {
		t.Logf("Expected no error, got %T:%v\n", err, err)
		t.Fail()
	}

	actual := element.String()

	if actual != expected {
		t.Logf("Expected unmarshaled value to equal\n%q\n\tgot\n%q\n", expected, actual)
		t.Fail()
	}
}

func TestPinTanBusinessTransactionParameterUnmarshalHBCI(t *testing.T) {
	test := "HKSAL:N"

	expectedElement := &PinTanBusinessTransactionParameter{
		SegmentID: NewAlphaNumeric("HKSAL", 6),
		NeedsTAN:  NewBoolean(false),
	}
	expectedElement.DataElement = NewGroupDataElementGroup(pinTanBusinessTransactionParameterGDEG, 2, expectedElement)

	expected := expectedElement.String()

	element := &PinTanBusinessTransactionParameter{}

	err := element.UnmarshalHBCI([]byte(test))

	if err != nil {
		t.Logf("Expected no error, got %T:%v\n", err, err)
		t.Fail()
	}

	actual := element.String()

	if actual != expected {
		t.Logf("Expected unmarshaled value to equal\n%q\n\tgot\n%q\n", expected, actual)
		t.Fail()
	}
}