From a5aa1e19a5b8a734d3e8255e1157d54787689abf Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Sat, 11 Apr 2020 18:37:10 +0200 Subject: [PATCH] Fixed failing integration tests following amends to UserBuilder. --- .../Builders/EntitySlimBuilder.cs | 6 ------ .../Builders/Extensions/BuilderExtensions.cs | 7 +++++++ .../Repositories/UserRepositoryTest.cs | 20 +++++++++---------- .../Testing/UmbracoIntegrationTest.cs | 4 ---- .../Models/PathValidationTests.cs | 4 ++-- 5 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/Umbraco.Tests.Common/Builders/EntitySlimBuilder.cs b/src/Umbraco.Tests.Common/Builders/EntitySlimBuilder.cs index eedef3482c..844c765a9d 100644 --- a/src/Umbraco.Tests.Common/Builders/EntitySlimBuilder.cs +++ b/src/Umbraco.Tests.Common/Builders/EntitySlimBuilder.cs @@ -23,12 +23,6 @@ namespace Umbraco.Tests.Common.Builders }; } - public EntitySlimBuilder WithNoId() - { - _id = 0; - return this; - } - public EntitySlimBuilder WithNoParentId() { _parentId = 0; diff --git a/src/Umbraco.Tests.Common/Builders/Extensions/BuilderExtensions.cs b/src/Umbraco.Tests.Common/Builders/Extensions/BuilderExtensions.cs index 3228181edb..f3c0b9796e 100644 --- a/src/Umbraco.Tests.Common/Builders/Extensions/BuilderExtensions.cs +++ b/src/Umbraco.Tests.Common/Builders/Extensions/BuilderExtensions.cs @@ -12,6 +12,13 @@ namespace Umbraco.Tests.Common.Builders.Extensions return builder; } + public static T WithoutIdentity(this T builder) + where T : IWithIdBuilder + { + builder.Id = 0; + return builder; + } + public static T WithCreatorId(this T builder, int creatorId) where T : IWithCreatorIdBuilder { diff --git a/src/Umbraco.Tests.Integration/Persistence/Repositories/UserRepositoryTest.cs b/src/Umbraco.Tests.Integration/Persistence/Repositories/UserRepositoryTest.cs index 7feb69f0c6..a590121556 100644 --- a/src/Umbraco.Tests.Integration/Persistence/Repositories/UserRepositoryTest.cs +++ b/src/Umbraco.Tests.Integration/Persistence/Repositories/UserRepositoryTest.cs @@ -1,21 +1,19 @@ -using System.Linq; +using System; +using System.Linq; using Moq; using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Cache; -using Umbraco.Core.Logging; +using Umbraco.Core.Configuration; using Umbraco.Core.Models.Membership; +using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Mappers; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.Repositories.Implement; using Umbraco.Core.Scoping; -using Umbraco.Tests.Testing; -using Umbraco.Core.Persistence; -using Umbraco.Core.PropertyEditors; -using System; -using Umbraco.Core.Configuration; -using Umbraco.Core.Services.Implement; +using Umbraco.Tests.Common.Builders.Extensions; using Umbraco.Tests.Integration.Testing; +using Umbraco.Tests.Testing; namespace Umbraco.Tests.Persistence.Repositories { @@ -381,9 +379,9 @@ namespace Umbraco.Tests.Persistence.Repositories private IUser[] CreateAndCommitMultipleUsers(IUserRepository repository) { - var user1 = UserBuilder.WithSuffix("1").Build(); - var user2 = UserBuilder.WithSuffix("2").Build(); - var user3 = UserBuilder.WithSuffix("3").Build(); + var user1 = UserBuilder.WithoutIdentity().WithSuffix("1").Build(); + var user2 = UserBuilder.WithoutIdentity().WithSuffix("2").Build(); + var user3 = UserBuilder.WithoutIdentity().WithSuffix("3").Build(); repository.Save(user1); repository.Save(user2); repository.Save(user3); diff --git a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs index 0f3895cfbf..101feb79a4 100644 --- a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs +++ b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs @@ -1,11 +1,8 @@ using System; -using System.Collections.Generic; -using System.IO; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using NPoco.Expressions; using NUnit.Framework; using Umbraco.Core.Cache; using Umbraco.Core.Composing; @@ -21,7 +18,6 @@ using Umbraco.Tests.Common.Builders; using Umbraco.Tests.Integration.Extensions; using Umbraco.Tests.Integration.Implementations; using Umbraco.Web.BackOffice.AspNetCore; -using Umbraco.Web.Common.AspNetCore; using Umbraco.Web.Common.Extensions; namespace Umbraco.Tests.Integration.Testing diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Models/PathValidationTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Models/PathValidationTests.cs index 36a282aaf4..92f728d4b8 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Models/PathValidationTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Models/PathValidationTests.cs @@ -18,7 +18,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Models public void Validate_Path() { var entity = _builder - .WithNoId() + .WithoutIdentity() .Build(); //it's empty with no id so we need to allow it @@ -44,7 +44,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Models public void Ensure_Path_Throws_Without_Id() { var entity = _builder - .WithNoId() + .WithoutIdentity() .Build(); //no id assigned