Skip to content

Commit

Permalink
Merge pull request #3 from dorssel/unit_test
Browse files Browse the repository at this point in the history
Add unit testing
  • Loading branch information
dorssel authored Feb 29, 2024
2 parents 3b3363a + 55c824b commit 62e5de8
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 7 deletions.
4 changes: 1 addition & 3 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"tools": {
"dotnet-ef": {
"version": "8.0.2",
"commands": [
"dotnet-ef"
]
"commands": ["dotnet-ef"]
}
}
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ SPDX-License-Identifier: MIT

# dotnet-ef-sqlite-timestamp

[![Build](https://github.com/dorssel/dotnet-ef-sqlite-timestamp/workflows/Build/badge.svg?branch=master)](https://github.com/dorssel/dotnet-ef-sqlite-timestamp/actions?query=workflow%3ABuild+branch%3Amaster)
[![CodeQL](https://github.com/dorssel/dotnet-ef-sqlite-timestamp/workflows/CodeQL/badge.svg?branch=master)](https://github.com/dorssel/dotnet-ef-sqlite-timestamp/actions?query=workflow%3ACodeQL+branch%3Amaster)
[![MegaLinter](https://github.com/dorssel/dotnet-ef-sqlite-timestamp/workflows/MegaLinter/badge.svg?branch=master)](https://github.com/dorssel/dotnet-ef-sqlite-timestamp/actions?query=workflow%3AMegaLinter+branch%3Amaster)
[![codecov](https://codecov.io/gh/dorssel/dotnet-ef-sqlite-timestamp/branch/master/graph/badge.svg?token=zsbTiXoisQ)](https://codecov.io/gh/dorssel/dotnet-ef-sqlite-timestamp)
[![Build](https://github.com/dorssel/dotnet-ef-sqlite-timestamp/actions/workflows/dotnet.yml/badge.svg?branch=main)](https://github.com/dorssel/dotnet-ef-sqlite-timestamp/actions?query=workflow%3ABuild+branch%3Amain)
[![CodeQL](https://github.com/dorssel/dotnet-ef-sqlite-timestamp/actions/workflows/codeql.yml/badge.svg?branch=main)](https://github.com/dorssel/dotnet-ef-sqlite-timestamp/actions?query=workflow%3ACodeQL+branch%3Amain)
[![MegaLinter](https://github.com/dorssel/dotnet-ef-sqlite-timestamp/actions/workflows/lint.yml/badge.svg?branch=main)](https://github.com/dorssel/dotnet-ef-sqlite-timestamp/actions?query=workflow%3ALint+branch%3Amain)
[![codecov](https://codecov.io/gh/dorssel/dotnet-ef-sqlite-timestamp/branch/main/graph/badge.svg?token=zsbTiXoisQ)](https://codecov.io/gh/dorssel/dotnet-ef-sqlite-timestamp)
[![REUSE status](https://api.reuse.software/badge/github.com/dorssel/dotnet-ef-sqlite-timestamp)](https://api.reuse.software/info/github.com/dorssel/dotnet-ef-sqlite-timestamp)
[![NuGet](https://img.shields.io/nuget/v/Dorssel.EntityFrameworkCore.Sqlite.Timestamp?logo=nuget)](https://www.nuget.org/packages/Dorssel.EntityFrameworkCore.Sqlite.Timestamp)

Expand Down
19 changes: 19 additions & 0 deletions UnitTests/Api_Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-FileCopyrightText: 2024 Frans van Dorsselaer
//
// SPDX-License-Identifier: MIT

namespace UnitTests;

[TestClass]
sealed class Api_Tests
{
[TestMethod]
public void UseSqliteTimestamp_NullBuilderThrows()
{
DbContextOptionsBuilder optionsBuilder = null!;
Assert.ThrowsException<ArgumentNullException>(() =>
{
optionsBuilder.UseSqliteTimestamp();
});
}
}
6 changes: 6 additions & 0 deletions UnitTests/AssemblySettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-FileCopyrightText: 2024 Frans van Dorsselaer
//
// SPDX-License-Identifier: MIT

[assembly: CLSCompliant(false)]
[assembly: DiscoverInternals]
12 changes: 12 additions & 0 deletions UnitTests/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-FileCopyrightText: 2024 Frans van Dorsselaer
//
// SPDX-License-Identifier: MIT

// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

using System.Diagnostics.CodeAnalysis;

[assembly: SuppressMessage("Performance", "CA1812:Internal class is never instantiated", Justification = "We use internal test classes")]
26 changes: 26 additions & 0 deletions UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
SPDX-FileCopyrightText: 2024 Frans van Dorsselaer
SPDX-License-Identifier: MIT
-->
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<SignAssembly>True</SignAssembly>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
<PackageReference Include="MSTest.TestAdapter" />
<PackageReference Include="MSTest.TestFramework" />
<PackageReference Include="coverlet.collector" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\SqliteTimestamp\SqliteTimestamp.csproj" />
</ItemGroup>

</Project>
7 changes: 7 additions & 0 deletions UnitTests/Usings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-FileCopyrightText: 2024 Frans van Dorsselaer
//
// SPDX-License-Identifier: MIT

global using Dorssel.EntityFrameworkCore;
global using Microsoft.EntityFrameworkCore;
global using Microsoft.VisualStudio.TestTools.UnitTesting;
6 changes: 6 additions & 0 deletions dotnet-ef-sqlite-timestamp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests", "UnitTests\UnitTests.csproj", "{422D4232-1539-43C6-A7A4-0BEC3F7D083C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -35,6 +37,10 @@ Global
{780D7D60-C59A-4816-BA69-873AEFEB28C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{780D7D60-C59A-4816-BA69-873AEFEB28C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{780D7D60-C59A-4816-BA69-873AEFEB28C8}.Release|Any CPU.Build.0 = Release|Any CPU
{422D4232-1539-43C6-A7A4-0BEC3F7D083C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{422D4232-1539-43C6-A7A4-0BEC3F7D083C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{422D4232-1539-43C6-A7A4-0BEC3F7D083C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{422D4232-1539-43C6-A7A4-0BEC3F7D083C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit 62e5de8

Please sign in to comment.