Esempio n. 1
0
        public void ExecutesNextIfNoBehaviors()
        {
            var invocation = new MethodInvocation(new FakeMock(), typeof(object).GetMethod(nameof(object.ToString)));
            var pipeline   = new MockBehaviorPipeline(new MockSetup(invocation, Array.Empty <IArgumentMatcher>()));

            Assert.NotNull(pipeline.Execute(invocation, () => (m, n) => m.CreateValueReturn(null)));
        }
Esempio n. 2
0
        public void ThrowsIfTargetNotIMocked()
        {
            var invocation = new MethodInvocation(new object(), typeof(object).GetMethod(nameof(object.ToString)));
            var pipeline   = new MockBehaviorPipeline(new MockSetup(invocation, Array.Empty <IArgumentMatcher>()));

            pipeline.Behaviors.Add(MockBehavior.Create((m, i, n) => i.CreateValueReturn(null), "test"));

            Assert.Throws <ArgumentException>(() => pipeline.Execute(invocation, () => (m, n) => throw new NotImplementedException()));
        }
        public void ExecutesBehaviorAndNext()
        {
            var invocation = new MethodInvocation(new FakeMock(), typeof(object).GetMethod(nameof(object.ToString)));
            var pipeline   = new MockBehaviorPipeline(new MockSetup(invocation, Array.Empty <IArgumentMatcher>()));

            pipeline.Behaviors.Add(new DelegateMockBehavior((m, i, n) => n().Invoke(m, i, n), "test"));

            Assert.NotNull(pipeline.Execute(invocation, () => (m, n) => m.CreateValueReturn(null)));
        }
Esempio n. 4
0
        public void ExecutesBehavior()
        {
            var invocation = new MethodInvocation(new FakeMock(), typeof(object).GetMethod(nameof(object.ToString)));
            var pipeline   = new MockBehaviorPipeline(new MockSetup(invocation, Array.Empty <IArgumentMatcher>()));

            pipeline.Behaviors.Add(new AnonymousMockBehavior((m, i, n) => i.CreateValueReturn(null), "test"));

            Assert.NotNull(pipeline.Execute(invocation, () => (m, n) => throw new NotImplementedException()));
        }