MCPcopy Create free account
hub / github.com/codnect/procyon / TestDefaultContainer_CanResolve

Function TestDefaultContainer_CanResolve

component/container_test.go:718–767  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

716}
717
718func TestDefaultContainer_CanResolve(t *testing.T) {
719 var testCases = []struct {
720 name string
721 preCondition func(container Container)
722 instanceName string
723
724 wantResult bool
725 }{
726 {
727 name: "can resolve instance singleton",
728 preCondition: func(container Container) {
729 _ = container.RegisterSingleton("anyInstanceName", &AnyComponent{})
730 },
731 instanceName: "anyInstanceName",
732 wantResult: true,
733 },
734 {
735 name: "can resolve instance definition",
736 preCondition: func(container Container) {
737 _ = container.RegisterDefinition(&Definition{
738 name: "anyInstanceName",
739 })
740 },
741 instanceName: "anyInstanceName",
742 wantResult: true,
743 },
744 {
745 name: "cannot resolve instance",
746 instanceName: "anyInstanceName",
747 wantResult: false,
748 },
749 }
750
751 for _, tc := range testCases {
752 t.Run(tc.name, func(t *testing.T) {
753 // given
754 container := NewDefaultContainer()
755
756 if tc.preCondition != nil {
757 tc.preCondition(container)
758 }
759
760 // when
761 result := container.CanResolve(tc.instanceName)
762
763 // then
764 assert.Equal(t, tc.wantResult, result)
765 })
766 }
767}
768
769func TestDefaultContainer_CanResolveType(t *testing.T) {
770 var testCases = []struct {

Callers

nothing calls this directly

Calls 5

RegisterSingletonMethod · 0.95
RegisterDefinitionMethod · 0.95
CanResolveMethod · 0.95
NewDefaultContainerFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected