di/registry/registry_test.go
crusader 700f188618 ing
2017-12-06 15:07:44 +09:00

35 lines
875 B
Go

package registry
import (
"reflect"
"testing"
cda "git.loafle.net/commons_go/di/annotation"
)
func TestRegisterType(t *testing.T) {
RegisterType(reflect.TypeOf((*TestStruct1)(nil)), &cda.ComponentAnnotation{})
RegisterType(reflect.TypeOf((*TestStruct2)(nil)), &cda.ComponentAnnotation{
Name: "test1",
})
RegisterType(reflect.TypeOf((*TestStruct3)(nil)), &cda.ComponentAnnotation{
Name: "test2",
})
}
type TestStruct1 struct {
Name1 string `annotation:"@Inject"`
Name2 string `annotation:"@Inject()"`
Name3 string `annotation:"@Inject(name=test1)"`
}
type TestStruct2 struct {
Name1 string `annotation:"@Inject"`
Name2 string `annotation:"@Inject()"`
Name3 string `annotation:"@Inject(name=test2)"`
}
type TestStruct3 struct {
Name1 string `annotation:"@Inject"`
Name2 string `annotation:"@Inject()"`
Name3 string `annotation:"@Inject(name=test3)"`
}