Skip to content

Commit

Permalink
Add unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
atrakic committed Jun 14, 2024
1 parent 64c5734 commit 05b4f8d
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 3 deletions.
13 changes: 12 additions & 1 deletion azure-aks-dotnet-api-demo.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "demo-dotnet", "src\demo-dotnet.csproj", "{C59EF39F-A2B4-4D6F-A877-BC65BE59D030}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{DD93DF1A-FAF0-4B95-9885-FB77A4B38546}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "tests\UnitTests\UnitTests.csproj", "{FFFCCFEE-9EA9-4D65-BA5E-482052449D94}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -18,5 +22,12 @@ Global
{C59EF39F-A2B4-4D6F-A877-BC65BE59D030}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C59EF39F-A2B4-4D6F-A877-BC65BE59D030}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C59EF39F-A2B4-4D6F-A877-BC65BE59D030}.Release|Any CPU.Build.0 = Release|Any CPU
{FFFCCFEE-9EA9-4D65-BA5E-482052449D94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FFFCCFEE-9EA9-4D65-BA5E-482052449D94}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FFFCCFEE-9EA9-4D65-BA5E-482052449D94}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FFFCCFEE-9EA9-4D65-BA5E-482052449D94}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{FFFCCFEE-9EA9-4D65-BA5E-482052449D94} = {DD93DF1A-FAF0-4B95-9885-FB77A4B38546}
EndGlobalSection
EndGlobal
3 changes: 1 addition & 2 deletions src/SqliteGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
//using UsersJson;
using System;

using Microsoft.Data.Sqlite;

Expand Down
26 changes: 26 additions & 0 deletions tests/UnitTests/SqliteGeneratorTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Xunit;

using DataSqlite;

namespace UnitTests
{
public class SqliteGeneratorTests
{
[Fact]
public void GenerateSql_WhenCalled_ReturnsValidSql()
{
// Arrange
var users = SqliteGenerator.GenerateUsers();

// Act

// Assert
Assert.NotNull(users);
Assert.NotEmpty(users);
Assert.True(users.Count() > 0);
Assert.Contains(users, u => u.Name == "Admin");
Assert.DoesNotContain(users, u => u.Name == "Demo");
Assert.All(users, item => Assert.False(string.IsNullOrWhiteSpace(item.Name)));
}
}
}
27 changes: 27 additions & 0 deletions tests/UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\demo-dotnet.csproj" />
</ItemGroup>

</Project>

0 comments on commit 05b4f8d

Please sign in to comment.