Пример #1
0
        public void Invoke_ValidParameters_ReturnsResult()
        {
            var obj   = new TestClasses.ImplIClass2(null);
            var mocks = typeof(TestClasses.ImplIClass2).GetMocksFrom("second")
                        .Distinct()
                        .Mocks.Select(p => p.Details);

            Assert.IsTrue(mocks.Invoke <TestClasses.ImplIClass2, bool>("second", obj), "Invoked method has something wrong");
        }
Пример #2
0
        public void VoidInvoke_InvalidMethod_ReturnsException()
        {
            var obj   = new TestClasses.ImplIClass2(null);
            var mocks = typeof(TestClasses.ImplIClass2).GetMocksFrom("voidsecond")
                        .Distinct()
                        .Mocks.Select(p => p.Details);

            Assert.Throws <MethodNotFoundException>(() =>
            {
                mocks.Invoke <TestClasses.ImplIClass2, bool>("notexist", obj);
            });
        }
Пример #3
0
        public void VoidInvoke_ValidParameters_EndsWithoutException()
        {
            var obj   = new TestClasses.ImplIClass2(null);
            var mocks = typeof(TestClasses.ImplIClass2).GetMocksFrom("voidsecond")
                        .Distinct()
                        .Mocks.Select(p => p.Details);

            Assert.DoesNotThrow(() =>
            {
                mocks.Invoke <TestClasses.ImplIClass2>("voidsecond", obj);
            });
        }
Пример #4
0
        public void VoidInvoke_SignatureDoesNotMatch_ReturnsException()
        {
            var obj   = new TestClasses.ImplIClass2(null);
            var mocks = typeof(TestClasses.ImplIClass2).GetMocksFrom("voidsecond")
                        .Distinct()
                        .Mocks.Select(p => p.Details);

            mocks = mocks.Where(p => false); //empty list

            Assert.Throws <MethodNotFoundException>(() =>
            {
                mocks.Invoke <TestClasses.ImplIClass2, bool>("voidsecond", obj);
            });
        }