Esempio n. 1
0
        public void ThrowIfNoStepInVeryStrictMode()
        {
            var methodMock = new FuncMethodMock <string>(new object(), "ClassName", "InterfaceName", "MemberName", "MockName", Strictness.VeryStrict);
            var ex         = Assert.Throws <MockMissingException>(() => methodMock.Call());

            Assert.Equal(MockType.Method, ex.MemberType);
        }
Esempio n. 2
0
        public void ReturnDefaultIfNoStepInLenientMode()
        {
            var    methodMock = new FuncMethodMock <string>(new object(), "ClassName", "InterfaceName", "MemberName", "MockName", Strictness.Lenient);
            string result     = methodMock.Call();

            Assert.Null(result);
        }
Esempio n. 3
0
        public void ThrowIfClearedInVeryStrictMode()
        {
            var methodMock = new FuncMethodMock <string>(new object(), "ClassName", "InterfaceName", "MemberName", "MockName", Strictness.VeryStrict);
            var nextStep   = NextStepFor(methodMock, "5");

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

            Assert.Equal(MockType.Method, ex.MemberType);
            Assert.Equal(0, nextStep.Count);
        }
Esempio n. 4
0
        public void ReturnDefaultIfClearedInLenientMode()
        {
            var methodMock = new FuncMethodMock <string>(new object(), "ClassName", "InterfaceName", "MemberName", "MockName", Strictness.Lenient);
            var nextStep   = NextStepFor(methodMock, "5");

            methodMock.Clear();
            string result = methodMock.Call();

            Assert.Equal(0, nextStep.Count);
            Assert.Null(result);
        }
Esempio n. 5
0
        public void SendMockInformationToStepAndGetResultBack()
        {
            var methodMock = new FuncMethodMock <string>(new object(), "ClassName", "InterfaceName", "MemberName", "MockName", Strictness.Lenient);
            var nextStep   = NextStepFor(methodMock, "5");

            string result = methodMock.Call();

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

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

            newStep.Call.Func(_ =>
            {
                called = true;
                return(string.Empty);
            });
            ((ICanHaveNextMethodStep <ValueTuple, string>)_parameterLessFuncMock).SetNextStep(newStep);
            _parameterLessFuncMock.Call();
            Assert.True(called);
        }