From 777207f314ad1451269cfbb578a2e12f37243bb1 Mon Sep 17 00:00:00 2001 From: Brian Dukes Date: Tue, 15 Dec 2020 16:47:23 -0600 Subject: [PATCH] Turn on TreatWarningsAsErrors for test projects --- .../DNN.Integration.Test.Framework.csproj | 17 +- .../DotNetNuke.Tests.AspNetCCP.csproj | 15 +- .../DotNetNuke.Tests.Authentication.csproj | 5 +- .../DotNetNuke.Tests.Content.csproj | 5 +- .../DotNetNuke.Tests.Core.csproj | 5 +- .../DotNetNuke.Tests.Data.csproj | 5 +- .../DotNetNuke.Tests.Integration.csproj | 5 +- .../DotNetNuke.Tests.UI.csproj | 17 +- .../DotNetNuke.Tests.Urls.csproj | 3 + .../DotNetNuke.Tests.Web.Mvc.csproj | 15 +- .../DotNetNuke.Tests.Web.csproj | 11 +- .../Dnn.PersonaBar.Pages.Tests.csproj | 3 + .../PagesControllerUnitTests.cs | 242 +++++++++--------- .../Dnn.PersonaBar.Security.Tests.csproj | 3 + .../Dnn.PersonaBar.Users.Tests.csproj | 3 + 15 files changed, 190 insertions(+), 164 deletions(-) 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 4030f417ae1..ab610ef6f44 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 @@ -12,6 +12,7 @@ v4.7.2 512 + true AnyCPU @@ -22,7 +23,7 @@ DEBUG;TRACE prompt 4 - 1591, 618 + 1591, 618,SA0001 7 @@ -33,7 +34,7 @@ TRACE prompt 4 - 1591, 618 + 1591, 618,SA0001 7 @@ -114,11 +115,11 @@ - \ No newline at end of file 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 823e768a1e7..4586c15785a 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.AspNetCCP/DotNetNuke.Tests.AspNetCCP.csproj +++ b/DNN Platform/Tests/DotNetNuke.Tests.AspNetCCP/DotNetNuke.Tests.AspNetCCP.csproj @@ -14,6 +14,7 @@ 512 ..\..\..\..\Evoq.Content\ true + true true @@ -23,6 +24,7 @@ DEBUG;TRACE prompt 4 + SA0001 7 @@ -32,6 +34,7 @@ TRACE prompt 4 + SA0001 7 @@ -104,11 +107,11 @@ - \ 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 34f5206312a..1d68559b12a 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Authentication/DotNetNuke.Tests.Authentication.csproj +++ b/DNN Platform/Tests/DotNetNuke.Tests.Authentication/DotNetNuke.Tests.Authentication.csproj @@ -35,6 +35,7 @@ true ..\..\..\ true + true true @@ -45,7 +46,7 @@ prompt 4 AllRules.ruleset - 1591 + 1591,SA0001 7 @@ -56,7 +57,7 @@ prompt 4 AllRules.ruleset - 1591 + 1591,SA0001 7 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 71422d46914..450378d5adf 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Content/DotNetNuke.Tests.Content.csproj +++ b/DNN Platform/Tests/DotNetNuke.Tests.Content/DotNetNuke.Tests.Content.csproj @@ -35,6 +35,7 @@ true ..\..\..\..\Evoq.Content\ true + true true @@ -45,7 +46,7 @@ prompt 4 AllRules.ruleset - 1591 + 1591,SA0001 7 @@ -56,7 +57,7 @@ prompt 4 AllRules.ruleset - 1591 + 1591,SA0001 7 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 bd2731b0e89..3174f715360 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Core/DotNetNuke.Tests.Core.csproj +++ b/DNN Platform/Tests/DotNetNuke.Tests.Core/DotNetNuke.Tests.Core.csproj @@ -35,6 +35,7 @@ true ..\..\..\..\Evoq.Content\ true + true true @@ -45,7 +46,7 @@ prompt 4 AllRules.ruleset - 1591, 0618 + 1591, 0618,SA0001 7 @@ -56,7 +57,7 @@ prompt 4 AllRules.ruleset - 1591, 0618 + 1591, 0618,SA0001 7 diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Data/DotNetNuke.Tests.Data.csproj b/DNN Platform/Tests/DotNetNuke.Tests.Data/DotNetNuke.Tests.Data.csproj index e21231fdd82..cd0a9577e15 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Data/DotNetNuke.Tests.Data.csproj +++ b/DNN Platform/Tests/DotNetNuke.Tests.Data/DotNetNuke.Tests.Data.csproj @@ -34,6 +34,7 @@ ..\..\..\..\Evoq.Content\ true + true true @@ -44,7 +45,7 @@ prompt 4 AllRules.ruleset - 1591 + 1591,SA0001 7 @@ -55,7 +56,7 @@ prompt 4 AllRules.ruleset - 1591 + 1591,SA0001 7 diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Integration/DotNetNuke.Tests.Integration.csproj b/DNN Platform/Tests/DotNetNuke.Tests.Integration/DotNetNuke.Tests.Integration.csproj index 6f36f06b0c5..603544ab24b 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Integration/DotNetNuke.Tests.Integration.csproj +++ b/DNN Platform/Tests/DotNetNuke.Tests.Integration/DotNetNuke.Tests.Integration.csproj @@ -35,6 +35,7 @@ true ..\..\..\..\Evoq.Content\ true + true true @@ -45,7 +46,7 @@ prompt 4 AllRules.ruleset - 1591, 0618 + 1591, 0618,SA0001 7 @@ -56,7 +57,7 @@ prompt 4 AllRules.ruleset - 1591, 0618 + 1591, 0618,SA0001 7 diff --git a/DNN Platform/Tests/DotNetNuke.Tests.UI/DotNetNuke.Tests.UI.csproj b/DNN Platform/Tests/DotNetNuke.Tests.UI/DotNetNuke.Tests.UI.csproj index 68a30fae87b..f446625df0a 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.UI/DotNetNuke.Tests.UI.csproj +++ b/DNN Platform/Tests/DotNetNuke.Tests.UI/DotNetNuke.Tests.UI.csproj @@ -35,6 +35,7 @@ true ..\..\..\..\Evoq.Content\ true + true true @@ -45,7 +46,7 @@ prompt 4 AllRules.ruleset - 1591 + 1591,SA0001 7 @@ -56,7 +57,7 @@ prompt 4 AllRules.ruleset - 1591 + 1591,SA0001 7 @@ -115,11 +116,11 @@ - \ No newline at end of file diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Urls/DotNetNuke.Tests.Urls.csproj b/DNN Platform/Tests/DotNetNuke.Tests.Urls/DotNetNuke.Tests.Urls.csproj index 482cc83a1ba..02382913b4a 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Urls/DotNetNuke.Tests.Urls.csproj +++ b/DNN Platform/Tests/DotNetNuke.Tests.Urls/DotNetNuke.Tests.Urls.csproj @@ -13,6 +13,7 @@ 512 ..\..\..\..\Evoq.Content\ true + true true @@ -22,6 +23,7 @@ DEBUG;TRACE prompt 4 + SA0001 7 @@ -31,6 +33,7 @@ TRACE prompt 4 + SA0001 7 diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Web.Mvc/DotNetNuke.Tests.Web.Mvc.csproj b/DNN Platform/Tests/DotNetNuke.Tests.Web.Mvc/DotNetNuke.Tests.Web.Mvc.csproj index 14034c7b66d..2c587ddc721 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Web.Mvc/DotNetNuke.Tests.Web.Mvc.csproj +++ b/DNN Platform/Tests/DotNetNuke.Tests.Web.Mvc/DotNetNuke.Tests.Web.Mvc.csproj @@ -13,6 +13,7 @@ 512 ..\..\..\ true + true true @@ -22,6 +23,7 @@ DEBUG;TRACE prompt 4 + SA0001 7 @@ -31,6 +33,7 @@ TRACE prompt 4 + SA0001 7 @@ -156,11 +159,11 @@ - \ No newline at end of file diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Web/DotNetNuke.Tests.Web.csproj b/DNN Platform/Tests/DotNetNuke.Tests.Web/DotNetNuke.Tests.Web.csproj index 840af18b6a0..0176bc65770 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Web/DotNetNuke.Tests.Web.csproj +++ b/DNN Platform/Tests/DotNetNuke.Tests.Web/DotNetNuke.Tests.Web.csproj @@ -14,6 +14,7 @@ 512 ..\..\..\..\Evoq.Content\ true + true true @@ -23,7 +24,7 @@ DEBUG;TRACE prompt 4 - 618 + 618,SA0001 7 @@ -33,7 +34,7 @@ TRACE prompt 4 - 618 + 618,SA0001 7 @@ -158,8 +159,8 @@ - @@ -173,6 +174,6 @@ - \ No newline at end of file diff --git a/Dnn.AdminExperience/Tests/Dnn.PersonaBar.Pages.Tests/Dnn.PersonaBar.Pages.Tests.csproj b/Dnn.AdminExperience/Tests/Dnn.PersonaBar.Pages.Tests/Dnn.PersonaBar.Pages.Tests.csproj index 05fb10f67ab..10e10625910 100644 --- a/Dnn.AdminExperience/Tests/Dnn.PersonaBar.Pages.Tests/Dnn.PersonaBar.Pages.Tests.csproj +++ b/Dnn.AdminExperience/Tests/Dnn.PersonaBar.Pages.Tests/Dnn.PersonaBar.Pages.Tests.csproj @@ -11,6 +11,7 @@ Dnn.PersonaBar.Pages.Tests v4.7.2 512 + true true @@ -20,6 +21,7 @@ DEBUG;TRACE prompt 4 + SA0001 7 @@ -29,6 +31,7 @@ TRACE prompt 4 + SA0001 7 diff --git a/Dnn.AdminExperience/Tests/Dnn.PersonaBar.Pages.Tests/PagesControllerUnitTests.cs b/Dnn.AdminExperience/Tests/Dnn.PersonaBar.Pages.Tests/PagesControllerUnitTests.cs index 2cebca44b90..432def0fe30 100644 --- a/Dnn.AdminExperience/Tests/Dnn.PersonaBar.Pages.Tests/PagesControllerUnitTests.cs +++ b/Dnn.AdminExperience/Tests/Dnn.PersonaBar.Pages.Tests/PagesControllerUnitTests.cs @@ -2,124 +2,124 @@ // 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.PersonaBar.Pages.Tests -{ - using System.Collections.Generic; - - using Dnn.PersonaBar.Library.Helper; - using Dnn.PersonaBar.Pages.Components; - using Dnn.PersonaBar.Pages.Components.Exceptions; - using Dnn.PersonaBar.Pages.Services.Dto; - using DotNetNuke.Entities.Modules; - using DotNetNuke.Entities.Portals; - using DotNetNuke.Entities.Tabs; - using DotNetNuke.Entities.Urls; - using Moq; - using NUnit.Framework; - - [TestFixture] - public class PagesControllerUnitTests - { - private Mock _tabControllerMock; - private Mock _moduleControllerMock; - private Mock _pageUrlsControllerMock; - private Mock _templateControllerMock; - private Mock _defaultPortalThemeControllerMock; - private Mock _cloneModuleExecutionContextMock; - private Mock _urlRewriterUtilsWrapperMock; - private Mock _friendlyUrlWrapperMock; - private Mock _contentVerifierMock; - PagesControllerImpl _pagesController; - Mock _portalControllerMock; - - [SetUp] - public void RunBeforeEachTest() - { - this._tabControllerMock = new Mock(); - this._moduleControllerMock = new Mock(); - this._pageUrlsControllerMock = new Mock(); - this._templateControllerMock = new Mock(); - this._defaultPortalThemeControllerMock = new Mock(); - this._cloneModuleExecutionContextMock = new Mock(); - this._urlRewriterUtilsWrapperMock = new Mock(); - this._friendlyUrlWrapperMock = new Mock(); - this._contentVerifierMock = new Mock(); - this._portalControllerMock = new Mock(); - } - - [TestCase("http://www.websitename.com/home/", "/home")] - [TestCase("/news/", "/news")] - [TestCase("contactus/", "contactus")] - [TestCase("blogs", "blogs")] - public void ValidatePageUrlSettings_CleanNameForUrl_URLArgumentShouldBeLocalPath(string inputUrl, string expected) - { - // Arrange - var modified = false; - var tab = new TabInfo(); - var portalSettings = new PortalSettings(); - var friendlyOptions = new FriendlyUrlOptions(); - - this._urlRewriterUtilsWrapperMock.Setup(d => d.GetExtendOptionsForURLs(It.IsAny())).Returns(friendlyOptions); - this._friendlyUrlWrapperMock.Setup(d => d.CleanNameForUrl(It.IsAny(), friendlyOptions, out modified)).Returns(expected); - this._friendlyUrlWrapperMock.Setup(d => d.ValidateUrl(It.IsAny(), It.IsAny(), It.IsAny(), out modified)); - - this.InitializePageController(); - - PageSettings pageSettings = new PageSettings(); - pageSettings.Url = inputUrl; - - string inValidField = string.Empty; - string errorMessage = string.Empty; - - // Act - bool result = this._pagesController.ValidatePageUrlSettings(portalSettings, pageSettings, tab, ref inValidField, ref errorMessage); - - // Assert - Assert.IsTrue(result); - this._urlRewriterUtilsWrapperMock.VerifyAll(); - this._friendlyUrlWrapperMock.Verify(d => d.CleanNameForUrl(expected, friendlyOptions, out modified), Times.Once()); - } - - [Test] - public void GetPageSettings_CallGetCurrentPortalSettings_WhenSettingParameterIsNull() - { - var tabId = 0; - var portalId = 0; - - var tab = new TabInfo(); - tab.PortalID = portalId; - - var portalSettings = new PortalSettings(); - - // Arrange - this._tabControllerMock.Setup(t => t.GetTab(It.IsAny(), It.IsAny())).Returns(tab); - this._portalControllerMock.Setup(p => p.GetCurrentPortalSettings()).Returns(portalSettings); - this._contentVerifierMock.Setup(c => c.IsContentExistsForRequestedPortal(It.IsAny(), It.IsAny(), false)).Returns(false); - - this.InitializePageController(); - - // Act - TestDelegate pageSettingsCall = () => this._pagesController.GetPageSettings(tabId, null); - - // Assert - Assert.Throws(pageSettingsCall); - this._portalControllerMock.Verify(p => p.GetCurrentPortalSettings(), Times.Exactly(2)); - this._contentVerifierMock.Verify(c => c.IsContentExistsForRequestedPortal(portalId, portalSettings, false)); - } - - private void InitializePageController() - { - this._pagesController = new PagesControllerImpl( - this._tabControllerMock.Object, - this._moduleControllerMock.Object, - this._pageUrlsControllerMock.Object, - this._templateControllerMock.Object, - this._defaultPortalThemeControllerMock.Object, - this._cloneModuleExecutionContextMock.Object, - this._urlRewriterUtilsWrapperMock.Object, - this._friendlyUrlWrapperMock.Object, - this._contentVerifierMock.Object, - this._portalControllerMock.Object); - } - } -} +namespace Dnn.PersonaBar.Pages.Tests +{ + using System.Collections.Generic; + + using Dnn.PersonaBar.Library.Helper; + using Dnn.PersonaBar.Pages.Components; + using Dnn.PersonaBar.Pages.Components.Exceptions; + using Dnn.PersonaBar.Pages.Services.Dto; + using DotNetNuke.Entities.Modules; + using DotNetNuke.Entities.Portals; + using DotNetNuke.Entities.Tabs; + using DotNetNuke.Entities.Urls; + using Moq; + using NUnit.Framework; + + [TestFixture] + public class PagesControllerUnitTests + { + private Mock _tabControllerMock; + private Mock _moduleControllerMock; + private Mock _pageUrlsControllerMock; + private Mock _templateControllerMock; + private Mock _defaultPortalThemeControllerMock; + private Mock _cloneModuleExecutionContextMock; + private Mock _urlRewriterUtilsWrapperMock; + private Mock _friendlyUrlWrapperMock; + private Mock _contentVerifierMock; + private PagesControllerImpl _pagesController; + private Mock _portalControllerMock; + + [SetUp] + public void RunBeforeEachTest() + { + this._tabControllerMock = new Mock(); + this._moduleControllerMock = new Mock(); + this._pageUrlsControllerMock = new Mock(); + this._templateControllerMock = new Mock(); + this._defaultPortalThemeControllerMock = new Mock(); + this._cloneModuleExecutionContextMock = new Mock(); + this._urlRewriterUtilsWrapperMock = new Mock(); + this._friendlyUrlWrapperMock = new Mock(); + this._contentVerifierMock = new Mock(); + this._portalControllerMock = new Mock(); + } + + [TestCase("http://www.websitename.com/home/", "/home")] + [TestCase("/news/", "/news")] + [TestCase("contactus/", "contactus")] + [TestCase("blogs", "blogs")] + public void ValidatePageUrlSettings_CleanNameForUrl_URLArgumentShouldBeLocalPath(string inputUrl, string expected) + { + // Arrange + var modified = false; + var tab = new TabInfo(); + var portalSettings = new PortalSettings(); + var friendlyOptions = new FriendlyUrlOptions(); + + this._urlRewriterUtilsWrapperMock.Setup(d => d.GetExtendOptionsForURLs(It.IsAny())).Returns(friendlyOptions); + this._friendlyUrlWrapperMock.Setup(d => d.CleanNameForUrl(It.IsAny(), friendlyOptions, out modified)).Returns(expected); + this._friendlyUrlWrapperMock.Setup(d => d.ValidateUrl(It.IsAny(), It.IsAny(), It.IsAny(), out modified)); + + this.InitializePageController(); + + PageSettings pageSettings = new PageSettings(); + pageSettings.Url = inputUrl; + + string inValidField = string.Empty; + string errorMessage = string.Empty; + + // Act + bool result = this._pagesController.ValidatePageUrlSettings(portalSettings, pageSettings, tab, ref inValidField, ref errorMessage); + + // Assert + Assert.IsTrue(result); + this._urlRewriterUtilsWrapperMock.VerifyAll(); + this._friendlyUrlWrapperMock.Verify(d => d.CleanNameForUrl(expected, friendlyOptions, out modified), Times.Once()); + } + + [Test] + public void GetPageSettings_CallGetCurrentPortalSettings_WhenSettingParameterIsNull() + { + var tabId = 0; + var portalId = 0; + + var tab = new TabInfo(); + tab.PortalID = portalId; + + var portalSettings = new PortalSettings(); + + // Arrange + this._tabControllerMock.Setup(t => t.GetTab(It.IsAny(), It.IsAny())).Returns(tab); + this._portalControllerMock.Setup(p => p.GetCurrentPortalSettings()).Returns(portalSettings); + this._contentVerifierMock.Setup(c => c.IsContentExistsForRequestedPortal(It.IsAny(), It.IsAny(), false)).Returns(false); + + this.InitializePageController(); + + // Act + TestDelegate pageSettingsCall = () => this._pagesController.GetPageSettings(tabId, null); + + // Assert + Assert.Throws(pageSettingsCall); + this._portalControllerMock.Verify(p => p.GetCurrentPortalSettings(), Times.Exactly(2)); + this._contentVerifierMock.Verify(c => c.IsContentExistsForRequestedPortal(portalId, portalSettings, false)); + } + + private void InitializePageController() + { + this._pagesController = new PagesControllerImpl( + this._tabControllerMock.Object, + this._moduleControllerMock.Object, + this._pageUrlsControllerMock.Object, + this._templateControllerMock.Object, + this._defaultPortalThemeControllerMock.Object, + this._cloneModuleExecutionContextMock.Object, + this._urlRewriterUtilsWrapperMock.Object, + this._friendlyUrlWrapperMock.Object, + this._contentVerifierMock.Object, + this._portalControllerMock.Object); + } + } +} diff --git a/Dnn.AdminExperience/Tests/Dnn.PersonaBar.Security.Tests/Dnn.PersonaBar.Security.Tests.csproj b/Dnn.AdminExperience/Tests/Dnn.PersonaBar.Security.Tests/Dnn.PersonaBar.Security.Tests.csproj index a234e230531..b8cc999f06d 100644 --- a/Dnn.AdminExperience/Tests/Dnn.PersonaBar.Security.Tests/Dnn.PersonaBar.Security.Tests.csproj +++ b/Dnn.AdminExperience/Tests/Dnn.PersonaBar.Security.Tests/Dnn.PersonaBar.Security.Tests.csproj @@ -11,6 +11,7 @@ Dnn.PersonaBar.Security.Tests v4.7.2 512 + true true @@ -20,6 +21,7 @@ DEBUG;TRACE prompt 4 + SA0001 7 @@ -29,6 +31,7 @@ TRACE prompt 4 + SA0001 7 diff --git a/Dnn.AdminExperience/Tests/Dnn.PersonaBar.Users.Tests/Dnn.PersonaBar.Users.Tests.csproj b/Dnn.AdminExperience/Tests/Dnn.PersonaBar.Users.Tests/Dnn.PersonaBar.Users.Tests.csproj index 6e00f1cc118..9cbdf64b507 100644 --- a/Dnn.AdminExperience/Tests/Dnn.PersonaBar.Users.Tests/Dnn.PersonaBar.Users.Tests.csproj +++ b/Dnn.AdminExperience/Tests/Dnn.PersonaBar.Users.Tests/Dnn.PersonaBar.Users.Tests.csproj @@ -12,6 +12,7 @@ v4.7.2 512 + true true @@ -21,6 +22,7 @@ DEBUG;TRACE prompt 4 + SA0001 7 @@ -30,6 +32,7 @@ TRACE prompt 4 + SA0001 7