separate trading212 logic

This commit is contained in:
2025-11-10 13:38:49 +00:00
parent 06dc25ae88
commit 4686e36501
5 changed files with 359 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
package internal
import "testing"
func TestDirection_String(t *testing.T) {
tests := []struct {
name string
d Direction
want string
}{
{"buy", DirectionBuy, "buy"},
{"sell", DirectionSell, "sell"},
{"unknown", DirectionUnknown, "unknown"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.d.String(); got != tt.want {
t.Errorf("want Direction.String() to be %v but got %v", tt.want, got)
}
})
}
}
func TestDirection_IsBuy(t *testing.T) {
tests := []struct {
name string
d Direction
want bool
}{
{"buy", DirectionBuy, true},
{"sell", DirectionSell, false},
{"unknown", DirectionUnknown, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.d.IsBuy(); got != tt.want {
t.Errorf("want Direction.IsBuy() to be %v but got %v", tt.want, got)
}
})
}
}
func TestDirection_IsSell(t *testing.T) {
tests := []struct {
name string
d Direction
want bool
}{
{"buy", DirectionBuy, false},
{"sell", DirectionSell, true},
{"unknown", DirectionUnknown, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.d.IsSell(); got != tt.want {
t.Errorf("want Direction.IsSell() to be %v but got %v", tt.want, got)
}
})
}
}