Hi Sunny,

I think my current approach is similar to yours. I do the DI verification
in separated cases, then inject the mocks in other cases.

I wish Windsor has what Autofac has, the last registration wins policy. So
we can use the same DI configuration everywhere, and only need to make a
small amount of overriding when needed.


Regards,
David


On Fri, Sep 8, 2017 at 7:17 AM Sunny <slon...@gmail.com> wrote:

> Hi,
> so if I understand correctly, you would like to:
> 1. test if your registrations, etc - are OK
> 2. use the existing container to get classes to tes, so it essential
> auto-wires-up the dependencies, but you replace them with mocks when/if you
> need it
>
> If the above is correct, I had solved it by:
> 1. create a separate test, which uses Diagnostics to inspect the
> registrations, if all are ok, and if there are missing registrations
> 2. I have created a small helper base test class, which auto-registers
> mocks for each dependency a class needs (using windsor underneath to put
> mocks as dependencies)
>
> Lmk if I'm correct in my assumptions and I'll make the above code public.
>
> On Thu, Sep 7, 2017 at 3:32 AM, Xi Shen <davidshe...@gmail.com> wrote:
>
>> Hi Ken,
>>
>> My scenario is, I want to use DI in my unit test, and I need to override
>> some dependency with mock instance.
>>
>> I know some people say we should not use DI in unit test. But I think
>> unit test can also be used to verify if the DIs are configured correctly.
>>
>>
>> I would also like to learn a better way to very DI configuration in real
>> product scenario.
>>
>>
>> Thanks,
>> David
>>
>>
>> On Thu, Sep 7, 2017 at 2:01 PM Ken Egozi <egoz...@gmail.com> wrote:
>>
>>> So much time since I last touched child containers...
>>>
>>>
>>> Once resolution went up to the parent container it would not go back to
>>> resolve from the child as the direction is one way.
>>>
>>> The right question to be answered is "what is your scenario?" Experience
>>> shows that more often than not, a conceptually simpler solution can be had
>>> that does not involve child containers.
>>>
>>> On Sep 6, 2017 8:01 PM, "Xi Shen" <davidshe...@gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> Is Child container still in use in Windsor 4.0? I had some issue using
>>>> child container, and opened an ticket
>>>> https://github.com/castleproject/Windsor/issues/323, but nobody
>>>> replies...I wonder if I am using some obsolete technique that nobody cares.
>>>>
>>>> If child container is obsolete, what is the modern replacement?
>>>>
>>>>
>>>> Thanks,
>>>> David
>>>>
>>>> --
>>>>
>>> You received this message because you are subscribed to the Google
>>>> Groups "Castle Project Users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to castle-project-users+unsubscr...@googlegroups.com.
>>>
>>>
>>>> To post to this group, send email to
>>>> castle-project-users@googlegroups.com.
>>>> Visit this group at
>>>> https://groups.google.com/group/castle-project-users.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "Castle Project Users" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/castle-project-users/RH28ZoTfwxQ/unsubscribe
>>> .
>>> To unsubscribe from this group and all its topics, send an email to
>>> castle-project-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to
>>> castle-project-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/castle-project-users
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Castle Project Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to castle-project-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to
>> castle-project-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/castle-project-users.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Svetoslav Milenov (Sunny)
>
> Artificial Intelligence is no match for natural stupidity.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Castle Project Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/castle-project-users/RH28ZoTfwxQ/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> castle-project-users+unsubscr...@googlegroups.com.
> To post to this group, send email to castle-project-users@googlegroups.com
> .
> Visit this group at https://groups.google.com/group/castle-project-users.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to castle-project-users+unsubscr...@googlegroups.com.
To post to this group, send email to castle-project-users@googlegroups.com.
Visit this group at https://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to