1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.MonoRail
.Framework
.Test
17 using Castle
.Components
.Common
.EmailSender
;
20 /// Represents a mock implementation of <see cref="IEmailSender"/> for unit test purposes.
22 public class MockSmtpSender
: IEmailSender
24 private readonly MockEngineContext context
;
27 /// Initializes a new instance of the <see cref="MockSmtpSender"/> class.
29 /// <param name="context">The context.</param>
30 public MockSmtpSender(MockEngineContext context
)
32 this.context
= context
;
38 /// <param name="from">From field</param>
39 /// <param name="to">To field</param>
40 /// <param name="subject">e-mail's subject</param>
41 /// <param name="messageText">message's body</param>
42 public void Send(string from, string to
, string subject
, string messageText
)
44 Send(new Message(from, to
, subject
, messageText
));
50 /// <param name="message">Message instance</param>
51 public void Send(Message message
)
53 context
.AddEmailMessageSent(message
);
57 /// Sends multiple messages.
59 /// <param name="messages">Array of messages</param>
60 public void Send(Message
[] messages
)
62 foreach(Message message
in messages
)
64 context
.AddEmailMessageSent(message
);