Added unit tests for introduced unit test configuration setting builders.

This commit is contained in:
Andy Butland
2020-09-21 08:44:11 +02:00
parent d5d6082d07
commit d55b54ce49
15 changed files with 292 additions and 27 deletions

View File

@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System;
using System.ComponentModel.DataAnnotations;
using System.Net.Mail;
using Umbraco.Core.Configuration.Models.Validation;
@@ -16,7 +17,18 @@ namespace Umbraco.Core.Configuration.Models
public string PickupDirectoryLocation { get; set; }
public SmtpDeliveryMethod DeliveryMethod { get; set; }
// See notes on ContentSettings.MacroErrors
internal string DeliveryMethod { get; set; }
public SmtpDeliveryMethod DeliveryMethodValue
{
get
{
return Enum.TryParse<SmtpDeliveryMethod>(DeliveryMethod, true, out var value)
? value
: SmtpDeliveryMethod.Network;
}
}
public string Username { get; set; }

View File

@@ -1,4 +1,5 @@
using Microsoft.Extensions.Options;
using System.Net.Mail;
using Microsoft.Extensions.Options;
namespace Umbraco.Core.Configuration.Models.Validation
{
@@ -17,7 +18,8 @@ namespace Umbraco.Core.Configuration.Models.Validation
private bool ValidateSmtpSetting(SmtpSettings value, out string message)
{
return ValidateOptionalEntry("Global:Smtp", value, "A valid From email address is required", out message);
return ValidateOptionalEntry("Global:Smtp", value, "A valid From email address is required", out message) &&
ValidateStringIsOneOfEnumValues("Global:Smtp:DeliveryMethod", value.DeliveryMethod, typeof(SmtpDeliveryMethod), out message);
}
}
}