/ Published in: C#
                    
                                        
Example 1: I'm verifying that the list that is passed in has 3 attachments.  SendMail is run later in the SendEmail method.
Example 2: I'm verifying that the object that is passed into the method has the appropriate values.
                Example 2: I'm verifying that the object that is passed into the method has the appropriate values.
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
Example 1:
private Mock<IEmailService> mockEmailService = repository.Create<IEmailService>();
// Setup
const string messageSubject = @"foo example";
const string messageBody = @"foo body";
const bool highPriority = true;
const string fromAccount = "TestAccount";
// Action
target.SendEmail(emailAddress, messageSubject, messageBody, true, fromAccount, attachmentList);
// Assert
mockEmailService.Verify(x => x.SendMail(It.Is<MailMessage>(p => p.Attachments.Count() == 3), It.IsAny<bool>()));
------------------------------
Example 2:
private MockRepository mockRepository;
private Mock<IProvider> mockProvider;
BrokerInvoiceNumber = "BI456"};
mockProvider.Setup(h => h.BiProcessingErrorProvider.InsertBiProcessingError(
&& x.BrokerInvoiceNumber == brokerInvoiceModel.BrokerInvoiceNumber
&& x.ExceptionInfo == exception.Message
&& x.ExtendedInfo == exception.ToString()))).Verifiable();
// Action
target.CreateErrorLog(exception, brokerInvoiceModel);
// Assert
mockRepository.VerifyAll();
Comments
 Subscribe to comments
                    Subscribe to comments
                
                