Skip to content

Commit

Permalink
Fix namespaces and documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
GillesTourreau committed Sep 27, 2024
1 parent ed54cb4 commit 3053560
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion docs/WriteTest.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ By default, with XUnit all the tests will be executed in parallel. Also, our tes
will works on the same database. It will not work of course, so it is mean that our tests must be executed in series
and not in parallel.

For that, we must add the `Collection` attribute with an unique name to indicate to XUnit that all the tests
For that, we must add the `Collection` attribute with an unique name to indicate to xUnit that all the tests
in the class, must not be executed in parallel.

We recommand to put the name of the database in the arguments of the `Collection` attribute.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace PosInformatique.DemoApp.DataAccessLayer.Migrations.Tests
{
using FluentAssertions;
using Microsoft.EntityFrameworkCore;
using PosInformatique.UnitTests.Databases;
using PosInformatique.UnitTests.Databases.SqlServer;
using PosInformatique.Testing.Databases;
using PosInformatique.Testing.Databases.SqlServer;

public class DatabaseMigrationTest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageReference Include="coverlet.collector" />
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="PosInformatique.UnitTests.Databases.SqlServer.EntityFramework" />
<PackageReference Include="PosInformatique.Testing.Databases.SqlServer.EntityFramework" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace PosInformatique.DemoApp.DataAccessLayer.Tests
{
using FluentAssertions;
using PosInformatique.UnitTests.Databases.SqlServer;
using PosInformatique.Testing.Databases.SqlServer;

[Collection(DatabaseName)]
public class CustomerRepositoryTest : IClassFixture<SqlServerDatabaseInitializer>
Expand All @@ -30,7 +30,7 @@ public CustomerRepositoryTest(SqlServerDatabaseInitializer initializer)
// - Here we force to set the ID of the customer to 15.
this.database.InsertInto("Customer", disableIdentityInsert: true, new { Id = 15, FirstName = "Marcel", LastName = "DUPONT", Revenue = 4852.45 });

// - Here, to simplify the syntax (recommanded approach) we use an extension method in the unit tests project.
// - Here, to simplify the syntax (recommanded approach) we use an extension method in the tests project.
// Using extension methods, make the code more readable.
// Also, we recommand to force to set the IDENTITY column values explicit to avoid
// to update lot of code if you delete some rows later...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace PosInformatique.DemoApp.DataAccessLayer.Tests

/// <summary>
/// This helper allows to centralize the connection string
/// and the creation of the <see cref="DbContextOptions"/> for the unit tests.
/// and the creation of the <see cref="DbContextOptions"/> for the tests.
/// </summary>
public static class DatabaseTestsConnectionStrings
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageReference Include="coverlet.collector" />
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="PosInformatique.UnitTests.Databases.SqlServer.EntityFramework" />
<PackageReference Include="PosInformatique.Testing.Databases.SqlServer.EntityFramework" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace PosInformatique.DemoApp.DataAccessLayer.Tests
{
using PosInformatique.UnitTests.Databases.SqlServer;
using PosInformatique.Testing.Databases.SqlServer;

/// <summary>
/// Contains static methods to insert data in the database.
Expand Down
2 changes: 1 addition & 1 deletion samples/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="Microsoft.SqlServer.DacFx" Version="161.6374.0" />
<PackageVersion Include="PosInformatique.UnitTests.Databases.SqlServer.EntityFramework" Version="2.0.0" />
<PackageVersion Include="PosInformatique.Testing.Databases.SqlServer.EntityFramework" Version="2.0.0-rc.1" />
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
<PackageVersion Include="xunit" Version="2.9.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</PackageReleaseNotes>
</PropertyGroup>

<!-- Add the InternalsVisibleToAttribute for the unit tests -->
<!-- Add the InternalsVisibleToAttribute for the tests -->
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>$(AssemblyName).Tests</_Parameter1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace PosInformatique.Testing.Databases.SqlServer
using Microsoft.Data.SqlClient;

/// <summary>
/// Initializer used to initialize the database for the unit tests.
/// Initializer used to initialize the database for the tests.
/// Call the <see cref="Initialize(SqlServerDatabaseInitializer, string, string)"/> method to initialize a database from
/// a DACPAC file.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>

<Description>Testing.Databases.SqlServer.Dac is a library that contains a set of tools for unit testing to deploy DAC (Data-tier Applications) packages (.dacpac files).</Description>
<Description>Testing.Databases.SqlServer.Dac is a library that contains a set of tools for testing to deploy DAC (Data-tier Applications) packages (.dacpac files).</Description>
<PackageTags>testing unittest sqlserver repository tdd dataaccesslayer dacpac dac</PackageTags>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<GenerateDocumentationFile>True</GenerateDocumentationFile>

<Description>Testing.Databases.SqlServer.EntityFramework is a library that contains a set of tools for unit testing Data Access Layer (repositories) based on Entity Framework and SQL Server.</Description>
<Description>Testing.Databases.SqlServer.EntityFramework is a library that contains a set of tools for testing Data Access Layer (repositories) based on Entity Framework and SQL Server.</Description>
<PackageTags>testing unittest entityframework sqlserver repository tdd dataaccesslayer</PackageTags>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace PosInformatique.Testing.Databases.SqlServer
{
/// <summary>
/// Initializer used to initialize the database for the unit tests.
/// Initializer used to initialize the database for the tests.
/// Depending of the strategy to use (initialize from Entity Framework DbContext or .dacpac package)
/// add the <c>PosInformatique.Testing.Databases.SqlServer.EntityFramework</c> or <c>PosInformatique.Testing.Databases.SqlServer.Dac</c>
/// NuGet packages and call the <c>Initialize()</c> method.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<TargetFramework>net8.0</TargetFramework>
<GenerateDocumentationFile>True</GenerateDocumentationFile>

<Description>Testing.Databases.SqlServer is a library that contains a set of tools for unit testing Data Access Layer (repositories) based on SQL Server.</Description>
<PackageTags>testing nittest sqlserver repository tdd dataaccesslayer</PackageTags>
<Description>Testing.Databases.SqlServer is a library that contains a set of tools for testing Data Access Layer (repositories) based on SQL Server.</Description>
<PackageTags>testing unittest sqlserver repository tdd dataaccesslayer</PackageTags>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void Test1()
table.Rows[1]["Name"].Should().Be("Name 2");

// Insert a row which should not be use in other tests.
this.database.InsertInto("MyTable", new { Id = 99, Name = "Should not be here for the next unit test" });
this.database.InsertInto("MyTable", new { Id = 99, Name = "Should not be here for the next test" });
}

[Fact]
Expand All @@ -71,7 +71,7 @@ public void Test2()
table.Rows[1]["Name"].Should().Be("Name 2");

// Insert a row which should not be use in other tests.
this.database.InsertInto("MyTable", new { Id = 99, Name = "Should not be here for the next unit test" });
this.database.InsertInto("MyTable", new { Id = 99, Name = "Should not be here for the next test" });
}

private sealed class DbContextTest : DbContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace PosInformatique.Testing.Databases.SqlServer.Tests
{
[Collection("PosInformatique.UniTestingtTests.Databases.SqlServer.Tests")]
[Collection("PosInformatique.Testing.Databases.SqlServer.Tests")]
public class SqlServerDatabaseInitializerTest : IClassFixture<SqlServerDatabaseInitializer>
{
private const string ConnectionString = $"Data Source=(localDB)\\posinfo-tests; Initial Catalog={nameof(SqlServerDatabaseInitializerTest)}; Integrated Security=True";
Expand Down Expand Up @@ -43,7 +43,7 @@ public void Test1()
table.Rows[1]["Name"].Should().Be("Name 2");

// Insert a row which should not be use in other tests.
this.database.InsertInto("MyTable", new { Id = 99, Name = "Should not be here for the next unit test" });
this.database.InsertInto("MyTable", new { Id = 99, Name = "Should not be here for the next test" });
}

[Fact]
Expand All @@ -64,7 +64,7 @@ public void Test2()
table.Rows[1]["Name"].Should().Be("Name 2");

// Insert a row which should not be use in other tests.
this.database.InsertInto("MyTable", new { Id = 99, Name = "Should not be here for the next unit test" });
this.database.InsertInto("MyTable", new { Id = 99, Name = "Should not be here for the next test" });
}
}
}

0 comments on commit 3053560

Please sign in to comment.