Debian Codegraph @

segment/basic_account_information_test.go

raw
1 package segment
2
3 import (
4 "reflect"
5 "testing"
6
7 "github.com/mitch000001/go-hbci/domain"
8 "github.com/mitch000001/go-hbci/element"
9 )
10
11 func TestAccountInformationSegment_Account(t *testing.T) {
12 testCases := []struct {
13 desc string
14 segment AccountInformation
15 expectedAccount domain.AccountInformation
16 }{
17 {
18 desc: "v4 all mandatory fields set",
19 segment: &AccountInformationV4{
20 AccountConnection: element.NewAccountConnection(
21 domain.AccountConnection{
22 AccountID: "123456789",
23 CountryCode: 280,
24 BankID: "1000000",
25 },
26 ),
27 UserID: element.NewIdentification("user"),
28 AccountCurrency: element.NewCurrency("EUR"),
29 Name1: element.NewAlphaNumeric("name", 27),
30 },
31 expectedAccount: domain.AccountInformation{
32 AccountConnection: domain.AccountConnection{
33 AccountID: "123456789",
34 CountryCode: 280,
35 BankID: "1000000",
36 },
37 UserID: "user",
38 Currency: "EUR",
39 Name1: "name",
40 },
41 },
42 {
43 desc: "v5 all mandatory fields set",
44 segment: &AccountInformationV5{
45 UserID: element.NewIdentification("user"),
46 Name1: element.NewAlphaNumeric("name", 27),
47 },
48 expectedAccount: domain.AccountInformation{
49 UserID: "user",
50 Name1: "name",
51 },
52 },
53 {
54 desc: "v6 all mandatory fields set",
55 segment: &AccountInformationV6{
56 UserID: element.NewIdentification("user"),
57 Name1: element.NewAlphaNumeric("name", 27),
58 },
59 expectedAccount: domain.AccountInformation{
60 UserID: "user",
61 Name1: "name",
62 },
63 },
64 }
65
66 for _, tt := range testCases {
67 t.Run(tt.desc, func(t *testing.T) {
68 account := tt.segment.Account()
69
70 if !reflect.DeepEqual(tt.expectedAccount, account) {
71 t.Errorf("Expected accout to equal\n%v\n\tgot\n%v\n", tt.expectedAccount, account)
72 }
73 })
74 }
75 }