Esempio n. 1
0
 public EmptyMethodOnly()
 {
     stub  = new ThingStub();
     fake  = A.Fake <IThingy>();
     mock  = new Mock <IThingy>().Object;
     sub   = Substitute.For <IThingy>();
     chunk = Rock.Make <IThingy>();
 }
Esempio n. 2
0
        [Test] public void CallMethodWithWeirdObjectReturn()
        {
            IThingy t = thingy;

            mock.ExpectAndReturn("AThingy", t);
            IThingy result = thingy.AThingy();

            Assertion.AssertEquals(thingy, result);
            mock.Verify();
        }
Esempio n. 3
0
        private static Program Create()
        {
            IThingy thingy = null;

            #if USE_ALTERNATES
            thingy = new thingy.alternate.AlternateThingy();
            #else
            thingy = new thingy.http.HttpThingy();
            #endif

            return(new Program(thingy));
        }
Esempio n. 4
0
        [Test] public void CreateGenericProxy()
        {
            InvocationHandlerImpl handler = new InvocationHandlerImpl();
            ClassGenerator        cg      = new ClassGenerator(typeof(IThingy), handler);
            IThingy thingy = (IThingy)cg.Generate();

            handler.expectedMethodName = "NoArgs";

            thingy.NoArgs();

            Assertion.Assert("Should have been called ", handler.wasCalled);
        }
Esempio n. 5
0
        public VerifyOnly()
        {
            stub = new ThingStub();
            stub.DoSomething();

            fake = A.Fake <IThingy>();
            fake.DoSomething();

            mock = new Mock <IThingy>();
            mock.Object.DoSomething();

            sub = Substitute.For <IThingy>();
            sub.DoSomething();

            rock = Rock.Create <IThingy>();
            rock.Handle(r => r.DoSomething());
            rock.Make().DoSomething();
        }
Esempio n. 6
0
        public CallbackOnly()
        {
            stub = new ThingStub();

            fake = A.Fake <IThingy>();
            A.CallTo(() => fake.DoSomething()).Invokes(f => fakeCalled = true);

            var mockSetup = new Mock <IThingy>();

            mockSetup.Setup(m => m.DoSomething()).Callback(() => mockCalled = true);
            mock = mockSetup.Object;

            sub = Substitute.For <IThingy>();
            sub.When(s => s.DoSomething()).Do(c => subCalled = true);

            var rock = Rock.Create <IThingy>();

            rock.Handle(r => r.DoSomething(), () => rockCalled = true);
            chunk = rock.Make();
        }
Esempio n. 7
0
        public ReturnOnly()
        {
            stub = new ThingStub();

            fake = A.Fake <IThingy>();
            A.CallTo(() => fake.One()).Returns(1);

            var mockSetup = new Mock <IThingy>();

            mockSetup.Setup(m => m.One()).Returns(1);
            mock = mockSetup.Object;

            sub = Substitute.For <IThingy>();
            sub.One().Returns(1);

            var rock = Rock.Create <IThingy>();

            rock.Handle(r => r.One()).Returns(1);
            chunk = rock.Make();
        }
Esempio n. 8
0
		[SetUp] public void SetUp()
		{
			mock = new Mock("Test Mock");
			cg = new ClassGenerator(typeof(IThingy), mock);
			thingy = (IThingy)cg.Generate();
		}
Esempio n. 9
0
 public Program(IThingy thingy)
 {
     _thingy = thingy;
 }
Esempio n. 10
0
 [SetUp] public void SetUp()
 {
     mock   = new Mock("Test Mock");
     cg     = new ClassGenerator(typeof(IThingy), mock);
     thingy = (IThingy)cg.Generate();
 }