Fix Unit & Integration tests

This commit is contained in:
Nikolaj Geisle
2022-02-11 14:27:04 +01:00
parent 83baba696c
commit 58f6226942
8 changed files with 22 additions and 21 deletions

View File

@@ -299,7 +299,7 @@ namespace Umbraco.Extensions
var firstValue = identity.FindFirstValue(ClaimTypes.NameIdentifier);
if (firstValue is not null)
{
int.Parse(firstValue, CultureInfo.InvariantCulture);
return int.Parse(firstValue, CultureInfo.InvariantCulture);
}
return null;

View File

@@ -17,7 +17,7 @@ namespace Umbraco.Cms.Core.Models.ContentEditing
public class UserSave : EntityBasic, IValidatableObject
{
[DataMember(Name = "changePassword", IsRequired = true)]
public ChangingPasswordModel ChangePassword { get; set; }
public ChangingPasswordModel? ChangePassword { get; set; }
[DataMember(Name = "id", IsRequired = true)]
[Required]
@@ -41,10 +41,10 @@ namespace Umbraco.Cms.Core.Models.ContentEditing
public IEnumerable<string> UserGroups { get; set; }
[DataMember(Name = "startContentIds")]
public int[] StartContentIds { get; set; }
public int[]? StartContentIds { get; set; }
[DataMember(Name = "startMediaIds")]
public int[] StartMediaIds { get; set; }
public int[]? StartMediaIds { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{

View File

@@ -16,7 +16,7 @@ namespace Umbraco.Cms.Core.Models
/// </summary>
public ContentTypeSort(int id, int sortOrder)
{
Id = new Lazy<int>(() => default);
Id = new Lazy<int>(() => id);
SortOrder = sortOrder;
}

View File

@@ -47,7 +47,7 @@ namespace Umbraco.Cms.Core.Models.Email
Subject = subject;
Body = body;
IsBodyHtml = isBodyHtml;
Attachments = attachments.ToList();
Attachments = attachments?.ToList();
}
}

View File

@@ -32,7 +32,7 @@ namespace Umbraco.Cms.Core.Models
public PropertyGroup(PropertyTypeCollection propertyTypeCollection)
{
_propertyTypes = propertyTypeCollection;
PropertyTypes = propertyTypeCollection;
_alias = string.Empty;
}

View File

@@ -30,7 +30,7 @@ namespace Umbraco.Cms.Core.Templates
{
foreach ((int? intId, GuidUdi? udi, string tagValue) in FindLocalLinkIds(text))
{
if (udi is null)
if (udi is not null)
yield return udi; // In v8, we only care abuot UDIs
}
}
@@ -74,7 +74,7 @@ namespace Umbraco.Cms.Core.Templates
foreach((int? intId, GuidUdi? udi, string tagValue) in FindLocalLinkIds(text))
{
if (udi is null)
if (udi is not null)
{
var newLink = "#";
if (udi?.EntityType == Constants.UdiEntityType.Document)
@@ -111,7 +111,7 @@ namespace Umbraco.Cms.Core.Templates
if (UdiParser.TryParse(id, out var udi))
{
var guidUdi = udi as GuidUdi;
if (guidUdi is null)
if (guidUdi is not null)
yield return (null, guidUdi, tag.Value);
}

View File

@@ -172,6 +172,7 @@ namespace Umbraco.Cms.Core.PropertyEditors
foreach (var udi in _imageSourceParser.FindUdisFromDataAttributes(asString))
yield return new UmbracoEntityReference(udi);
var udis = _localLinkParser.FindUdisFromLocalLinks(asString);
foreach (var udi in _localLinkParser.FindUdisFromLocalLinks(asString))
yield return new UmbracoEntityReference(udi);

View File

@@ -149,17 +149,17 @@ namespace Umbraco.Extensions
{
builder.Services
};
// Replace the default with our custom engine
builder.Services.AddSingleton<IRazorViewEngine>(
s => new RefreshingRazorViewEngine(
() =>
{
// re-create the original container so that a brand new IRazorPageActivator
// is produced, if we don't re-create the container then it will just return the same instance.
ServiceProvider recreatedServices = initialCollection.BuildServiceProvider();
return recreatedServices.GetRequiredService<IRazorViewEngine>();
}, s.GetRequiredService<InMemoryModelFactory>()));
//
// // Replace the default with our custom engine
// builder.Services.AddSingleton<IRazorViewEngine>(
// s => new RefreshingRazorViewEngine(
// () =>
// {
// // re-create the original container so that a brand new IRazorPageActivator
// // is produced, if we don't re-create the container then it will just return the same instance.
// ServiceProvider recreatedServices = initialCollection.BuildServiceProvider();
// return recreatedServices.GetRequiredService<IRazorViewEngine>();
// }, s.GetRequiredService<InMemoryModelFactory>()));
return builder;
}