Skip to content

Commit

Permalink
Merge branch 'release/0.82.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed May 23, 2021
2 parents 1734e65 + 27b3637 commit d5f6093
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 33 deletions.
4 changes: 3 additions & 1 deletion Source/StrongGrid.IntegrationTests/Tests/Mail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ public async Task RunAsync(IBaseClient client, TextWriter log, CancellationToken
Enabled = true,
HtmlContent = "<p>This email was sent with the help of the <b><a href=\"https://www.nuget.org/packages/StrongGrid/\">StrongGrid</a></b> library</p>",
TextContent = "This email was sent with the help of the StrongGrid library"
}
},
BypassSpamManagement = true,
BypassListManagement = false
};
var trackingSettings = new TrackingSettings
{
Expand Down
2 changes: 1 addition & 1 deletion Source/StrongGrid.IntegrationTests/TestsRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public async Task<int> RunAsync()
};

// Ensure the Console is tall enough and centered on the screen
Console.WindowHeight = Math.Min(60, Console.LargestWindowHeight);
if (OperatingSystem.IsWindows()) Console.WindowHeight = Math.Min(60, Console.LargestWindowHeight);
Utils.CenterConsole();

// These are the integration tests that we will execute
Expand Down
44 changes: 16 additions & 28 deletions Source/StrongGrid/Utilities/MailSettingsConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,41 +62,20 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s

var mailSettings = (MailSettings)value;

writer.WritePropertyName("bypass_list_management");
writer.WriteStartObject();
writer.WritePropertyName("enable");
serializer.Serialize(writer, mailSettings.BypassListManagement);
writer.WriteEndObject();

writer.WritePropertyName("bypass_spam_management");
writer.WriteStartObject();
writer.WritePropertyName("enable");
serializer.Serialize(writer, mailSettings.BypassSpamManagement);
writer.WriteEndObject();

writer.WritePropertyName("bypass_bounce_management");
writer.WriteStartObject();
writer.WritePropertyName("enable");
serializer.Serialize(writer, mailSettings.BypassBounceManagement);
writer.WriteEndObject();

writer.WritePropertyName("bypass_unsubscribe_management");
writer.WriteStartObject();
writer.WritePropertyName("enable");
serializer.Serialize(writer, mailSettings.BypassUnsubscribeManagement);
writer.WriteEndObject();
// bypass_xxx_management should be omited when the value is 'false'.
// See https://github.com/Jericho/StrongGrid/issues/395 for details.
if (mailSettings.BypassListManagement) WriteEnabledProperty(writer, "bypass_list_management", true, serializer);
if (mailSettings.BypassSpamManagement) WriteEnabledProperty(writer, "bypass_spam_management", true, serializer);
if (mailSettings.BypassBounceManagement) WriteEnabledProperty(writer, "bypass_bounce_management", true, serializer);
if (mailSettings.BypassUnsubscribeManagement) WriteEnabledProperty(writer, "bypass_unsubscribe_management", true, serializer);

if (mailSettings.Footer != null)
{
writer.WritePropertyName("footer");
serializer.Serialize(writer, mailSettings.Footer);
}

writer.WritePropertyName("sandbox_mode");
writer.WriteStartObject();
writer.WritePropertyName("enable");
serializer.Serialize(writer, mailSettings.SandboxModeEnabled);
writer.WriteEndObject();
WriteEnabledProperty(writer, "sandbox_mode", mailSettings.SandboxModeEnabled, serializer);

// End of JSON serialization
writer.WriteEndObject();
Expand All @@ -116,5 +95,14 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
{
throw new NotSupportedException("The MailSettingsConverter can only be used to write JSON");
}

private static void WriteEnabledProperty(JsonWriter writer, string propertyName, bool value, JsonSerializer serializer)
{
writer.WritePropertyName(propertyName);
writer.WriteStartObject();
writer.WritePropertyName("enable");
serializer.Serialize(writer, value);
writer.WriteEndObject();
}
}
}
6 changes: 3 additions & 3 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Install tools.
#tool dotnet:?package=GitVersion.Tool&version=5.6.6
#tool nuget:?package=GitReleaseManager&version=0.11.0
#tool nuget:?package=OpenCover&version=4.7.922
#tool nuget:?package=OpenCover&version=4.7.1189
#tool nuget:?package=ReportGenerator&version=4.8.8
#tool nuget:?package=coveralls.io&version=1.4.2
#tool nuget:?package=xunit.runner.console&version=2.4.1
Expand Down Expand Up @@ -126,7 +126,7 @@ Setup(context =>
// Integration tests are intended to be used for debugging purposes and not intended to be executed in CI environment.
// Also, the runner for these tests contains windows-specific code (such as resizing window, moving window to center of screen, etc.)
// which can cause problems when attempting to run unit tests on an Ubuntu image on AppVeyor.
if (IsRunningOnUnix())
if (!isLocalBuild)
{
Information("");
Information("Removing integration tests");
Expand All @@ -136,7 +136,7 @@ Setup(context =>

Teardown(context =>
{
if (IsRunningOnUnix())
if (!isLocalBuild)
{
Information("Restoring integration tests");
GitCheckout(".", new FilePath[] { solutionFile });
Expand Down

0 comments on commit d5f6093

Please sign in to comment.