-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add global usings and disabled nullable
- Loading branch information
Showing
25 changed files
with
2,237 additions
and
2,320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
global using System; | ||
global using System.Collections.Generic; | ||
global using System.IO; | ||
global using System.Linq; | ||
global using System.Net; | ||
global using System.Net.Sockets; | ||
global using System.Reflection; | ||
global using System.Text; | ||
global using System.Threading.Tasks; | ||
global using netDumbster.smtp; | ||
global using netDumbster.smtp.Logging; | ||
global using MimeKit; | ||
global using MailKit.Net.Smtp; | ||
global using Xunit; | ||
global using Xunit.Sdk; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,22 @@ | ||
// Copyright (c) 2010, Hexasystems Corporation | ||
// All rights reserved. | ||
namespace netDumbster.Test | ||
{ | ||
using System.Net; | ||
using netDumbster.smtp; | ||
namespace netDumbster.Test; | ||
|
||
public class LoopbackAdapterTests : TestsBase | ||
public class LoopbackAdapterTests : TestsBase | ||
{ | ||
protected override SimpleSmtpServer StartServer() | ||
{ | ||
protected override SimpleSmtpServer StartServer() | ||
{ | ||
return Configuration.Configure() | ||
.WithAddress(IPAddress.Loopback) | ||
.Build(); | ||
} | ||
|
||
protected override SimpleSmtpServer StartServer(int port) | ||
{ | ||
return Configuration.Configure() | ||
.WithAddress(IPAddress.Loopback) | ||
.WithPort(port) | ||
.Build(); | ||
} | ||
return Configuration.Configure() | ||
.WithAddress(IPAddress.Loopback) | ||
.Build(); | ||
} | ||
|
||
protected override SimpleSmtpServer StartServer(int port) | ||
{ | ||
return Configuration.Configure() | ||
.WithAddress(IPAddress.Loopback) | ||
.WithPort(port) | ||
.Build(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,69 @@ | ||
namespace netDumbster.Test | ||
namespace netDumbster.Test; | ||
|
||
public class MailKitTests : IDisposable | ||
{ | ||
using MailKit.Net.Smtp; | ||
using MimeKit; | ||
using netDumbster.smtp; | ||
using netDumbster.smtp.Logging; | ||
using System; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
public class MailKitTests : IDisposable | ||
private bool _disposed; | ||
private readonly SimpleSmtpServer _server; | ||
|
||
public MailKitTests() | ||
{ | ||
private bool _disposed; | ||
private readonly SimpleSmtpServer _server; | ||
LogManager.GetLogger = type => new ConsoleLogger(type); | ||
|
||
public MailKitTests() | ||
{ | ||
LogManager.GetLogger = type => new ConsoleLogger(type); | ||
_server = Configuration.Configure() | ||
.WithRandomPort() | ||
.Build(); | ||
} | ||
|
||
_server = Configuration.Configure() | ||
.WithRandomPort() | ||
.Build(); | ||
} | ||
/// <summary> | ||
/// As reported: <see href="https://github.com/cmendible/netDumbster/issues/26"/> | ||
/// </summary> | ||
[Fact] | ||
public async Task Send_WithMailKit_WholeBodyMessageIsPreserved() | ||
{ | ||
var expectedBody = $"this is the body{Environment.NewLine}line2{Environment.NewLine}line3"; | ||
|
||
/// <summary> | ||
/// As reported: <see href="https://github.com/cmendible/netDumbster/issues/26"/> | ||
/// </summary> | ||
[Fact] | ||
public async Task Send_WithMailKit_WholeBodyMessageIsPreserved() | ||
using var client = new SmtpClient | ||
{ | ||
var expectedBody = $"this is the body{Environment.NewLine}line2{Environment.NewLine}line3"; | ||
ServerCertificateValidationCallback = (_, __, ___, ____) => true | ||
}; | ||
|
||
using var client = new SmtpClient | ||
{ | ||
ServerCertificateValidationCallback = (_, __, ___, ____) => true | ||
}; | ||
await client.ConnectAsync("localhost", _server.Configuration.Port, false).ConfigureAwait(true); | ||
client.AuthenticationMechanisms.Remove("XOAUTH2"); | ||
|
||
await client.ConnectAsync("localhost", _server.Configuration.Port, false).ConfigureAwait(false); | ||
client.AuthenticationMechanisms.Remove("XOAUTH2"); | ||
var from = new MailboxAddress("from", "[email protected]"); | ||
var to = new MailboxAddress("to", "[email protected]"); | ||
|
||
var from = new MailboxAddress("from", "[email protected]"); | ||
var to = new MailboxAddress("to", "[email protected]"); | ||
var message = new MimeMessage(); | ||
|
||
var message = new MimeMessage(); | ||
message.From.Add(from); | ||
message.To.Add(to); | ||
message.Subject = "test"; | ||
message.Body = new TextPart("plain") { Text = expectedBody }; | ||
message.Headers.Add("empty-value", string.Empty); | ||
|
||
message.From.Add(from); | ||
message.To.Add(to); | ||
message.Subject = "test"; | ||
message.Body = new TextPart("plain") { Text = expectedBody }; | ||
message.Headers.Add("empty-value", string.Empty); | ||
client.Send(message); | ||
|
||
client.Send(message); | ||
Assert.Equal(1, _server.ReceivedEmailCount); | ||
Assert.Equal(expectedBody, _server.ReceivedEmail[0].MessageParts[0].BodyData); | ||
} | ||
|
||
Assert.Equal(1, _server.ReceivedEmailCount); | ||
Assert.Equal(expectedBody, _server.ReceivedEmail[0].MessageParts[0].BodyData); | ||
} | ||
public void Dispose() | ||
{ | ||
Dispose(true); | ||
GC.SuppressFinalize(this); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
Dispose(true); | ||
GC.SuppressFinalize(this); | ||
} | ||
protected virtual void Dispose(bool disposing) | ||
{ | ||
if (_disposed) | ||
return; | ||
|
||
protected virtual void Dispose(bool disposing) | ||
if (disposing) | ||
{ | ||
if (_disposed) | ||
return; | ||
|
||
if (disposing) | ||
{ | ||
_server.Stop(); | ||
} | ||
|
||
_disposed = true; | ||
_server.Stop(); | ||
} | ||
|
||
_disposed = true; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,26 @@ | ||
// Copyright (c) 2010, Hexasystems Corporation | ||
// All rights reserved. | ||
|
||
namespace netDumbster.Test | ||
namespace netDumbster.Test; | ||
|
||
public class RepeatAttribute : DataAttribute | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using Xunit.Sdk; | ||
private readonly int times; | ||
|
||
public class RepeatAttribute : DataAttribute | ||
public RepeatAttribute(int count) | ||
{ | ||
private readonly int times; | ||
|
||
public RepeatAttribute(int count) | ||
if (count < 1) | ||
{ | ||
if (count < 1) | ||
{ | ||
throw new ArgumentOutOfRangeException( | ||
nameof(count), | ||
"Repeat count must be greater than 0."); | ||
} | ||
times = count; | ||
throw new ArgumentOutOfRangeException( | ||
nameof(count), | ||
"Repeat count must be greater than 0."); | ||
} | ||
times = count; | ||
} | ||
|
||
public override IEnumerable<object[]> GetData(MethodInfo testMethod) | ||
{ | ||
return Enumerable.Repeat(Array.Empty<object>(), times); | ||
} | ||
public override IEnumerable<object[]> GetData(MethodInfo testMethod) | ||
{ | ||
return Enumerable.Repeat(Array.Empty<object>(), times); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.