示例#1
0
        public void MockInterfaceWithGenericMethodWithConstraints()
        {
            MockRepository mockery = new MockRepository();

            ITestInterface mockObj = mockery.StrictMockWithRemoting <ITestInterface>();

            mockObj.AddService <IDisposable, SqlConnection>();
            LastCall.Return(mockObj);
            mockery.ReplayAll();

            mockObj.AddService <IDisposable, SqlConnection>();

            mockery.VerifyAll();
        }
示例#2
0
        public void MockInterfaceWithGenericMethodWithConstraints_UsingDynamicMock()
        {
            ITestInterface mockObj = MockRepository.MockWithRemoting <ITestInterface>();

            mockObj.AddService <IDisposable, SqlConnection>();
            mockObj.VerifyAllExpectations();
        }
示例#3
0
        public void MockInterfaceWithGenericMethodWithConstraints_UsingDynamicMock()
        {
            ITestInterface mockObj = MockRepository.MockWithRemoting <ITestInterface>();

            mockObj.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault);

            mockObj.AddService <IDisposable, SqlConnection>();
            mockObj.VerifyAllExpectations();
        }
示例#4
0
        public void MockInterfaceWithGenericMethodWithConstraints_UsingDynamicMock()
        {
            MockRepository mockery = new MockRepository();

            ITestInterface mockObj = mockery.DynamicMockWithRemoting <ITestInterface>();

            mockery.ReplayAll();

            mockObj.AddService <IDisposable, SqlConnection>();

            mockery.VerifyAll();
        }
示例#5
0
        public void MockInterfaceWithGenericMethodWithConstraints_WhenNotValid_UsingDynamicMock()
        {
            MockRepository mockery = new MockRepository();

            ITestInterface mockObj = mockery.DynamicMockWithRemoting <ITestInterface>();

            mockObj.AddService <IDisposable, SqlConnection>();
            LastCall.Return(mockObj);
            mockery.ReplayAll();

            Assert.Throws <ExpectationViolationException>(
                "ITestInterface.AddService<System.IDisposable, System.Data.SqlClient.SqlConnection>(); Expected #1, Actual #0.",
                () => mockery.VerifyAll());
        }