예제 #1
0
        public void Invalid_DelegateToGenericMock()
        {
            IEMailFormatter <string>     formatterMock = MockRepository.Mock <IEMailFormatter <string> >();
            SmtpEMailSenderBase <string> senderMock    = MockRepository.Mock <SmtpEMailSenderBase <string> >();

            Assert.Throws <InvalidOperationException>(
                () => senderMock.Expect(x => x.SetFormatter(formatterMock))
                .DoInstead((Action <IEMailFormatter <int> >) delegate(IEMailFormatter <int> formatter)
            {
                Assert.NotNull(formatter);
            }));
        }
예제 #2
0
        public void DelegateToGenericMock()
        {
            IEMailFormatter <string>     formatterMock = MockRepository.Mock <IEMailFormatter <string> >();
            SmtpEMailSenderBase <string> senderMock    = MockRepository.Mock <SmtpEMailSenderBase <string> >();

            senderMock.Expect(x => x.SetFormatter(formatterMock))
            .DoInstead((Action <IEMailFormatter <string> >) delegate(IEMailFormatter <string> formatter)
            {
                Assert.NotNull(formatter);
            });

            senderMock.SetFormatter(formatterMock);
            senderMock.VerifyExpectations(true);
        }
예제 #3
0
        public void Invalid_DelegateToGenericMock()
        {
            MockRepository               mocks         = new MockRepository();
            IEMailFormatter <string>     formatterMock = mocks.StrictMock <IEMailFormatter <string> >();
            SmtpEMailSenderBase <string> senderMock    = (SmtpEMailSenderBase <string>)mocks.StrictMock(typeof(SmtpEMailSenderBase <string>));

            senderMock.SetFormatter(formatterMock);
            Assert.Throws <InvalidOperationException>("Callback arguments didn't match the method arguments",
                                                      () =>
                                                      LastCall.Do(
                                                          (Action <IEMailFormatter <int> >) delegate(IEMailFormatter <int> formatter)
            {
                Assert.NotNull(formatter);
            }));
        }
예제 #4
0
        public void DelegateToGenericMock()
        {
            MockRepository               mocks         = new MockRepository();
            IEMailFormatter <string>     formatterMock = mocks.StrictMock <IEMailFormatter <string> >();
            SmtpEMailSenderBase <string> senderMock    = (SmtpEMailSenderBase <string>)mocks.StrictMock(typeof(SmtpEMailSenderBase <string>));

            senderMock.SetFormatter(formatterMock);
            LastCall.Do((Action <IEMailFormatter <string> >) delegate(IEMailFormatter <string> formatter)
            {
                Assert.NotNull(formatter);
            });
            mocks.ReplayAll();

            senderMock.SetFormatter(formatterMock);

            mocks.VerifyAll();
        }