public void AddMessage() { IEditableSession session = GetSession(); Mock <IMessage> message = new Mock <IMessage>(); session.AddMessage(message.Object); Assert.AreEqual(1, session.GetMessages().Length); Assert.AreSame(message.Object, session.GetMessages()[0]); }
public void AppendToLog() { IEditableSession session = GetSession(); session.AppendToLog("Blah1"); session.AppendToLog("Blah2"); CollectionAssert.AreEqual(new[] { "Blah1", "Blah2", "" }, session.GetLog().ReadToEnd().Split(new string[] { "\r\n" }, StringSplitOptions.None)); }
public void AddMessage() { IEditableSession session = GetSession(); Mock <IMessage> message = new Mock <IMessage>(); session.AddMessage(message.Object); Assert.Single(session.GetMessages()); Assert.Same(message.Object, session.GetMessages()[0]); }
/// <summary> /// Initializes a new instance of the <see cref="Connection"/> class. /// </summary> /// <param name="server">The server.</param> /// <param name="session">The session.</param> /// <param name="connectionChannel">The connection channel.</param> /// <param name="verbMap">The verb map.</param> /// <param name="extensionProcessors">The extension processors.</param> internal Connection(ISmtpServer server, IEditableSession session, IConnectionChannel connectionChannel, IVerbMap verbMap, Func <IConnection, IExtensionProcessor[]> extensionProcessors) { this.id = $"[RemoteIP={connectionChannel.ClientIPAddress}]"; this.ConnectionChannel = connectionChannel; this.ConnectionChannel.ClosedEventHandler += this.OnConnectionChannelClosed; this.VerbMap = verbMap; this.Session = session; this.Server = server; this.ExtensionProcessors = extensionProcessors(this).ToArray(); }
/// <summary> /// Creates the a connection for the specified server and channel.. /// </summary> /// <param name="server">The server.</param> /// <param name="connectionChannel">The connection channel.</param> /// <param name="verbMap">The verb map.</param> /// <returns>An <see cref="Task{T}"/> representing the async operation.</returns> internal static async Task <Connection> Create(ISmtpServer server, IConnectionChannel connectionChannel, IVerbMap verbMap) { IEditableSession session = await server.Behaviour.OnCreateNewSession(connectionChannel).ConfigureAwait(false); var extensions = await server.Behaviour.GetExtensions(connectionChannel).ConfigureAwait(false); IExtensionProcessor[] CreateConnectionExtensions(IConnection c) => extensions.Select(e => e.CreateExtensionProcessor(c)).ToArray(); Connection result = new Connection(server, session, connectionChannel, verbMap, CreateConnectionExtensions); return(result); }
public async Task AppendToLog() { IEditableSession session = this.GetSession(); await session.AppendLineToSessionLog("Blah1"); await session.AppendLineToSessionLog("Blah2"); string sessionLog = (await session.GetLog()).ReadToEnd(); Assert.Equal(new[] { "Blah1", "Blah2", "" }, sessionLog.Split(new string[] { "\r\n" }, StringSplitOptions.None)); }
public async Task AddMessage() { IEditableSession session = this.GetSession(); Mock <IMessage> message = new Mock <IMessage>(); session.AddMessage(message.Object); System.Collections.Generic.IReadOnlyCollection <IMessage> messages = await session.GetMessages(); Assert.Single(messages); Assert.Same(message.Object, messages.First()); }
public void GetMessages_InitiallyEmpty() { IEditableSession session = GetSession(); Assert.AreEqual(0, session.GetMessages().Length); }
public void GetMessages_InitiallyEmpty() { IEditableSession session = GetSession(); Assert.Empty(session.GetMessages()); }
public async Task GetMessages_InitiallyEmpty() { IEditableSession session = this.GetSession(); Assert.Empty(await session.GetMessages()); }