Пример #1
0
        public void ThrowIfNoStepInVeryStrictMode()
        {
            var methodMock = new ActionMethodMock(new object(), "ClassName", "InterfaceName", "MemberName", "MockName", Strictness.VeryStrict);
            var ex         = Assert.Throws <MockMissingException>(() => methodMock.Call());

            Assert.Equal(MockType.Method, ex.MemberType);
        }
Пример #2
0
        public void DoNothingIfClearedInLenientMode()
        {
            var methodMock = new ActionMethodMock(new object(), "ClassName", "InterfaceName", "MemberName", "MockName", Strictness.Lenient);
            var nextStep   = NextStepFor(methodMock);

            methodMock.Clear();
            methodMock.Call();
            Assert.Equal(0, nextStep.Count);
        }
Пример #3
0
        public void SendMockInformationToStep()
        {
            var methodMock = new ActionMethodMock(new object(), "ClassName", "InterfaceName", "MemberName", "MockName", Strictness.Lenient);
            var nextStep   = NextStepFor(methodMock);

            methodMock.Call();

            Assert.Equal(1, nextStep.Count);
            Assert.Same(methodMock, nextStep.LastMockInfo);
        }
        public void SetStepUsedByCallForParameterCase()
        {
            bool called  = false;
            var  newStep = new MockMethodStep <int, ValueTuple>();

            newStep.Call.Action(_ => called = true);
            ((ICanHaveNextMethodStep <int, ValueTuple>)_actionMock).SetNextStep(newStep);
            _actionMock.Call(5);
            Assert.True(called);
        }
        public void SetStepUsedByCall()
        {
            bool called  = false;
            var  newStep = new MockMethodStep <ValueTuple, ValueTuple>();

            newStep.Call.Action(_ => { called = true; });
            ((ICanHaveNextMethodStep <ValueTuple, ValueTuple>)_parameterLessActionMock).SetNextStep(newStep);
            _parameterLessActionMock.Call();
            Assert.True(called);
        }
Пример #6
0
        public void ThrowIfClearedInVeryStrictMode()
        {
            var methodMock = new ActionMethodMock(new object(), "ClassName", "InterfaceName", "MemberName", "MockName", Strictness.VeryStrict);
            var nextStep   = NextStepFor(methodMock);

            methodMock.Clear();
            var ex = Assert.Throws <MockMissingException>(() => methodMock.Call());

            Assert.Equal(MockType.Method, ex.MemberType);
            Assert.Equal(0, nextStep.Count);
        }
Пример #7
0
        public void SendMockInformationAndParametersToStep()
        {
            var actionMock = new ActionMethodMock <int>(new object(), "ClassName", "InterfaceName", "MemberName", "MockName", Strictness.Lenient);
            var nextStep   = NextStepFor(actionMock);

            actionMock.Call(5);

            Assert.Equal(1, nextStep.Count);
            Assert.Same(actionMock, nextStep.LastMockInfo);
            Assert.Equal(5, nextStep.LastParam);
        }
Пример #8
0
        public void DoNothingIfNoStepInLenientMode()
        {
            var methodMock = new ActionMethodMock(new object(), "ClassName", "InterfaceName", "MemberName", "MockName", Strictness.Lenient);

            methodMock.Call();
        }