Contents tagged with Stub

  • Stubs vs Shims difference

    Hello everybody,

    today I want to mention difference between two kinds of testing. Shim vs Stub. 

    Take a look at the following code sample:

    // Stub sample

    public interface IDependency

    {

        void SomeMethod();

    }

    // Take note that class TestTarget allows to inject 

    // interface IDependency

    public class TestTarget

    {

        private IDependency _dependency { get; set; }

        public TestTarget(IDependency dependency)

        {

            _dependency = dependency;

        }

        public void TestMethod()

        {

            _dependency.SomeMethod();

            

        }

    }

    // Shim sample. Take note that class ShimTarget doesn't allow to inject 

    // interface as dependency

    public class Dep :  … more