Exemplo n.º 1
0
        public void TestReplaceWithInstanceVariable()
        {
            ShimTests shimTests = new ShimTests();
            Shim      shim      = Shim.Replace(() => shimTests.TestReplace());

            Assert.AreEqual(typeof(ShimTests).GetMethod("TestReplace"), shim.Original);
            Assert.AreSame(shimTests, shim.Instance);
            Assert.IsNull(shim.Replacement);
        }
Exemplo n.º 2
0
        public void TestShimReplaceWithInvalidSignature()
        {
            ShimTests shimTests = new ShimTests();
            Shim      shim      = Shim.Replace(() => shimTests.TestReplace());

            Assert.ThrowsException <InvalidShimSignatureException>(
                () => Shim.Replace(() => shimTests.TestReplace()).With(() => { }));
            Assert.ThrowsException <InvalidShimSignatureException>(
                () => Shim.Replace(() => Console.WriteLine(Is.A <string>())).With(() => { }));
        }
Exemplo n.º 3
0
        public void TestShimReplaceWith()
        {
            ShimTests          shimTests      = new ShimTests();
            Action             action         = new Action(() => { });
            Action <ShimTests> actionInstance = new Action <ShimTests>((s) => { });

            Shim shim  = Shim.Replace(() => Console.WriteLine()).With(action);
            Shim shim1 = Shim.Replace(() => shimTests.TestReplace()).With(actionInstance);

            Assert.AreEqual(typeof(Console).GetMethod("WriteLine", Type.EmptyTypes), shim.Original);
            Assert.AreEqual(action, shim.Replacement);

            Assert.AreEqual(typeof(ShimTests).GetMethod("TestReplace"), shim1.Original);
            Assert.AreSame(shimTests, shim1.Instance);
            Assert.AreEqual(actionInstance, shim1.Replacement);
        }