Skip to content

Commit

Permalink
✅ enforce correct namespacing for imported PB code via tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fluffynuts committed Oct 23, 2024
1 parent fbcc73f commit efacbae
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Linq;
using PeanutButter.Utils;

namespace NExpect.Matchers.AspNet.Tests;

[TestFixture]
public class TestPeanutButterProperlyImported
{
[TestCase("PeanutButter.")]
public void ShouldNotExportNamespaceStartingWith_(
string prefix
)
{
// Arrange
// Act
var invalid = typeof(Expectations)
.GetAssembly()
.GetTypes()
.Where(t => t.Namespace?.StartsWith(prefix) ?? false)
.ToArray();
// Assert
Expect(invalid)
.To.Be.Empty();
}
}
2 changes: 2 additions & 0 deletions src/NExpect.Matchers.AspNetMvc.Tests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
global using NExpect;
global using static NExpect.Expectations;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using static PeanutButter.RandomGenerators.RandomValueGen;
using NExpect.Exceptions;
using PeanutButter.Utils;
using static NExpect.Expectations;

namespace NExpect.Matchers.AspNetMvc.Tests;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Web.Mvc;
using NExpect.Exceptions;
using NUnit.Framework;
using static NExpect.Expectations;

namespace NExpect.Matchers.AspNetMvc.Tests;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using NExpect.Exceptions;
using NUnit.Framework;
using static PeanutButter.RandomGenerators.RandomValueGen;
using static NExpect.Expectations;

namespace NExpect.Matchers.AspNetMvc.Tests;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Linq;
using NUnit.Framework;
using PeanutButter.Utils;

namespace NExpect.Matchers.AspNetMvc.Tests;

[TestFixture]
public class TestPeanutButterProperlyImported
{
[TestCase("PeanutButter.")]
public void ShouldNotExportNamespaceStartingWith_(
string prefix
)
{
// Arrange
// Act
var invalid = typeof(Expectations)
.GetAssembly()
.GetTypes()
.Where(t => t.Namespace?.StartsWith(prefix) ?? false)
.ToArray();
// Assert
Expect(invalid)
.To.Be.Empty();
}
}
26 changes: 26 additions & 0 deletions src/NExpect.Tests/TestPeanutButterProperlyImported.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Linq;
using NUnit.Framework;
using PeanutButter.Utils;

namespace NExpect.Tests;

[TestFixture]
public class TestPeanutButterProperlyImported
{
[TestCase("PeanutButter.")]
public void ShouldNotExportNamespaceStartingWith_(
string prefix
)
{
// Arrange
// Act
var invalid = typeof(Expectations)
.GetAssembly()
.GetTypes()
.Where(t => t.Namespace?.StartsWith(prefix) ?? false)
.ToArray();
// Assert
Expect(invalid)
.To.Be.Empty();
}
}
2 changes: 1 addition & 1 deletion src/PeanutButter
Submodule PeanutButter updated 35 files
+1 −1 source/Async/PeanutButter.Async.Tests/PeanutButter.Async.Tests.csproj
+1 −1 source/Async/PeanutButter.TestUtils.Async.Tests/PeanutButter.TestUtils.Async.Tests.csproj
+1 −1 source/DatabaseHelpers/PeanutButter.DatabaseHelpers.More.Tests/PeanutButter.DatabaseHelpers.More.Tests.csproj
+1 −1 source/DatabaseHelpers/PeanutButter.DatabaseHelpers.Tests/PeanutButter.DatabaseHelpers.Tests.vbproj
+2 −2 source/INI/PeanutButter.INI.Tests/PeanutButter.INI.Tests.csproj
+2 −2 source/NugetPackageVersionIncrementer.Tests/NugetPackageVersionIncrementer.Tests.csproj
+1 −1 ...vers/PeanutButter.SimpleHTTPServer.Testability.Tests/PeanutButter.SimpleHTTPServer.Testability.Tests.csproj
+1 −1 source/SimpleServers/PeanutButter.SimpleHTTPServer.Tests/PeanutButter.SimpleHTTPServer.Tests.csproj
+1 −1 source/SimpleServers/PeanutButter.SimpleTcpServer.Tests/PeanutButter.SimpleTcpServer.Tests.csproj
+1 −1 source/TempDb/PeanutButter.TempDb.MySql.Connector.Tests/PeanutButter.TempDb.MySql.Connector.Tests.csproj
+1 −1 source/TempDb/PeanutButter.TempDb.MySql.Data.Tests/PeanutButter.TempDb.MySql.Data.Tests.csproj
+1 −1 source/TempDb/PeanutButter.TempDb.Runner.Tests/PeanutButter.TempDb.Runner.Tests.csproj
+1 −1 source/TempDb/PeanutButter.TempDb.Tests/PeanutButter.TempDb.Tests.csproj
+1 −1 source/TempDb/PeanutButter.TempRedis.Tests/PeanutButter.TempRedis.Tests.csproj
+1 −1 source/TestUtils/PeanutButter.RandomGenerators.Core.Tests/PeanutButter.RandomGenerators.Core.Tests.csproj
+1 −1 source/TestUtils/PeanutButter.RandomGenerators.Ducked.Tests/PeanutButter.RandomGenerators.Ducked.Tests.csproj
+1 −1 source/TestUtils/PeanutButter.RandomGenerators.Tests/PeanutButter.RandomGenerators.Tests.csproj
+3 −3 source/TestUtils/PeanutButter.TestUtils.AspNetCore.Tests/PeanutButter.TestUtils.AspNetCore.Tests.csproj
+1 −1 source/TestUtils/PeanutButter.TestUtils.Generic.Tests/PeanutButter.TestUtils.Generic.Tests.csproj
+1 −1 ...ce/TinyEventAggregator/PeanutButter.TinyEventAggregator.Tests/PeanutButter.TinyEventAggregator.Tests.csproj
+1 −1 source/Utils/PeanutButter.DuckTyping.NetCore.Tests/PeanutButter.DuckTyping.NetCore.Tests.csproj
+1 −1 source/Utils/PeanutButter.DuckTyping.Tests/PeanutButter.DuckTyping.Tests.csproj
+1 −1 source/Utils/PeanutButter.EasyArgs.Tests/PeanutButter.EasyArgs.Tests.csproj
+1 −1 source/Utils/PeanutButter.FileSystem.Tests/PeanutButter.FileSystem.Tests.csproj
+2 −2 source/Utils/PeanutButter.JObjectExtensions.Tests/PeanutButter.JObjectExtensions.Tests.csproj
+2 −2 source/Utils/PeanutButter.MVC.Tests/PeanutButter.MVC.Tests.csproj
+1 −1 source/Utils/PeanutButter.NetUtils.Tests/PeanutButter.NetUtils.Tests.csproj
+2 −2 source/Utils/PeanutButter.Utils.NetCore.Tests/PeanutButter.Utils.NetCore.Tests.csproj
+2 −2 source/Utils/PeanutButter.Utils.Tests/PeanutButter.Utils.Tests.csproj
+4 −0 source/Utils/PeanutButter.Utils/Dictionaries/OrderedDictionary.cs
+1 −1 source/Utils/PeanutButter.XmlUtils.Tests/PeanutButter.XmlUtils.Tests.csproj
+1 −1 source/Win32Service/PeanutButter.ServiceShell.NetCore.Tests/PeanutButter.ServiceShell.NetCore.Tests.csproj
+1 −1 source/Win32Service/PeanutButter.ServiceShell.Tests/PeanutButter.ServiceShell.Tests.csproj
+1 −1 ...ce/PeanutButter.WindowsServiceManagement.Core.Tests/PeanutButter.WindowsServiceManagement.Core.Tests.csproj
+1 −1 ...Win32Service/PeanutButter.WindowsServiceManagement.Tests/PeanutButter.WindowsServiceManagement.Tests.csproj

0 comments on commit efacbae

Please sign in to comment.