diff --git a/Build/Program.cs b/Build/Program.cs index 6f999068987..8b8898b41b3 100644 --- a/Build/Program.cs +++ b/Build/Program.cs @@ -12,10 +12,10 @@ namespace DotNetNuke.Build public class Program { /// The version of the Microsoft.TestPlatform NuGet package. - internal const string MicrosoftTestPlatformVersion = "17.14.1"; + internal const string MicrosoftTestPlatformVersion = "18.0.1"; /// The version of the NUnit3TestAdapter NuGet package. - internal const string NUnit3TestAdapterVersion = "5.0.0"; + internal const string NUnit3TestAdapterVersion = "6.0.0"; /// Runs the build process. /// The arguments from the command line. diff --git a/Build/Tasks/UnitTests.cs b/Build/Tasks/UnitTests.cs index 5be502e900f..ba432d1a3e4 100644 --- a/Build/Tasks/UnitTests.cs +++ b/Build/Tasks/UnitTests.cs @@ -16,8 +16,8 @@ public sealed class UnitTests : FrostingTask /// public override void Run(Context context) { - var testAssemblies = context.GetFiles($@"**\bin\{context.BuildConfiguration}\DotNetNuke.Tests.*.dll"); - testAssemblies += context.GetFiles($@"**\bin\{context.BuildConfiguration}\Dnn.PersonaBar.*.Tests.dll"); + var testAssemblies = context.GetFiles(@"**\bin\**\DotNetNuke.Tests.*.dll"); + testAssemblies += context.GetFiles(@"**\bin\**\Dnn.PersonaBar.*.Tests.dll"); testAssemblies -= context.GetFiles(@"**\DotNetNuke.Tests.Utilities.dll"); // TODO: address issues to allow these tests to run diff --git a/DNN Platform/Library/Entities/Portals/PortalController.cs b/DNN Platform/Library/Entities/Portals/PortalController.cs index f3e64ee0da9..b5fc245f5ca 100644 --- a/DNN Platform/Library/Entities/Portals/PortalController.cs +++ b/DNN Platform/Library/Entities/Portals/PortalController.cs @@ -1155,9 +1155,9 @@ public static string GetActivePortalLanguage(IHostSettings hostSettings, IApplic // PortalSettings IS Nothing - probably means we haven't set it yet (in Begin Request) // so try detecting the user's cookie - if (HttpContext.Current.Request["language"] != null) + if (context.Request["language"] != null) { - language = HttpContext.Current.Request["language"]; + language = context.Request["language"]; isDefaultLanguage = false; } diff --git a/DNN Platform/Tests/DNN.Integration.Test.Framework/DNN.Integration.Test.Framework.csproj b/DNN Platform/Tests/DNN.Integration.Test.Framework/DNN.Integration.Test.Framework.csproj index a4d862e1ff5..8161f6e69f2 100644 --- a/DNN Platform/Tests/DNN.Integration.Test.Framework/DNN.Integration.Test.Framework.csproj +++ b/DNN Platform/Tests/DNN.Integration.Test.Framework/DNN.Integration.Test.Framework.csproj @@ -1,240 +1,45 @@ - - - - - - - - - - - + + - Debug - AnyCPU - {8F727796-7C6C-4F42-B385-67B06ECD358E} - Library - Properties - DNN.Integration.Test.Framework - DNN.Integration.Test.Framework - v4.8 - 512 - - true - - - - - AnyCPU - true - full - false - bin\ - DEBUG;TRACE - prompt - 4 - 1591, 618,SA0001 - latest - true - - - AnyCPU - pdbonly - true - bin\ - TRACE - prompt - 4 - 1591, 618,SA0001 + net48 + false latest true + 1591,618,SA0001 + false + bin + false + - - ..\..\..\packages\Castle.Core.5.1.1\lib\net462\Castle.Core.dll - - - ..\..\..\packages\Microsoft.ApplicationInsights.2.22.0\lib\net46\Microsoft.ApplicationInsights.dll - - - - ..\..\..\packages\Microsoft.Testing.Platform.MSBuild.1.6.0\lib\netstandard2.0\Microsoft.Testing.Extensions.MSBuild.dll - - - ..\..\..\packages\Microsoft.Testing.Extensions.Telemetry.1.6.0\lib\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.dll - - - ..\..\..\packages\Microsoft.Testing.Extensions.TrxReport.Abstractions.1.6.0\lib\netstandard2.0\Microsoft.Testing.Extensions.TrxReport.Abstractions.dll - - - ..\..\..\packages\Microsoft.Testing.Extensions.VSTestBridge.1.6.0\lib\netstandard2.0\Microsoft.Testing.Extensions.VSTestBridge.dll - - - ..\..\..\packages\Microsoft.Testing.Platform.1.6.0\lib\netstandard2.0\Microsoft.Testing.Platform.dll - - - ..\..\..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.TestPlatform.CoreUtilities.dll - - - ..\..\..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.TestPlatform.PlatformAbstractions.dll - - - ..\..\..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll - - - ..\..\..\packages\Moq.4.20.72\lib\net462\Moq.dll - True - - - ..\..\..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll - - - ..\..\..\packages\Newtonsoft.Json.Bson.1.0.3\lib\net45\Newtonsoft.Json.Bson.dll - - - ..\..\..\packages\NUnit.4.3.2\lib\net462\nunit.framework.dll - - - ..\..\..\packages\NUnit.4.3.2\lib\net462\nunit.framework.legacy.dll - - - - ..\..\..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll - - - ..\..\..\packages\System.Collections.Immutable.9.0.2\lib\net462\System.Collections.Immutable.dll - - - - - ..\..\..\packages\System.Diagnostics.DiagnosticSource.9.0.2\lib\net462\System.Diagnostics.DiagnosticSource.dll - - - ..\..\..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll - - - ..\..\..\packages\Microsoft.AspNet.WebApi.Client.6.0.0\lib\net45\System.Net.Http.Formatting.dll - - - - ..\..\..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll - - - ..\..\..\packages\System.Reflection.Metadata.9.0.2\lib\net462\System.Reflection.Metadata.dll - - - - ..\..\..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll - - - - ..\..\..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll - - - ..\..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll - - - - ..\..\..\packages\Microsoft.AspNet.WebApi.Core.5.3.0\lib\net45\System.Web.Http.dll - - - - - + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + - - Properties\SolutionInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {5FE5D021-9C8D-47A6-BD34-F328BA3E709C} - DotNetNuke.Internal.SourceGenerators - - - {6928a9b1-f88a-4581-a132-d3eb38669bb0} - DotNetNuke.Abstractions - - - {6b29aded-7b56-4484-bea5-c0e09079535b} - DotNetNuke.Library - - - - - stylecop.json - - - - + + - - - + + + + - + + - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/DNN Platform/Tests/DNN.Integration.Test.Framework/DNN.Integration.Test.Framework.nuspec b/DNN Platform/Tests/DNN.Integration.Test.Framework/DNN.Integration.Test.Framework.nuspec index f32e5f2739c..358ed847844 100644 --- a/DNN Platform/Tests/DNN.Integration.Test.Framework/DNN.Integration.Test.Framework.nuspec +++ b/DNN Platform/Tests/DNN.Integration.Test.Framework/DNN.Integration.Test.Framework.nuspec @@ -13,8 +13,8 @@ https://dnncommunity.org/favicon.ico - - + + diff --git a/DNN Platform/Tests/DNN.Integration.Test.Framework/Helpers/WebApiTestHelper.cs b/DNN Platform/Tests/DNN.Integration.Test.Framework/Helpers/WebApiTestHelper.cs index 03c4163a4b4..2d120d6765b 100644 --- a/DNN Platform/Tests/DNN.Integration.Test.Framework/Helpers/WebApiTestHelper.cs +++ b/DNN Platform/Tests/DNN.Integration.Test.Framework/Helpers/WebApiTestHelper.cs @@ -1,6 +1,6 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information namespace DNN.Integration.Test.Framework.Helpers { using System; @@ -8,10 +8,11 @@ namespace DNN.Integration.Test.Framework.Helpers using System.Net; using System.Security.Cryptography; using System.Text; - + using System.Threading.Tasks; + using DNN.Integration.Test.Framework.Controllers; using NUnit.Framework; - + public static class WebApiTestHelper { private static readonly Dictionary CachedConnections = new Dictionary(); @@ -19,7 +20,7 @@ public static class WebApiTestHelper private static readonly string HostGuid = HostSettingsHelper.GetHostSettingValue("GUID"); private static IWebApiConnector _anonymousConnector; - /// Returns a coonector to access the default site annonymously. + /// Returns a connector to access the default site anonymously. /// IWebApiConnector object to perform more actions. public static IWebApiConnector GetAnnonymousConnector(string url = null) { @@ -45,16 +46,16 @@ SELECT TOP 1 m.ModuleID FROM {{objectQualifier}}TabModules tm }; } - public static IWebApiConnector PrepareNewUser(out int userId, out string username, out int fileId, int portalId = 0) + public static async Task<(IWebApiConnector Connector, int UserId, string Username, int FileId)> PrepareNewUser(int portalId = 0) { - username = $"testuser{Rnd.Next(1000, 9999)}"; + var username = $"testuser{Rnd.Next(1000, 9999)}"; var email = $"{username}@dnn.com"; using (WebApiTestHelper.Register(username, AppConfigHelper.HostPassword, username, email)) { } - userId = DatabaseHelper.ExecuteScalar($"SELECT UserId FROM {{objectQualifier}}Users WHERE Username = '{username}'"); + var userId = DatabaseHelper.ExecuteScalar($"SELECT UserId FROM {{objectQualifier}}Users WHERE Username = '{username}'"); var connector = WebApiTestHelper.LoginHost(); var url = $"/API/PersonaBar/Users/UpdateAuthorizeStatus?userId={userId}&authorized=true"; @@ -62,11 +63,11 @@ public static IWebApiConnector PrepareNewUser(out int userId, out string usernam connector.Logout(); var userConnector = WebApiTestHelper.LoginUser(username); - userConnector.UploadUserFile("Files\\Test.png", true, userId); + await userConnector.UploadUserFile("Files\\Test.png", true, userId); - fileId = DatabaseHelper.ExecuteScalar($"SELECT MAX(FileId) FROM {{objectQualifier}}Files WHERE FileName = 'Test.png' AND CreatedByUserID = {userId} AND PortalId = {portalId}"); + var fileId = DatabaseHelper.ExecuteScalar($"SELECT MAX(FileId) FROM {{objectQualifier}}Files WHERE FileName = 'Test.png' AND CreatedByUserID = {userId} AND PortalId = {portalId}"); - return userConnector; + return (userConnector, userId, username, fileId); } /// Register a user by using the Registration form. diff --git a/DNN Platform/Tests/DNN.Integration.Test.Framework/IWebApiConnector.cs b/DNN Platform/Tests/DNN.Integration.Test.Framework/IWebApiConnector.cs index 654bf8bbf06..6865fe00c1e 100644 --- a/DNN Platform/Tests/DNN.Integration.Test.Framework/IWebApiConnector.cs +++ b/DNN Platform/Tests/DNN.Integration.Test.Framework/IWebApiConnector.cs @@ -1,14 +1,15 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information - +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information + namespace DNN.Integration.Test.Framework { using System; using System.Collections.Generic; using System.Net; using System.Net.Http; - + using System.Threading.Tasks; + public interface IWebApiConnector { int UserId { get; } @@ -33,11 +34,11 @@ public interface IWebApiConnector bool Login(string password); - HttpResponseMessage UploadUserFile(string fileName, bool waitHttpResponse = true, int userId = -1); + Task UploadUserFile(string fileName, bool waitHttpResponse = true, int userId = -1); HttpResponseMessage ActivityStreamUploadUserFile(IDictionary headers, string fileName); - bool UploadCmsFile(string fileName, string portalFolder); + Task UploadCmsFile(string fileName, string portalFolder); HttpResponseMessage PostJson( string relativeUrl, diff --git a/DNN Platform/Tests/DNN.Integration.Test.Framework/IntegrationTestBase.cs b/DNN Platform/Tests/DNN.Integration.Test.Framework/IntegrationTestBase.cs index 1b9b839bf2c..b04e78815f4 100644 --- a/DNN Platform/Tests/DNN.Integration.Test.Framework/IntegrationTestBase.cs +++ b/DNN Platform/Tests/DNN.Integration.Test.Framework/IntegrationTestBase.cs @@ -1,17 +1,18 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information - +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information + namespace DNN.Integration.Test.Framework { using System; using System.Globalization; using System.Net; using System.Threading; - + using System.Threading.Tasks; + using DNN.Integration.Test.Framework.Helpers; using NUnit.Framework; - + public abstract class IntegrationTestBase { // public static string DatabaseName { get; } @@ -42,8 +43,9 @@ public static void LogText(string text) } [OneTimeSetUp] - public virtual void TestFixtureSetUp() + public virtual async Task TestFixtureSetUp() { + await Task.Yield(); } [OneTimeTearDown] diff --git a/DNN Platform/Tests/DNN.Integration.Test.Framework/WebApiConnector.cs b/DNN Platform/Tests/DNN.Integration.Test.Framework/WebApiConnector.cs index 21df1fa6016..3996d91a699 100644 --- a/DNN Platform/Tests/DNN.Integration.Test.Framework/WebApiConnector.cs +++ b/DNN Platform/Tests/DNN.Integration.Test.Framework/WebApiConnector.cs @@ -15,6 +15,7 @@ namespace DNN.Integration.Test.Framework using System.Net.Http.Headers; using System.Text; using System.Text.RegularExpressions; + using System.Threading.Tasks; using System.Web; using System.Xml; using System.Xml.Linq; @@ -214,7 +215,10 @@ public bool Login(string password) return this.IsLoggedIn; } - public HttpResponseMessage UploadUserFile(string fileName, bool waitHttpResponse = true, int userId = -1) + public async Task UploadUserFile( + string fileName, + bool waitHttpResponse = true, + int userId = -1) { this.EnsureLoggedIn(); @@ -226,7 +230,7 @@ public HttpResponseMessage UploadUserFile(string fileName, bool waitHttpResponse folder = $"Users/{rootFolder}/{subFolder}/{userId}/"; } - return this.UploadFile(fileName, folder, waitHttpResponse); + return await this.UploadFile(fileName, folder, waitHttpResponse); } public HttpResponseMessage ActivityStreamUploadUserFile(IDictionary headers, string fileName) @@ -235,10 +239,10 @@ public HttpResponseMessage ActivityStreamUploadUserFile(IDictionary UploadCmsFile(string fileName, string portalFolder) { this.EnsureLoggedIn(); - var result = this.UploadFile(fileName, portalFolder); + var result = await this.UploadFile(fileName, portalFolder); return result.IsSuccessStatusCode; } @@ -713,7 +717,7 @@ private void ExtractVerificationCookie(string cookiesString) } } - private HttpResponseMessage UploadFile(string fileName, string portalFolder, bool waitHttpResponse = true) + private async Task UploadFile(string fileName, string portalFolder, bool waitHttpResponse = true) { using (var client = this.CreateHttpClient("/", true)) { @@ -724,8 +728,8 @@ private HttpResponseMessage UploadFile(string fileName, string portalFolder, boo if (string.IsNullOrEmpty(this._inputFieldVerificationToken)) { - var resultGet = client.GetAsync("/").Result; - var data = resultGet.Content.ReadAsStringAsync().Result; + var resultGet = await client.GetAsync("/"); + var data = await resultGet.Content.ReadAsStringAsync(); this._inputFieldVerificationToken = GetVerificationToken(data); if (!string.IsNullOrEmpty(this._inputFieldVerificationToken)) @@ -762,7 +766,7 @@ private HttpResponseMessage UploadFile(string fileName, string portalFolder, boo content.Add(fileContent); client.DefaultRequestHeaders.UserAgent.ParseAdd(this.UserAgentValue); - var result = client.PostAsync(UploadFileRequestPath, content).Result; + var result = await client.PostAsync(UploadFileRequestPath, content); return !waitHttpResponse ? result : EnsureSuccessResponse(result, "UploadFile", UploadFileRequestPath); diff --git a/DNN Platform/Tests/DNN.Integration.Test.Framework/packages.config b/DNN Platform/Tests/DNN.Integration.Test.Framework/packages.config deleted file mode 100644 index 591219350fa..00000000000 --- a/DNN Platform/Tests/DNN.Integration.Test.Framework/packages.config +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/DNN Platform/Tests/DotNetNuke.Tests.AspNetCCP/App.config b/DNN Platform/Tests/DotNetNuke.Tests.AspNetCCP/App.config deleted file mode 100644 index 8baca4e5753..00000000000 --- a/DNN Platform/Tests/DotNetNuke.Tests.AspNetCCP/App.config +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/DNN Platform/Tests/DotNetNuke.Tests.AspNetCCP/DotNetNuke.Tests.AspNetCCP.csproj b/DNN Platform/Tests/DotNetNuke.Tests.AspNetCCP/DotNetNuke.Tests.AspNetCCP.csproj index 026ffa5e5b8..38609b7ceb6 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.AspNetCCP/DotNetNuke.Tests.AspNetCCP.csproj +++ b/DNN Platform/Tests/DotNetNuke.Tests.AspNetCCP/DotNetNuke.Tests.AspNetCCP.csproj @@ -1,206 +1,44 @@ - - - - - - - + + - Debug - AnyCPU - 8.0.30703 - 2.0 - {64BA74E9-411E-4DC1-91CB-DEF7F22468AD} - Library - Properties - DotNetNuke.Tests.AspNetClientCapabilityProviderTest - DotNetNuke.Tests.AspNetClientCapabilityProviderTest - v4.8 - 512 - true - true - - - - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - SA0001 + net48 + false latest true - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 SA0001 - latest - true + false + - - ..\..\..\packages\Castle.Core.5.1.1\lib\net462\Castle.Core.dll - - - ..\..\..\packages\Microsoft.ApplicationInsights.2.22.0\lib\net46\Microsoft.ApplicationInsights.dll - - - ..\..\..\packages\Microsoft.Testing.Platform.MSBuild.1.6.0\lib\netstandard2.0\Microsoft.Testing.Extensions.MSBuild.dll - - - ..\..\..\packages\Microsoft.Testing.Extensions.Telemetry.1.6.0\lib\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.dll - - - ..\..\..\packages\Microsoft.Testing.Extensions.TrxReport.Abstractions.1.6.0\lib\netstandard2.0\Microsoft.Testing.Extensions.TrxReport.Abstractions.dll - - - ..\..\..\packages\Microsoft.Testing.Extensions.VSTestBridge.1.6.0\lib\netstandard2.0\Microsoft.Testing.Extensions.VSTestBridge.dll - - - ..\..\..\packages\Microsoft.Testing.Platform.1.6.0\lib\netstandard2.0\Microsoft.Testing.Platform.dll - - - ..\..\..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.TestPlatform.CoreUtilities.dll - - - ..\..\..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.TestPlatform.PlatformAbstractions.dll - - - ..\..\..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll - - - ..\..\..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll - True - - - ..\..\..\packages\Moq.4.20.72\lib\net462\Moq.dll - True - - - ..\..\..\packages\NUnit.4.3.2\lib\net462\nunit.framework.dll - - - ..\..\..\packages\NUnit.4.3.2\lib\net462\nunit.framework.legacy.dll - - - - ..\..\..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll - - - ..\..\..\packages\System.Collections.Immutable.9.0.2\lib\net462\System.Collections.Immutable.dll - - - - - ..\..\..\packages\System.Diagnostics.DiagnosticSource.9.0.2\lib\net462\System.Diagnostics.DiagnosticSource.dll - - - ..\..\..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll - - - - - ..\..\..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll - - - ..\..\..\packages\System.Reflection.Metadata.9.0.2\lib\net462\System.Reflection.Metadata.dll - - - - ..\..\..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll - - - - ..\..\..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll - - - ..\..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll - - - - - - - - - - - - - - - - {6928a9b1-f88a-4581-a132-d3eb38669bb0} - DotNetNuke.Abstractions - - - {DDF18E36-41A0-4CA7-A098-78CA6E6F41C1} - DotNetNuke.Instrumentation - - - {6b29aded-7b56-4484-bea5-c0e09079535b} - DotNetNuke.Library - - - {a3b3f1e8-6c1a-4e35-a5b4-51ecc5a43af7} - DotNetNuke.Providers.AspNetCCP - - - {5AECE021-E449-4A7F-BF82-2FA7B236ED3E} - DotNetNuke.Tests.Utilities - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + - - stylecop.json - - - Designer - - - - - + + - - - + + + + + + + - + - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/DNN Platform/Tests/DotNetNuke.Tests.AspNetCCP/ILLink/ILLink.Descriptors.LibraryBuild.xml b/DNN Platform/Tests/DotNetNuke.Tests.AspNetCCP/ILLink/ILLink.Descriptors.LibraryBuild.xml deleted file mode 100644 index 3d583f85b3a..00000000000 --- a/DNN Platform/Tests/DotNetNuke.Tests.AspNetCCP/ILLink/ILLink.Descriptors.LibraryBuild.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/DNN Platform/Tests/DotNetNuke.Tests.AspNetCCP/packages.config b/DNN Platform/Tests/DotNetNuke.Tests.AspNetCCP/packages.config deleted file mode 100644 index ac45c45472a..00000000000 --- a/DNN Platform/Tests/DotNetNuke.Tests.AspNetCCP/packages.config +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Authentication/DotNetNuke.Tests.Authentication.csproj b/DNN Platform/Tests/DotNetNuke.Tests.Authentication/DotNetNuke.Tests.Authentication.csproj index 8225813110e..37ed6d9a6b2 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Authentication/DotNetNuke.Tests.Authentication.csproj +++ b/DNN Platform/Tests/DotNetNuke.Tests.Authentication/DotNetNuke.Tests.Authentication.csproj @@ -1,226 +1,41 @@ - - - - - - - + + - Debug - AnyCPU - 9.0.30729 - 2.0 - {0E8502FD-DE8B-46A5-AB96-B1BE39777917} - Library - Properties - DotNetNuke.Tests.Authentication - DotNetNuke.Tests.Authentication - v4.8 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - - - - - 4.0 - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - ..\..\..\ - true - true - - - - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - AllRules.ruleset - 1591,SA0001 + net48 + false latest true - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - AllRules.ruleset 1591,SA0001 - latest - true + false + - - ..\..\..\packages\Castle.Core.5.1.1\lib\net462\Castle.Core.dll - - - ..\..\..\packages\Microsoft.ApplicationInsights.2.22.0\lib\net46\Microsoft.ApplicationInsights.dll - - - - ..\..\..\packages\Microsoft.Testing.Platform.MSBuild.1.6.0\lib\netstandard2.0\Microsoft.Testing.Extensions.MSBuild.dll - - - ..\..\..\packages\Microsoft.Testing.Extensions.Telemetry.1.6.0\lib\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.dll - - - ..\..\..\packages\Microsoft.Testing.Extensions.TrxReport.Abstractions.1.6.0\lib\netstandard2.0\Microsoft.Testing.Extensions.TrxReport.Abstractions.dll - - - ..\..\..\packages\Microsoft.Testing.Extensions.VSTestBridge.1.6.0\lib\netstandard2.0\Microsoft.Testing.Extensions.VSTestBridge.dll - - - ..\..\..\packages\Microsoft.Testing.Platform.1.6.0\lib\netstandard2.0\Microsoft.Testing.Platform.dll - - - ..\..\..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.TestPlatform.CoreUtilities.dll - - - ..\..\..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.TestPlatform.PlatformAbstractions.dll - - - ..\..\..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll - - - ..\..\..\packages\Moq.4.20.72\lib\net462\Moq.dll - True - - - ..\..\..\packages\NUnit.4.3.2\lib\net462\nunit.framework.dll - - - ..\..\..\packages\NUnit.4.3.2\lib\net462\nunit.framework.legacy.dll - - - - ..\..\..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll - - - ..\..\..\packages\System.Collections.Immutable.9.0.2\lib\net462\System.Collections.Immutable.dll - - - - - - ..\..\..\packages\System.Diagnostics.DiagnosticSource.9.0.2\lib\net462\System.Diagnostics.DiagnosticSource.dll - - - ..\..\..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll - - - - - ..\..\..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll - - - ..\..\..\packages\System.Reflection.Metadata.9.0.2\lib\net462\System.Reflection.Metadata.dll - - - - ..\..\..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll - - - - ..\..\..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll - - - ..\..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll - - - - - - - - - - - - - - - - {6b29aded-7b56-4484-bea5-c0e09079535b} - DotNetNuke.Library - - - {07e655de-0dd2-4874-bb0c-e818d24c9b59} - DotNetNuke.Authentication.Facebook - - - {0304b44c-ea08-434e-a368-65f619fc67a5} - DotNetNuke.Authentication.Google - - - {46924a38-cab7-485d-9301-191e35f6255f} - DotNetNuke.Authentication.LiveConnect - - - {1c882aa9-2198-41ef-b325-605340fdefe5} - DotNetNuke.Authentication.Twitter - - - - - - - - stylecop.json - - - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + - - - + + + + + + + + - + - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Authentication/ILLink/ILLink.Descriptors.LibraryBuild.xml b/DNN Platform/Tests/DotNetNuke.Tests.Authentication/ILLink/ILLink.Descriptors.LibraryBuild.xml deleted file mode 100644 index 3d583f85b3a..00000000000 --- a/DNN Platform/Tests/DotNetNuke.Tests.Authentication/ILLink/ILLink.Descriptors.LibraryBuild.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Authentication/app.config b/DNN Platform/Tests/DotNetNuke.Tests.Authentication/app.config deleted file mode 100644 index dad094e3d73..00000000000 --- a/DNN Platform/Tests/DotNetNuke.Tests.Authentication/app.config +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Authentication/packages.config b/DNN Platform/Tests/DotNetNuke.Tests.Authentication/packages.config deleted file mode 100644 index ac45c45472a..00000000000 --- a/DNN Platform/Tests/DotNetNuke.Tests.Authentication/packages.config +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Content/DotNetNuke.Tests.Content.csproj b/DNN Platform/Tests/DotNetNuke.Tests.Content/DotNetNuke.Tests.Content.csproj index 54fdfc17fcd..cb947b411cc 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Content/DotNetNuke.Tests.Content.csproj +++ b/DNN Platform/Tests/DotNetNuke.Tests.Content/DotNetNuke.Tests.Content.csproj @@ -1,246 +1,45 @@ - - - - - - - + + - Debug - AnyCPU - 9.0.30729 - 2.0 - {22A67B3F-D9B6-4447-A3F7-E387075AF969} - Library - Properties - DotNetNuke.Tests.Content - DotNetNuke.Tests.Content - v4.8 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - - - - - 4.0 - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - true - true - - - - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - AllRules.ruleset - 1591,SA0001 + net48 + false latest true - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - AllRules.ruleset 1591,SA0001 - latest - true + false + - - ..\..\..\packages\Castle.Core.5.1.1\lib\net462\Castle.Core.dll - - - ..\..\..\packages\Microsoft.ApplicationInsights.2.22.0\lib\net46\Microsoft.ApplicationInsights.dll - - - ..\..\..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll - - - - ..\..\..\packages\Microsoft.Extensions.DependencyInjection.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.dll - - - ..\..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll - - - ..\..\..\packages\Microsoft.Testing.Platform.MSBuild.1.6.0\lib\netstandard2.0\Microsoft.Testing.Extensions.MSBuild.dll - - - ..\..\..\packages\Microsoft.Testing.Extensions.Telemetry.1.6.0\lib\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.dll - - - ..\..\..\packages\Microsoft.Testing.Extensions.TrxReport.Abstractions.1.6.0\lib\netstandard2.0\Microsoft.Testing.Extensions.TrxReport.Abstractions.dll - - - ..\..\..\packages\Microsoft.Testing.Extensions.VSTestBridge.1.6.0\lib\netstandard2.0\Microsoft.Testing.Extensions.VSTestBridge.dll - - - ..\..\..\packages\Microsoft.Testing.Platform.1.6.0\lib\netstandard2.0\Microsoft.Testing.Platform.dll - - - ..\..\..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.TestPlatform.CoreUtilities.dll - - - ..\..\..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.TestPlatform.PlatformAbstractions.dll - - - ..\..\..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll - - - ..\..\..\packages\Moq.4.20.72\lib\net462\Moq.dll - True - - - ..\..\..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll - - - ..\..\..\packages\NUnit.4.3.2\lib\net462\nunit.framework.dll - - - ..\..\..\packages\NUnit.4.3.2\lib\net462\nunit.framework.legacy.dll - - - - ..\..\..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll - - - ..\..\..\packages\System.Collections.Immutable.9.0.2\lib\net462\System.Collections.Immutable.dll - - - - - - ..\..\..\packages\System.Diagnostics.DiagnosticSource.9.0.2\lib\net462\System.Diagnostics.DiagnosticSource.dll - - - ..\..\..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll - - - - - ..\..\..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll - - - ..\..\..\packages\System.Reflection.Metadata.9.0.2\lib\net462\System.Reflection.Metadata.dll - - - - ..\..\..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll - - - - ..\..\..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll - - - ..\..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll - - - - - - - - - - - - - Code - - - - - - - - {6928A9B1-F88A-4581-A132-D3EB38669BB0} - DotNetNuke.Abstractions - - - {04f77171-0634-46e0-a95e-d7477c88712e} - DotNetNuke.Log4Net - - - {B1699614-39D4-468A-AB1D-A2FBA97CADDF} - DotNetNuke.Web - - - {6b29aded-7b56-4484-bea5-c0e09079535b} - DotNetNuke.Library - - - {2595aade-d3e0-4205-b8af-109cb23f4223} - DotNetNuke.Tests.Data - - - {68368906-57dd-40d1-ac10-35211a17d617} - DotNetNuke.Tests.Utilities - + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + - - - - - stylecop.json - - - + + - - - + + + + + + + - + - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Content/ILLink/ILLink.Descriptors.LibraryBuild.xml b/DNN Platform/Tests/DotNetNuke.Tests.Content/ILLink/ILLink.Descriptors.LibraryBuild.xml deleted file mode 100644 index 3d583f85b3a..00000000000 --- a/DNN Platform/Tests/DotNetNuke.Tests.Content/ILLink/ILLink.Descriptors.LibraryBuild.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Content/app.config b/DNN Platform/Tests/DotNetNuke.Tests.Content/app.config index 79f57edf61b..4fd8801fce0 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Content/app.config +++ b/DNN Platform/Tests/DotNetNuke.Tests.Content/app.config @@ -1,67 +1,11 @@  - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -71,32 +15,9 @@ - - - - - - - - - - - - - - - - - - - - - - + + - - - - + \ No newline at end of file diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Content/packages.config b/DNN Platform/Tests/DotNetNuke.Tests.Content/packages.config deleted file mode 100644 index 9bf2b97ab26..00000000000 --- a/DNN Platform/Tests/DotNetNuke.Tests.Content/packages.config +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Core/Collections/CollectionExtensionTests.cs b/DNN Platform/Tests/DotNetNuke.Tests.Core/Collections/CollectionExtensionTests.cs index 691f07c926f..78f4b6cd6ce 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Core/Collections/CollectionExtensionTests.cs +++ b/DNN Platform/Tests/DotNetNuke.Tests.Core/Collections/CollectionExtensionTests.cs @@ -16,6 +16,8 @@ namespace DotNetNuke.Tests.Core.Collections using DotNetNuke.Collections; using NUnit.Framework; + using CollectionExtensions = DotNetNuke.Collections.CollectionExtensions; + [TestFixture] public class CollectionExtensionTests { diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Core/Collections/LockStrategyTests.cs b/DNN Platform/Tests/DotNetNuke.Tests.Core/Collections/LockStrategyTests.cs index 5412cddc91f..365900595b6 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Core/Collections/LockStrategyTests.cs +++ b/DNN Platform/Tests/DotNetNuke.Tests.Core/Collections/LockStrategyTests.cs @@ -99,7 +99,7 @@ public void DoubleReadLockOnDifferentThreads() // assert that read thread has terminated Console.WriteLine(t.ThreadState.ToString()); - Assert.That(t.ThreadState == ThreadState.Stopped, Is.True); + Assert.That(t.ThreadState, Is.EqualTo(ThreadState.Stopped)); } } } diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Core/Collections/NaiveLockingListTests.cs b/DNN Platform/Tests/DotNetNuke.Tests.Core/Collections/NaiveLockingListTests.cs index e84042bf493..6af976270ba 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Core/Collections/NaiveLockingListTests.cs +++ b/DNN Platform/Tests/DotNetNuke.Tests.Core/Collections/NaiveLockingListTests.cs @@ -46,8 +46,8 @@ public void Contains() Assert.Multiple(() => { - Assert.That(list.Contains(2), Is.True); - Assert.That(list.Contains(9999), Is.False); + Assert.That(list, Has.Some.EqualTo(2)); + Assert.That(list, Has.None.EqualTo(9999)); }); } diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Core/Common/UrlUtilsTests.cs b/DNN Platform/Tests/DotNetNuke.Tests.Core/Common/UrlUtilsTests.cs index c4cde257057..a07cbe9ab0a 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Core/Common/UrlUtilsTests.cs +++ b/DNN Platform/Tests/DotNetNuke.Tests.Core/Common/UrlUtilsTests.cs @@ -102,7 +102,7 @@ public void EncodeParameterReplacesPaddingSymbols() public void EncryptParameterReplacesPaddingSymbols() { var result = UrlUtils.EncryptParameter("D", "key"); - Assert.That(result.EndsWith("%3d"), Is.True); + Assert.That(result, Does.EndWith("%3d")); } [Test] diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Core/Controllers/Messaging/NotificationsControllerTests.cs b/DNN Platform/Tests/DotNetNuke.Tests.Core/Controllers/Messaging/NotificationsControllerTests.cs index aee40293e54..2045844236f 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Core/Controllers/Messaging/NotificationsControllerTests.cs +++ b/DNN Platform/Tests/DotNetNuke.Tests.Core/Controllers/Messaging/NotificationsControllerTests.cs @@ -171,7 +171,7 @@ public void CreateNotificationType_Makes_Valid_Object() var actualNotificationType = CreateNewNotificationType(); this.mockNotificationsController.Object.CreateNotificationType(actualNotificationType); - Assert.That(new NotificationTypeComparer().Equals(expectedNotificationType, actualNotificationType), Is.True); + Assert.That(actualNotificationType, Is.EqualTo(expectedNotificationType).Using(new NotificationTypeComparer())); } [Test] @@ -240,7 +240,7 @@ public void GetNotificationType_By_Id_Returns_Valid_Object() var actualNotificationType = this.notificationsController.GetNotificationType(Constants.Messaging_NotificationTypeId); - Assert.That(new NotificationTypeComparer().Equals(expectedNotificationType, actualNotificationType), Is.True); + Assert.That(actualNotificationType, Is.EqualTo(expectedNotificationType).Using(new NotificationTypeComparer())); } [Test] @@ -297,7 +297,7 @@ public void GetNotificationType_By_Name_Returns_Valid_Object() var actualNotificationType = this.notificationsController.GetNotificationType(Constants.Messaging_NotificationTypeName); - Assert.That(new NotificationTypeComparer().Equals(expectedNotificationType, actualNotificationType), Is.True); + Assert.That(actualNotificationType, Is.EqualTo(expectedNotificationType).Using(new NotificationTypeComparer())); } [Test] @@ -384,9 +384,9 @@ public void SetNotificationTypeActions_Sets_NotificationTypeActionId_And_Notific .Returns(expectedNotificationTypeAction); var action = CreateNewNotificationTypeAction(); - this.mockNotificationsController.Object.SetNotificationTypeActions(new[] { action }, expectedNotificationTypeAction.NotificationTypeId); + this.mockNotificationsController.Object.SetNotificationTypeActions([action], expectedNotificationTypeAction.NotificationTypeId); - Assert.That(new NotificationTypeActionComparer().Equals(expectedNotificationTypeAction, action), Is.True); + Assert.That(action, Is.EqualTo(expectedNotificationTypeAction).Using(new NotificationTypeActionComparer())); } [Test] @@ -455,7 +455,7 @@ public void GetNotificationTypeAction_By_Id_Returns_Valid_Object() var actualNotificationTypeAction = this.notificationsController.GetNotificationTypeAction(Constants.Messaging_NotificationTypeActionId); - Assert.That(new NotificationTypeActionComparer().Equals(expectedNotificationTypeAction, actualNotificationTypeAction), Is.True); + Assert.That(actualNotificationTypeAction, Is.EqualTo(expectedNotificationTypeAction).Using(new NotificationTypeActionComparer())); } [Test] @@ -518,7 +518,7 @@ public void GetNotificationTypeAction_By_Name_Returns_Valid_Object() var actualNotificationTypeAction = this.notificationsController.GetNotificationTypeAction(Constants.Messaging_NotificationTypeId, Constants.Messaging_NotificationTypeActionNameResourceKey); - Assert.That(new NotificationTypeActionComparer().Equals(expectedNotificationTypeAction, actualNotificationTypeAction), Is.True); + Assert.That(actualNotificationTypeAction, Is.EqualTo(expectedNotificationTypeAction).Using(new NotificationTypeActionComparer())); } [Test] @@ -557,7 +557,7 @@ public void GetNotificationTypeActions_Returns_Valid_Object() Assert.Multiple(() => { Assert.That(actualNotificationTypeActions, Has.Count.EqualTo(1)); - Assert.That(new NotificationTypeActionComparer().Equals(expectedNotificationTypeAction, actualNotificationTypeActions[0]), Is.True); + Assert.That(actualNotificationTypeActions[0], Is.EqualTo(expectedNotificationTypeAction).Using(new NotificationTypeActionComparer())); }); } @@ -935,7 +935,7 @@ public void SendNotification_Returns_Valid_Object() roles, users); - Assert.That(new NotificationComparer().Equals(expectedNotification, notification), Is.True); + Assert.That(notification, Is.EqualTo(expectedNotification).Using(new NotificationComparer())); } [Test] diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Core/Controllers/Search/LuceneControllerTests.cs b/DNN Platform/Tests/DotNetNuke.Tests.Core/Controllers/Search/LuceneControllerTests.cs index b824c0f6ce1..226bd51d55d 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Core/Controllers/Search/LuceneControllerTests.cs +++ b/DNN Platform/Tests/DotNetNuke.Tests.Core/Controllers/Search/LuceneControllerTests.cs @@ -673,7 +673,7 @@ public void LuceneController_LockFileWhenExistsDoesNotCauseProblemForFirstIContr doc1.Add(new NumericField(fieldName, Field.Store.YES, true).SetIntValue(1)); // Assert - Assert.That(File.Exists(lockFile), Is.True); + Assert.That(lockFile, Does.Exist); Assert.DoesNotThrow(() => this.luceneController.Add(doc1)); } @@ -693,7 +693,7 @@ public void LuceneController_LockFileCanBeObtainedByOnlySingleController() var secondController = new LuceneControllerImpl(); // Assert - Assert.That(File.Exists(lockFile), Is.True); + Assert.That(lockFile, Does.Exist); Assert.Throws(() => secondController.Add(doc1)); } diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Core/Controllers/Search/SearchControllerTests.cs b/DNN Platform/Tests/DotNetNuke.Tests.Core/Controllers/Search/SearchControllerTests.cs index d75eb9893fe..8422b00104a 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Core/Controllers/Search/SearchControllerTests.cs +++ b/DNN Platform/Tests/DotNetNuke.Tests.Core/Controllers/Search/SearchControllerTests.cs @@ -397,7 +397,7 @@ public void SearchController_SearchFindsAnalyzedVeryLongWords() { // Assert Assert.That(search.Results, Has.Count.EqualTo(1)); - Assert.That(this.StipEllipses(search.Results[0].Snippet).Trim(), Is.EqualTo("" + veryLongWord + "")); + Assert.That(StripEllipses(search.Results[0].Snippet).Trim(), Is.EqualTo("" + veryLongWord + "")); }); } @@ -905,13 +905,13 @@ public void SearchController_GetsHighlightedDesc() { // Arrange string[] docs = - { + [ Line1, Line2, Line3, Line4, - Line5, - }; + Line5 + ]; this.AddLinesAsSearchDocs(docs); // Act @@ -922,15 +922,16 @@ public void SearchController_GetsHighlightedDesc() // Assert Assert.That(search.Results, Has.Count.EqualTo(docs.Length)); Assert.That( - new[] - { - "brown fox jumps over the lazy dog", - "quick fox jumps over the black dog - Italian", - "gold fox jumped over the lazy black dog", - "e red fox jumped over the lazy dark gray dog", - "quick fox jumps over the white dog - los de el Espana", - }.SequenceEqual(search.Results.Select(r => this.StipEllipses(r.Snippet))), - Is.True, + search.Results.Select(r => StripEllipses(r.Snippet)), + Is.EqualTo( + [ + "brown fox jumps over the lazy dog", + "quick fox jumps over the black dog - Italian", + "gold fox jumped over the lazy black dog", + "e red fox jumped over the lazy dark gray dog", + "quick fox jumps over the white dog - los de el Espana", + ]) + .AsCollection, "Found: " + string.Join(Environment.NewLine, search.Results.Select(r => r.Snippet))); }); } @@ -1789,12 +1790,12 @@ public void SearchController_SearchFindsAccentedAndNonAccentedWords() { // Assert Assert.That(searches1.TotalHits, Is.EqualTo(2)); - Assert.That(this.StipEllipses(searches1.Results[0].Snippet).Trim(), Is.EqualTo("zèbre or panthère")); - Assert.That(this.StipEllipses(searches1.Results[1].Snippet).Trim(), Is.EqualTo("zebre without accent")); + Assert.That(StripEllipses(searches1.Results[0].Snippet).Trim(), Is.EqualTo("zèbre or panthère")); + Assert.That(StripEllipses(searches1.Results[1].Snippet).Trim(), Is.EqualTo("zebre without accent")); Assert.That(searches2.TotalHits, Is.EqualTo(2)); - Assert.That(this.StipEllipses(searches2.Results[0].Snippet).Trim(), Is.EqualTo("zèbre or panthère")); - Assert.That(this.StipEllipses(searches2.Results[1].Snippet).Trim(), Is.EqualTo("zebre without accent")); + Assert.That(StripEllipses(searches2.Results[0].Snippet).Trim(), Is.EqualTo("zèbre or panthère")); + Assert.That(StripEllipses(searches2.Results[1].Snippet).Trim(), Is.EqualTo("zebre without accent")); }); } @@ -1820,8 +1821,8 @@ public void SearchController_PorterFilterTest() Assert.That(search1.TotalHits, Is.EqualTo(1)); Assert.That(search2.TotalHits, Is.EqualTo(1)); - Assert.That(this.StipEllipses(search1.Results[0].Snippet).Trim(), Is.EqualTo("" + lines[0] + "")); - Assert.That(this.StipEllipses(search2.Results[0].Snippet).Trim(), Is.EqualTo("" + lines[1] + "")); + Assert.That(StripEllipses(search1.Results[0].Snippet).Trim(), Is.EqualTo("" + lines[0] + "")); + Assert.That(StripEllipses(search2.Results[0].Snippet).Trim(), Is.EqualTo("" + lines[1] + "")); }); } @@ -1846,9 +1847,9 @@ public void SearchController_SearchFindsStemmedWords() { // Assert Assert.That(search.TotalHits, Is.EqualTo(3)); - Assert.That(this.StipEllipses(search.Results[0].Snippet), Is.EqualTo("I ride my bike to work")); - Assert.That(this.StipEllipses(search.Results[1].Snippet), Is.EqualTo("m are riding their bikes")); - Assert.That(this.StipEllipses(search.Results[2].Snippet), Is.EqualTo("e boy rides his bike to school")); + Assert.That(StripEllipses(search.Results[0].Snippet), Is.EqualTo("I ride my bike to work")); + Assert.That(StripEllipses(search.Results[1].Snippet), Is.EqualTo("m are riding their bikes")); + Assert.That(StripEllipses(search.Results[2].Snippet), Is.EqualTo("e boy rides his bike to school")); }); } @@ -1864,7 +1865,7 @@ public void SearchController_Search_Synonym_Works() // Assert Assert.That(search.TotalHits, Is.EqualTo(added)); - var snippets = search.Results.Select(result => this.StipEllipses(result.Snippet)).OrderBy(s => s).ToArray(); + var snippets = search.Results.Select(result => StripEllipses(result.Snippet)).OrderBy(s => s).ToArray(); Assert.Multiple(() => { Assert.That(snippets[0], Is.EqualTo("brown fox jumps over the lazy dog")); @@ -2620,6 +2621,11 @@ private static R ExecuteWithTimeout(Func proc, TimeSpan timeout) return r; // ah! } + private static string StripEllipses(string text) + { + return text.Replace("...", string.Empty).Trim(); + } + private void CreateNewLuceneControllerInstance(bool reCreate = false) { InternalSearchController.SetTestableInstance(new InternalSearchControllerImpl()); @@ -3098,11 +3104,6 @@ private SearchResults SearchForKeywordInModule(string keyword, int searchTypeId return this.searchController.SiteSearch(query); } - private string StipEllipses(string text) - { - return text.Replace("...", string.Empty).Trim(); - } - /// /// Sets up some data for testing security trimming. /// In the tests below, the users will have access to the follwoing documents diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Core/DotNetNuke.Tests.Core.csproj b/DNN Platform/Tests/DotNetNuke.Tests.Core/DotNetNuke.Tests.Core.csproj index 832143c05db..d423f0a431b 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Core/DotNetNuke.Tests.Core.csproj +++ b/DNN Platform/Tests/DotNetNuke.Tests.Core/DotNetNuke.Tests.Core.csproj @@ -1,477 +1,59 @@ - - - - - - - + + - Debug - AnyCPU - 9.0.30729 - 2.0 - {BCA9AC2A-1DF7-4697-8836-452E13E7CAFA} - Library - Properties - DotNetNuke.Tests.Core - DotNetNuke.Tests.Core - v4.8 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - - - - - 4.0 - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - true - true - - - - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - AllRules.ruleset - 1591, 0618,SA0001 - latest - true - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - AllRules.ruleset - 1591, 0618,SA0001 + net48 + false latest true + 1591,0618,SA0001 + false + - - ..\..\..\packages\Castle.Core.5.1.1\lib\net462\Castle.Core.dll - - - False - ..\..\DotNetNuke.Instrumentation\bin\DotNetNuke.Instrumentation.dll - - - False - ..\..\DotNetNuke.Log4net\bin\dotnetnuke.log4net.dll - - - ..\..\..\packages\SharpZipLib.1.4.2\lib\netstandard2.0\ICSharpCode.SharpZipLib.dll - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + ..\..\Components\Lucene.Net\bin\Lucene.Net.dll ..\..\Components\Lucene.Net.Contrib\bin\Lucene.Net.Contrib.Analyzers.dll - - False - ..\..\Components\Lucene.Net.Contrib\bin\Lucene.Net.Contrib.FastVectorHighlighter.dll - - - ..\..\..\packages\Microsoft.ApplicationInsights.2.22.0\lib\net46\Microsoft.ApplicationInsights.dll - - - ..\..\..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll - - - - ..\..\..\packages\Microsoft.Extensions.DependencyInjection.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.dll - - - ..\..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll - - - ..\..\..\packages\Microsoft.Testing.Platform.MSBuild.1.6.0\lib\netstandard2.0\Microsoft.Testing.Extensions.MSBuild.dll - - - ..\..\..\packages\Microsoft.Testing.Extensions.Telemetry.1.6.0\lib\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.dll - - - ..\..\..\packages\Microsoft.Testing.Extensions.TrxReport.Abstractions.1.6.0\lib\netstandard2.0\Microsoft.Testing.Extensions.TrxReport.Abstractions.dll - - - ..\..\..\packages\Microsoft.Testing.Extensions.VSTestBridge.1.6.0\lib\netstandard2.0\Microsoft.Testing.Extensions.VSTestBridge.dll - - - ..\..\..\packages\Microsoft.Testing.Platform.1.6.0\lib\netstandard2.0\Microsoft.Testing.Platform.dll - - - ..\..\..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.TestPlatform.CoreUtilities.dll - - - ..\..\..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.TestPlatform.PlatformAbstractions.dll - - - ..\..\..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll - - - ..\..\..\packages\Moq.4.20.72\lib\net462\Moq.dll - True - - - ..\..\..\packages\NUnit.4.3.2\lib\net462\nunit.framework.dll - - - ..\..\..\packages\NUnit.4.3.2\lib\net462\nunit.framework.legacy.dll - - - ..\..\Components\PetaPoco\bin\PetaPoco.dll - - - - ..\..\..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll - - - ..\..\..\packages\System.Collections.Immutable.9.0.2\lib\net462\System.Collections.Immutable.dll - - - - - - ..\..\..\packages\System.Diagnostics.DiagnosticSource.9.0.2\lib\net462\System.Diagnostics.DiagnosticSource.dll - - - - - ..\..\..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll - - - - - ..\..\..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll - - - ..\..\..\packages\System.Reflection.Metadata.9.0.2\lib\net462\System.Reflection.Metadata.dll - - - - ..\..\..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll - - - - ..\..\..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll - - - ..\..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll - - - - - - False - ..\..\Externals\AJAX\bin\System.Web.Extensions.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - + - - {6928A9B1-F88A-4581-A132-D3EB38669BB0} - DotNetNuke.Abstractions - - - {039BAFBD-E2DB-40C4-B565-C27467D9B5E1} - DotNetNuke.Web.Client.ResourceManager - - - {03e3afa5-ddc9-48fb-a839-ad4282ce237e} - DotNetNuke.Web.Client - - - {6b29aded-7b56-4484-bea5-c0e09079535b} - DotNetNuke.Library - - - {68368906-57dd-40d1-ac10-35211a17d617} - DotNetNuke.Tests.Utilities - + + + + + + + - + + - - stylecop.json - - - App.config - Designer - - + + Always - - - - - - - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - Designer - - - Always - Designer - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Core/Entities/Tabs/TabControllerTests.cs b/DNN Platform/Tests/DotNetNuke.Tests.Core/Entities/Tabs/TabControllerTests.cs index 3e1101704d4..2c5fc820749 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Core/Entities/Tabs/TabControllerTests.cs +++ b/DNN Platform/Tests/DotNetNuke.Tests.Core/Entities/Tabs/TabControllerTests.cs @@ -102,7 +102,7 @@ public void IsValidadTab_Returns_True_For_Regular_PageNames(string tabName) { // Assert Assert.That(isValid, Is.True, "A regular tab name is not allowed"); - Assert.That(invalidType, Is.EqualTo(string.Empty), "The invalidType is not the expected one"); + Assert.That(invalidType, Is.Empty, "The invalidType is not the expected one"); }); } } diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Core/EscapedStringTest.cs b/DNN Platform/Tests/DotNetNuke.Tests.Core/EscapedStringTest.cs index e10688830ae..c0f5d00eb9b 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Core/EscapedStringTest.cs +++ b/DNN Platform/Tests/DotNetNuke.Tests.Core/EscapedStringTest.cs @@ -2,151 +2,151 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information -namespace DotNetNuke.Tests.Core -{ - using System; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - using DotNetNuke.Common.Utilities; - using NUnit.Framework; - - [TestFixture] - public class EscapedStringTest - { - [Test] - public void SimpleCase() - { - this.DoTest(new[] { "first", "second" }, "first,second"); - } - - [Test] - public void CombinesWithSpecifiedSeperator() - { - string result = EscapedString.Combine(new[] { "first", "second" }, ';'); - - Assert.That(result, Is.EqualTo("first;second")); - } - - [Test] - public void SeperatesWithSpecifiedSeperator() - { - IEnumerable result = EscapedString.Seperate("first]second", ']'); - - Assert.That(result, Is.EqualTo(new[] { "first", "second" }).AsCollection); - } - - [Test] - public void EmbeddedSeperator() - { - this.DoTest(new[] { "fi,rst", "second" }, @"fi\,rst,second"); - } - - [Test] - public void DoubleSeperator() - { - this.DoTest(new[] { "fi,,rst", "second" }, @"fi\,\,rst,second"); - } - - [Test] - public void MultipleSeperators() - { - this.DoTest(new[] { "fi,rst", ",second," }, @"fi\,rst,\,second\,"); - } - - [Test] - public void EscapeCharacter() - { - this.DoTest(new[] { @"fi\rst", "second" }, @"fi\\rst,second"); - } - - [Test] - public void EmbeddedEscapeSequence() - { - this.DoTest(new[] { @"fi\,rst", "second" }, @"fi\\\,rst,second"); - } - - [Test] - public void CrazyContrivedStuff() - { - this.DoTest(new[] { @"\\\,,fi\,rst,,\,\\", "second" }, @"\\\\\\\,\,fi\\\,rst\,\,\\\,\\\\,second"); - } - - [Test] - public void EmptyElement() - { - this.DoTest(new[] { "first", string.Empty, "third" }, "first,,third"); - } - - [Test] - public void MultipleEmptyElements() - { - this.DoTest(new[] { string.Empty, string.Empty, string.Empty }, ",,"); - } - - [Test] - public void EmptyEnumerable() - { - this.DoTest(new object[] { }, string.Empty); - } - - [Test] - public void SingleElement() - { - this.DoTest(new[] { "only item here" }, "only item here"); - } - - [Test] - public void AllEscapeChars() - { - this.DoTest(new[] { @"\", @"\\", @"\\\" }, @"\\,\\\\,\\\\\\"); - } - - [Test] - public void AllSeperatorChars() - { - this.DoTest(new[] { ",", ",,", ",,," }, @"\,,\,\,,\,\,\,"); - } - - [Test] - public void AllEscapedSeperators() - { - this.DoTest(new[] { @"\,", @"\,\,", @"\,\,\," }, @"\\\,,\\\,\\\,,\\\,\\\,\\\,"); +namespace DotNetNuke.Tests.Core +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + using DotNetNuke.Common.Utilities; + using NUnit.Framework; + + [TestFixture] + public class EscapedStringTest + { + [Test] + public void SimpleCase() + { + DoTest(new[] { "first", "second" }, "first,second"); + } + + [Test] + public void CombinesWithSpecifiedSeparator() + { + string result = EscapedString.Combine(new[] { "first", "second" }, ';'); + + Assert.That(result, Is.EqualTo("first;second")); + } + + [Test] + public void SeparatesWithSpecifiedSeparator() + { + IEnumerable result = EscapedString.Seperate("first]second", ']'); + + Assert.That(result, Is.EqualTo(new[] { "first", "second" }).AsCollection); + } + + [Test] + public void EmbeddedSeparator() + { + DoTest(new[] { "fi,rst", "second" }, @"fi\,rst,second"); + } + + [Test] + public void DoubleSeparator() + { + DoTest(new[] { "fi,,rst", "second" }, @"fi\,\,rst,second"); + } + + [Test] + public void MultipleSeparators() + { + DoTest(new[] { "fi,rst", ",second," }, @"fi\,rst,\,second\,"); + } + + [Test] + public void EscapeCharacter() + { + DoTest(new[] { @"fi\rst", "second" }, @"fi\\rst,second"); + } + + [Test] + public void EmbeddedEscapeSequence() + { + DoTest(new[] { @"fi\,rst", "second" }, @"fi\\\,rst,second"); + } + + [Test] + public void CrazyContrivedStuff() + { + DoTest(new[] { @"\\\,,fi\,rst,,\,\\", "second" }, @"\\\\\\\,\,fi\\\,rst\,\,\\\,\\\\,second"); + } + + [Test] + public void EmptyElement() + { + DoTest(new[] { "first", string.Empty, "third" }, "first,,third"); + } + + [Test] + public void MultipleEmptyElements() + { + DoTest(new[] { string.Empty, string.Empty, string.Empty }, ",,"); + } + + [Test] + public void EmptyEnumerable() + { + DoTest(new object[] { }, string.Empty); + } + + [Test] + public void SingleElement() + { + DoTest(new[] { "only item here" }, "only item here"); + } + + [Test] + public void AllEscapeChars() + { + DoTest(new[] { @"\", @"\\", @"\\\" }, @"\\,\\\\,\\\\\\"); + } + + [Test] + public void AllSeparatorChars() + { + DoTest(new[] { ",", ",,", ",,," }, @"\,,\,\,,\,\,\,"); + } + + [Test] + public void AllEscapedSeparators() + { + DoTest(new[] { @"\,", @"\,\,", @"\,\,\," }, @"\\\,,\\\,\\\,,\\\,\\\,\\\,"); } [Test] public void TrimWhitespaces() { - this.SeperateTest( - new[] { "item1", "ite\nm2", "item3", "item4", "item5", "item6", "item7" }, "item1,ite\nm2,\nitem3, item4,item5\t,\r\nitem6,\vitem7", true); + SeparateTest( + ["item1", "ite\nm2", "item3", "item4", "item5", "item6", "item7"], "item1,ite\nm2,\nitem3, item4,item5\t,\r\nitem6,\vitem7", true); } [Test] public void KeepWhitespaces() { - this.SeperateTest( - new[] { "item1", "ite\nm2", "\nitem3", " item4", "item5\t", "\r\nitem6", "\vitem7" }, "item1,ite\nm2,\nitem3, item4,item5\t,\r\nitem6,\vitem7", false); - } - - private void DoTest(IEnumerable enumerable, string s) - { - this.CombineTest(enumerable, s); - this.SeperateTest(enumerable.Cast(), s); - } - - private void SeperateTest(IEnumerable expected, string data, bool trimWhitespaces = false) - { - var result = EscapedString.Seperate(data, trimWhitespaces); - - Assert.That(result, Is.EqualTo(expected).AsCollection); - } - - private void CombineTest(IEnumerable data, string expected) - { - string result = EscapedString.Combine(data); - - Assert.That(result, Is.EqualTo(expected)); - } - } -} + SeparateTest( + ["item1", "ite\nm2", "\nitem3", " item4", "item5\t", "\r\nitem6", "\vitem7"], "item1,ite\nm2,\nitem3, item4,item5\t,\r\nitem6,\vitem7", false); + } + + private static void DoTest(IEnumerable enumerable, string s) + { + CombineTest(enumerable, s); + SeparateTest(enumerable.Cast(), s); + } + + private static void SeparateTest(IEnumerable expected, string data, bool trimWhitespaces = false) + { + var result = EscapedString.Seperate(data, trimWhitespaces); + + Assert.That(result, Is.EqualTo(expected).AsCollection); + } + + private static void CombineTest(IEnumerable data, string expected) + { + string result = EscapedString.Combine(data); + + Assert.That(result, Is.EqualTo(expected)); + } + } +} diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Core/FileSystemUtilsTests.cs b/DNN Platform/Tests/DotNetNuke.Tests.Core/FileSystemUtilsTests.cs index 102e0ace17a..721c4ebab89 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Core/FileSystemUtilsTests.cs +++ b/DNN Platform/Tests/DotNetNuke.Tests.Core/FileSystemUtilsTests.cs @@ -18,7 +18,6 @@ namespace DotNetNuke.Tests.Core using NUnit.Framework; - /// FileSystemUtilsTests. [TestFixture] public class FileSystemUtilsTests { @@ -29,7 +28,7 @@ public void SetUp() { var applicationStatusInfo = new DotNetNuke.Application.ApplicationStatusInfo(Mock.Of()); var rootPath = Path.Combine(applicationStatusInfo.ApplicationMapPath, "FileSystemUtilsTest"); - this.PrepareRootPath(rootPath, applicationStatusInfo.ApplicationMapPath); + PrepareRootPath(rootPath, applicationStatusInfo.ApplicationMapPath); var mock = new Mock(); mock.Setup(info => info.ApplicationMapPath).Returns(rootPath); @@ -49,29 +48,29 @@ public void TearDown() [TestCase("/")] [TestCase("//")] [TestCase("///")] - [TestCase("\\")] - [TestCase("\\\\")] - [TestCase("\\\\\\")] + [TestCase(@"\")] + [TestCase(@"\\")] + [TestCase(@"\\\")] [TestCase("/Test/../")] [TestCase("/Test/mmm/../../")] - [TestCase("\\Test\\..\\")] - [TestCase("\\Test\\mmm\\..\\..\\")] - [TestCase("\\Test\\")] + [TestCase(@"\Test\..\")] + [TestCase(@"\Test\mmm\..\..\")] + [TestCase(@"\Test\")] [TestCase("..\\")] public void DeleteFiles_Should_Not_Able_To_Delete_Root_Folder(string path) { // Action - FileSystemUtils.DeleteFiles(new string[] { path }); + FileSystemUtils.DeleteFiles(new[] { path, }); var files = Directory.GetFiles(Globals.ApplicationMapPath, "*.*", SearchOption.AllDirectories); - Assert.That(files.Length, Is.GreaterThan(0)); + Assert.That(files, Is.Not.Empty); } [Test] public void AddToZip_Should_Able_To_Add_Multiple_Files() { // Action - this.DeleteZippedFiles(); + DeleteZippedFiles(); var zipFilePath = Path.Combine(Globals.ApplicationMapPath, $"Test{Guid.NewGuid().ToString().Substring(0, 8)}.zip"); var files = Directory.GetFiles(Globals.ApplicationMapPath, "*.*", SearchOption.TopDirectoryOnly); using (var stream = File.Create(zipFilePath)) @@ -108,8 +107,8 @@ public void AddToZip_Should_Able_To_Add_Multiple_Files() } finally { - this.DeleteZippedFiles(); - this.DeleteUnzippedFolder(destPath); + DeleteZippedFiles(); + DeleteUnzippedFolder(destPath); } } @@ -126,8 +125,7 @@ public void DeleteFile_Should_Delete_File() FileSystemUtils.DeleteFile(testPath); // Assert - bool res = File.Exists(testPath.Replace("/", "\\")); - Assert.That(res, Is.False); + Assert.That(testPath.Replace("/", "\\"), Does.Not.Exist); } [TestCase(null)] @@ -143,23 +141,21 @@ public void FixPath_Should_Change_Slashes_And_Trim(string input) // Assert if (string.IsNullOrEmpty(input)) { - Assert.That(input == result, Is.True); + Assert.That(result, Is.EqualTo(input)); } else if (string.IsNullOrWhiteSpace(input)) { - Assert.That(result == string.Empty, Is.True); + Assert.That(result, Is.Empty); } else { - Assert.Multiple(() => - { - Assert.That(result.Contains(" "), Is.False); - Assert.That(result.Contains("/"), Is.False); - }); + using var scope = Assert.EnterMultipleScope(); + Assert.That(result, Does.Not.Contain(" ")); + Assert.That(result, Does.Not.Contain("/")); } } - private void PrepareRootPath(string rootPath, string applicationMapPath) + private static void PrepareRootPath(string rootPath, string applicationMapPath) { if (!Directory.Exists(rootPath)) { @@ -168,11 +164,18 @@ private void PrepareRootPath(string rootPath, string applicationMapPath) foreach (var file in Directory.GetFiles(applicationMapPath, "*.*", SearchOption.TopDirectoryOnly)) { - File.Copy(file, Path.Combine(rootPath, Path.GetFileName(file)), true); + try + { + File.Copy(file, Path.Combine(rootPath, Path.GetFileName(file)), true); + } + catch (IOException e) + { + Console.WriteLine(e); + } } } - private void DeleteZippedFiles() + private static void DeleteZippedFiles() { var excludedFiles = Directory.GetFiles(Globals.ApplicationMapPath, "Test*", SearchOption.TopDirectoryOnly); foreach (var f in excludedFiles) @@ -188,7 +191,7 @@ private void DeleteZippedFiles() } } - private void DeleteUnzippedFolder(string zippedFolder) + private static void DeleteUnzippedFolder(string zippedFolder) { try { diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Core/ILLink/ILLink.Descriptors.LibraryBuild.xml b/DNN Platform/Tests/DotNetNuke.Tests.Core/ILLink/ILLink.Descriptors.LibraryBuild.xml deleted file mode 100644 index 3d583f85b3a..00000000000 --- a/DNN Platform/Tests/DotNetNuke.Tests.Core/ILLink/ILLink.Descriptors.LibraryBuild.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Core/Providers/Folder/FileManagerTests.cs b/DNN Platform/Tests/DotNetNuke.Tests.Core/Providers/Folder/FileManagerTests.cs index bf96e9e4366..e4fce1c63c6 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Core/Providers/Folder/FileManagerTests.cs +++ b/DNN Platform/Tests/DotNetNuke.Tests.Core/Providers/Folder/FileManagerTests.cs @@ -7,7 +7,6 @@ namespace DotNetNuke.Tests.Core.Providers.Folder using System.Data; using System.Drawing; using System.IO; - using System.Text; using DotNetNuke.Abstractions.Application; using DotNetNuke.Common.Internal; @@ -205,7 +204,7 @@ public void AddFile_Checks_Space_For_Stream_Length() this.folderInfo.Setup(fi => fi.FolderMappingID).Returns(Constants.FOLDER_ValidFolderMappingID); this.folderInfo.Setup(fi => fi.WorkflowID).Returns(Null.NullInteger); - var fileContent = new MemoryStream(Encoding.ASCII.GetBytes("some data here")); + var fileContent = new MemoryStream("some data here"u8.ToArray()); this.hostController.Setup(c => c.GetString("FileExtensions")).Returns(""); @@ -280,13 +279,11 @@ public void AddFile_Throws_When_File_Content_Is_Invalid(string fileName) { this.PrepareFileSecurityCheck(); - using (var fileContent = File.OpenRead(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"Resources/{fileName}"))) - { - this.portalController.Setup(pc => pc.HasSpaceAvailable(Constants.CONTENT_ValidPortalId, fileContent.Length)).Returns(true); - this.mockFileManager.Setup(mfm => mfm.IsAllowedExtension(Constants.FOLDER_ValidSvgFileName)).Returns(true); + using var fileContent = File.OpenRead(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"Resources/{fileName}")); + this.portalController.Setup(pc => pc.HasSpaceAvailable(Constants.CONTENT_ValidPortalId, fileContent.Length)).Returns(true); + this.mockFileManager.Setup(mfm => mfm.IsAllowedExtension(Constants.FOLDER_ValidSvgFileName)).Returns(true); - Assert.Throws(() => this.mockFileManager.Object.AddFile(this.folderInfo.Object, Constants.FOLDER_ValidSvgFileName, fileContent, false, false, Constants.CONTENTTYPE_ValidContentType)); - } + Assert.Throws(() => this.mockFileManager.Object.AddFile(this.folderInfo.Object, Constants.FOLDER_ValidSvgFileName, fileContent, false, false, Constants.CONTENTTYPE_ValidContentType)); } [TestCase("valid.svg")] @@ -297,19 +294,17 @@ public void AddFile_No_Error_When_File_Content_Is_Valid(string fileName) { this.PrepareFileSecurityCheck(); - using (var fileContent = File.OpenRead(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"Resources/{fileName}"))) - { - this.portalController.Setup(pc => pc.HasSpaceAvailable(Constants.CONTENT_ValidPortalId, fileContent.Length)).Returns(true); - this.mockFileManager.Setup(mfm => mfm.IsAllowedExtension(Constants.FOLDER_ValidSvgFileName)).Returns(true); - this.mockFileManager.Setup(mfm => mfm.IsImageFile(It.IsAny())).Returns(false); - this.hostController.Setup(c => c.GetString("FileExtensions")).Returns(""); + using var fileContent = File.OpenRead(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"Resources/{fileName}")); + this.portalController.Setup(pc => pc.HasSpaceAvailable(Constants.CONTENT_ValidPortalId, fileContent.Length)).Returns(true); + this.mockFileManager.Setup(mfm => mfm.IsAllowedExtension(Constants.FOLDER_ValidSvgFileName)).Returns(true); + this.mockFileManager.Setup(mfm => mfm.IsImageFile(It.IsAny())).Returns(false); + this.hostController.Setup(c => c.GetString("FileExtensions")).Returns(""); - this.mockFileManager.Object.AddFile(this.folderInfo.Object, Constants.FOLDER_ValidSvgFileName, fileContent, false, false, Constants.CONTENTTYPE_ValidContentType); - } + this.mockFileManager.Object.AddFile(this.folderInfo.Object, Constants.FOLDER_ValidSvgFileName, fileContent, false, false, Constants.CONTENTTYPE_ValidContentType); } [Test] - public void AddFile_Does_Not_Call_FolderProvider_AddFile_When_Not_Overwritting_And_File_Exists() + public void AddFile_Does_Not_Call_FolderProvider_AddFile_When_Not_Overwriting_And_File_Exists() { this.folderInfo.Setup(fi => fi.PortalID).Returns(Constants.CONTENT_ValidPortalId); this.folderInfo.Setup(fi => fi.FolderID).Returns(Constants.FOLDER_ValidFolderId); @@ -385,12 +380,12 @@ public void CopyFile_Throws_On_Null_DestinationFolder() public void CopyFile_Calls_FileManager_AddFile_When_FolderMapping_Of_Source_And_Destination_Folders_Are_Not_Equal() { // Arrange - const int sourceFolderMappingID = Constants.FOLDER_ValidFolderMappingID; - const int destinationFolderMappingID = Constants.FOLDER_ValidFolderMappingID + 1; + const int SourceFolderMappingId = Constants.FOLDER_ValidFolderMappingID; + const int DestinationFolderMappingId = Constants.FOLDER_ValidFolderMappingID + 1; this.fileInfo.Setup(fi => fi.FileName).Returns(Constants.FOLDER_ValidFileName); this.fileInfo.Setup(fi => fi.ContentType).Returns(Constants.CONTENTTYPE_ValidContentType); - this.fileInfo.Setup(fi => fi.FolderMappingID).Returns(sourceFolderMappingID); - this.folderInfo.Setup(fi => fi.FolderMappingID).Returns(destinationFolderMappingID); + this.fileInfo.Setup(fi => fi.FolderMappingID).Returns(SourceFolderMappingId); + this.folderInfo.Setup(fi => fi.FolderMappingID).Returns(DestinationFolderMappingId); var bytes = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; var fileContent = new MemoryStream(bytes); this.mockFileManager.Setup(mfm => mfm.GetFileContent(this.fileInfo.Object)).Returns(fileContent); @@ -444,7 +439,7 @@ public void DeleteFile_Calls_FileDeletionControllerDeleteFile() this.fileInfo.Setup(fi => fi.FolderId).Returns(Constants.FOLDER_ValidFolderId); this.fileInfo.Setup(fi => fi.FolderMappingID).Returns(Constants.FOLDER_ValidFolderMappingID); - this.mockFileDeletionController.Setup(mfdc => mfdc.DeleteFile(this.fileInfo.Object)).Verifiable(); + this.mockFileDeletionController.Setup(fdc => fdc.DeleteFile(this.fileInfo.Object)).Verifiable(); this.mockFileManager.Object.DeleteFile(this.fileInfo.Object); @@ -457,7 +452,7 @@ public void DeleteFile_Throws_WhenFileDeletionControllerThrows() this.fileInfo.Setup(fi => fi.PortalId).Returns(Constants.CONTENT_ValidPortalId); this.fileInfo.Setup(fi => fi.FolderId).Returns(Constants.FOLDER_ValidFolderId); - this.mockFileDeletionController.Setup(mfdc => mfdc.DeleteFile(this.fileInfo.Object)) + this.mockFileDeletionController.Setup(fdc => fdc.DeleteFile(this.fileInfo.Object)) .Throws(); Assert.Throws(() => this.mockFileManager.Object.DeleteFile(this.fileInfo.Object)); @@ -557,7 +552,7 @@ public void ExistsFile_Calls_FileManager_GetFile() this.folderInfo.Setup(fi => fi.PortalID).Returns(Constants.CONTENT_ValidPortalId); this.folderInfo.Setup(fi => fi.FolderID).Returns(Constants.FOLDER_ValidFolderId); - this.mockFileManager.Setup(mfm => mfm.GetFile(this.folderInfo.Object, Constants.FOLDER_ValidFileName, It.IsAny())).Returns(null).Verifiable(); + this.mockFileManager.Setup(mfm => mfm.GetFile(this.folderInfo.Object, Constants.FOLDER_ValidFileName, It.IsAny())).Returns(null!).Verifiable(); var folderMapping = new FolderMappingInfo { FolderProviderType = Constants.FOLDER_ValidFolderProviderType }; @@ -715,7 +710,7 @@ public void GetFileByID_Calls_DataCache_GetCache_First() [Test] public void GetFileByID_Calls_DataProvider_GetFileById_When_File_Is_Not_In_Cache() { - this.mockCache.Setup(mc => mc.GetItem(It.IsAny())).Returns(null); + this.mockCache.Setup(mc => mc.GetItem(It.IsAny())).Returns(null!); this.fileManager.GetFile(Constants.FOLDER_ValidFileId); @@ -751,7 +746,7 @@ public void MoveFile_Calls_FolderProvider_AddFile_And_DeleteFile_And_FileManager var fileContent = new MemoryStream(); this.mockFileManager.Setup(mfm => mfm.GetFileContent(this.fileInfo.Object)).Returns(fileContent); string someString; - this.mockFileLockingController.Setup(mflc => mflc.IsFileLocked(this.fileInfo.Object, out someString)).Returns(false); + this.mockFileLockingController.Setup(flc => flc.IsFileLocked(this.fileInfo.Object, out someString)).Returns(false); this.mockFileManager.Setup(mfm => mfm.MoveVersions(this.fileInfo.Object, It.IsAny(), It.IsAny(), It.IsAny())); this.mockFolder.Setup(mf => mf.AddFile(this.folderInfo.Object, Constants.FOLDER_ValidFileName, fileContent)).Verifiable(); this.mockFolder.Setup(mf => mf.DeleteFile(this.fileInfo.Object)).Verifiable(); @@ -791,7 +786,7 @@ public void MoveFile_Updates_FolderId_And_Folder() this.mockFileManager.Setup(mfm => mfm.GetFileContent(this.fileInfo.Object)).Returns(fileContent); string someString; - this.mockFileLockingController.Setup(mflc => mflc.IsFileLocked(this.fileInfo.Object, out someString)).Returns(false); + this.mockFileLockingController.Setup(flc => flc.IsFileLocked(this.fileInfo.Object, out someString)).Returns(false); this.mockFileManager.Setup(mfm => mfm.MoveVersions(this.fileInfo.Object, It.IsAny(), It.IsAny(), It.IsAny())); this.mockFileManager.Object.MoveFile(this.fileInfo.Object, this.folderInfo.Object); @@ -819,7 +814,7 @@ public void MoveFile_Calls_DeleteFile_When_A_File_With_The_Same_Name_Exists_On_T this.mockFileManager.Setup(mfm => mfm.GetFileContent(this.fileInfo.Object)).Returns(fileContent); string someString; - this.mockFileLockingController.Setup(mflc => mflc.IsFileLocked(this.fileInfo.Object, out someString)).Returns(false); + this.mockFileLockingController.Setup(flc => flc.IsFileLocked(this.fileInfo.Object, out someString)).Returns(false); this.mockFileManager.Setup(mfm => mfm.MoveVersions(this.fileInfo.Object, It.IsAny(), It.IsAny(), It.IsAny())); var existingFile = new FileInfo(); @@ -859,8 +854,7 @@ public void RenameFile_Calls_FolderProvider_RenameFile_When_FileNames_Are_Distin this.mockFileManager.Setup(mfm => mfm.FileExists(this.folderInfo.Object, Constants.FOLDER_OtherValidFileName, It.IsAny())).Returns(false); this.mockFileManager.Setup(mfm => mfm.UpdateFile(this.fileInfo.Object)); this.mockFileManager.Setup(mfm => mfm.IsAllowedExtension(Constants.FOLDER_OtherValidFileName)).Returns(true); - var folderMapping = new FolderMappingInfo(); - folderMapping.FolderProviderType = Constants.FOLDER_ValidFolderProviderType; + var folderMapping = new FolderMappingInfo { FolderProviderType = Constants.FOLDER_ValidFolderProviderType, }; this.folderMappingController.Setup(fmc => fmc.GetFolderMapping(Constants.CONTENT_ValidPortalId, Constants.FOLDER_ValidFolderMappingID)).Returns(folderMapping); // Act @@ -922,8 +916,7 @@ public void RenameFile_Throws_When_FolderProvider_Throws() this.mockFileManager.Setup(mfm => mfm.UpdateFile(this.fileInfo.Object)); this.mockFileManager.Setup(mfm => mfm.IsAllowedExtension(Constants.FOLDER_OtherValidFileName)).Returns(true); - var folderMapping = new FolderMappingInfo(); - folderMapping.FolderProviderType = Constants.FOLDER_ValidFolderProviderType; + var folderMapping = new FolderMappingInfo { FolderProviderType = Constants.FOLDER_ValidFolderProviderType, }; this.folderMappingController.Setup(fmc => fmc.GetFolderMapping(Constants.FOLDER_ValidFolderMappingID)).Returns(folderMapping); diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Core/Providers/Folder/StandardFolderProviderTests.cs b/DNN Platform/Tests/DotNetNuke.Tests.Core/Providers/Folder/StandardFolderProviderTests.cs index 3ec1ecc86f4..98e36dcf187 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Core/Providers/Folder/StandardFolderProviderTests.cs +++ b/DNN Platform/Tests/DotNetNuke.Tests.Core/Providers/Folder/StandardFolderProviderTests.cs @@ -601,7 +601,7 @@ public void GetFileUrl_ReturnsLinkclickUrl_WhenFileUrlContainsInvalidCharactes(s var fileUrl = sfp.Object.GetFileUrl(this.fileInfo.Object); // Assert - Assert.That(fileUrl.ToLowerInvariant().Contains("linkclick"), Is.True); + Assert.That(fileUrl, Does.Contain("linkclick").IgnoreCase); } [Test] diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Core/Providers/Membership/MembershipProviderTests.cs b/DNN Platform/Tests/DotNetNuke.Tests.Core/Providers/Membership/MembershipProviderTests.cs index c0233a6a1f5..bab93aa8528 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Core/Providers/Membership/MembershipProviderTests.cs +++ b/DNN Platform/Tests/DotNetNuke.Tests.Core/Providers/Membership/MembershipProviderTests.cs @@ -1,145 +1,151 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information - -namespace DotNetNuke.Tests.Core.Providers.Membership -{ - using System; - using System.Reflection; - using System.Web; - - using DotNetNuke.Common; - using DotNetNuke.Common.Utilities; - using DotNetNuke.ComponentModel; - using DotNetNuke.Data; - using DotNetNuke.Entities.Portals; - using DotNetNuke.Entities.Users; - using DotNetNuke.Entities.Users.Membership; - using DotNetNuke.Security.Membership; - using DotNetNuke.Security.Profile; - using DotNetNuke.Security.Roles; - using DotNetNuke.Services.Cache; - using DotNetNuke.Services.Log.EventLog; - using DotNetNuke.Tests.Utilities; - using NUnit.Framework; - - [TestFixture] - public class MembershipProviderTests : DnnUnitTest - { - [SetUp] - public void SetUp() - { - Globals.SetStatus(Globals.UpgradeStatus.None); - - ComponentFactory.Container = new SimpleContainer(); - ComponentFactory.InstallComponents(new ProviderInstaller("data", typeof(DataProvider), typeof(SqlDataProvider))); - ComponentFactory.InstallComponents(new ProviderInstaller("caching", typeof(CachingProvider), typeof(FBCachingProvider))); - ComponentFactory.InstallComponents(new ProviderInstaller("logging", typeof(LoggingProvider), typeof(DBLoggingProvider))); - ComponentFactory.InstallComponents(new ProviderInstaller("members", typeof(MembershipProvider), typeof(AspNetMembershipProvider))); - ComponentFactory.InstallComponents(new ProviderInstaller("roles", typeof(RoleProvider), typeof(DNNRoleProvider))); - ComponentFactory.InstallComponents(new ProviderInstaller("profiles", typeof(ProfileProvider), typeof(DNNProfileProvider))); - ComponentFactory.RegisterComponent(); - - PortalController.ClearInstance(); - UserController.ClearInstance(); - RoleController.ClearInstance(); - - var roleController = RoleController.Instance; - var roleProviderField = roleController.GetType().GetField("provider", BindingFlags.NonPublic | BindingFlags.Static); - if (roleProviderField != null) - { - roleProviderField.SetValue(roleController, RoleProvider.Instance()); - } - - var membershipType = typeof(System.Web.Security.Membership); - var initializedDefaultProviderField = membershipType.GetField("s_InitializedDefaultProvider", BindingFlags.NonPublic | BindingFlags.Static); - var defaultProviderField = membershipType.GetField("s_Provider", BindingFlags.NonPublic | BindingFlags.Static); - if (initializedDefaultProviderField != null - && defaultProviderField != null - && (bool)initializedDefaultProviderField.GetValue(null) == false) - { - initializedDefaultProviderField.SetValue(null, true); - defaultProviderField.SetValue(null, System.Web.Security.Membership.Providers["AspNetSqlMembershipProvider"]); - } - } - - [TearDown] - public void TearDown() - { - } - - // Note: this is the only test in core unit testing project that requires a working db connection to run. - [Test] - [Ignore("TODO: Must be moved to integration tests.")] - public void Password_Should_Saved_In_History_During_Create_User() - { - var user = CreateNewUser(); - - var simulator = new Instance.Utilities.HttpSimulator.HttpSimulator("/", AppDomain.CurrentDomain.BaseDirectory); - simulator.SimulateRequest(new Uri(this.WebsiteAppPath)); - HttpContextBase httpContextBase = new HttpContextWrapper(HttpContext.Current); - HttpContextSource.RegisterInstance(httpContextBase); - - var isPasswordInHistory = new MembershipPasswordController().IsPasswordInHistory(user.UserID, user.PortalID, user.Membership.Password); - - Assert.That(isPasswordInHistory, Is.EqualTo(true)); - } - - [Test] - [Ignore("The reasons have been lost to the sands of time…")] - public void ChangeUserName_Should_Success_With_Valid_Username() - { - var user = CreateNewUser(); - - var newUsername = $"{user.Username}_new"; - UserController.ChangeUsername(user.UserID, newUsername); - } - - [TestCase("