di/registry/registry_test.go
crusader 0a16fb1bd1 ing
2017-12-06 09:48:03 +09:00

35 lines
912 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{
Names: []string{"test1", "test2"},
})
RegisterType(reflect.TypeOf((*TestStruct3)(nil)), &cda.ComponentAnnotation{
Names: []string{"test1", "test2"},
})
}
type TestStruct1 struct {
Name1 string `annotation:"@Inject"`
Name2 string `annotation:"@Inject()"`
Name3 string `annotation:"@Inject(name=test)"`
}
type TestStruct2 struct {
Name1 string `annotation:"@Inject"`
Name2 string `annotation:"@Inject()"`
Name3 string `annotation:"@Inject(name=test)"`
}
type TestStruct3 struct {
Name1 string `annotation:"@Inject"`
Name2 string `annotation:"@Inject()"`
Name3 string `annotation:"@Inject(name=test)"`
}