locked
Why do we need original assembly after creating fake assembly? RRS feed

  • Question

  • Hello all,

    We are developing unit tests using MS Fakes Isolation Framework by providing fake implementation to externally referenced assembly methods called from the system under test.

    In the unit test project, we have created fake assemblies for each of the referenced assembly and tests were developed using stubs & shims.

    My question here is why do we need the original assembly even after creating fake assembly as we are not directly using any of the data types & methods from it?

    Presence of both assemblies lead to more confusion to find out whether original implementation is executed or fake implementation is executed

    Is there an option where can generate fake assemblies once and remove the original assemblies from unit test project?

    Thanks & Regards

    Samba

    Thursday, November 1, 2012 12:11 PM

Answers

  • Fakes needs only those assemblies required to compile the stubs and shims you specify. In particular if any type you choose to fake references another assembly in its "public" interface, then Fakes needs a reference to that assembly in order to generate and compile the matching fake type. To use the generated fake type, your unit test project would also need a reference to this assembly.

    By default, Fakes generates stubs and shims for all supported types in the target assembly. It is possible that you are having to reference assemblies required to generate the fake types you don't actually need. In this case, you can reduce the number of references by filtering the list of types as described here: http://msdn.microsoft.com/en-us/library/hh708916.aspx#bkmk_type_filtering.  

    • Proposed as answer by Amanda Zhu Friday, November 2, 2012 1:43 AM
    • Marked as answer by Amanda Zhu Monday, November 5, 2012 12:22 AM
    Thursday, November 1, 2012 3:44 PM