Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
run: dotnet tool install --global dotnet-coverage

- name: dotnet restore
run: dotnet restore ./v5/ooapi.v5.sln
run: dotnet restore ./v5/ooapi.v5.slnx

- name: dotnet build,test and sonar analyze
run: |
Expand All @@ -77,6 +77,6 @@ jobs:
-d:sonar.exclusions="**/ooapi.v5.core/Migrations/*" \
-d:sonar.cpd.exclusions="**/ooapi.v5.core/Migrations/*, **/ooapi.v5.core/Models/*" \
-d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
dotnet build ./v5/ooapi.v5.sln --no-restore
dotnet build ./v5/ooapi.v5.slnx --no-restore
dotnet-coverage collect -s "dotnetcoverage.runsettings.xml" -f xml -o "coverage.xml" "dotnet test ./v5 --no-build"
dotnet sonarscanner end -d:sonar.token="${{ secrets.SONAR_TOKEN }}"
7 changes: 7 additions & 0 deletions v5/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
31 changes: 31 additions & 0 deletions v5/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="AwesomeAssertions" Version="9.4.0" />
<PackageVersion Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="7.0.1" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageVersion Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
<PackageVersion Include="Swashbuckle.AspNetCore.Newtonsoft" Version="6.5.0" />
<PackageVersion Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.5.0" />
<PackageVersion Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.5.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="10.0.9" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="10.0.9" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.9" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.9" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.4" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.9" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.9" />
<PackageVersion Include="AutoFixture" Version="4.18.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
<PackageVersion Include="MockQueryable.NSubstitute" Version="10.0.8" />
<PackageVersion Include="NSubstitute" Version="5.3.0" />
<PackageVersion Include="NUnit" Version="4.6.1" />
<PackageVersion Include="NUnit3TestAdapter" Version="6.2.0" />
<PackageVersion Include="NUnit.Analyzers" Version="4.14.0" />
<PackageVersion Include="coverlet.collector" Version="10.0.1" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Core" Version="2.3.11" />
</ItemGroup>
</Project>
12 changes: 12 additions & 0 deletions v5/NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="NuGetDotOrg" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<packageSourceMapping>
<packageSource key="NuGetDotOrg">
<package pattern="*" />
</packageSource>
</packageSourceMapping>
</configuration>
2 changes: 1 addition & 1 deletion v5/ooapi.v5.UnitTests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
global using NUnit.Framework;
global using AutoFixture;
global using FluentAssertions;
global using AwesomeAssertions;
global using NSubstitute;
20 changes: 9 additions & 11 deletions v5/ooapi.v5.UnitTests/ooapi.v5.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
<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="AutoFixture" Version="4.18.1" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="NUnit" Version="4.0.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NUnit.Analyzers" Version="3.10.0">
<PackageReference Include="AutoFixture" />
<PackageReference Include="AwesomeAssertions" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NSubstitute" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="NUnit.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using Newtonsoft.Json;
using ooapi.v5.Enums;
using ooapi.v5.Helpers;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using ooapi.v5.Helpers;

namespace ooapi.v5.core.UnitTests.Helpers;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using Newtonsoft.Json;
using ooapi.v5.Helpers;
using ooapi.v5.Models;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using Newtonsoft.Json;
using ooapi.v5.Helpers;

Expand Down
2 changes: 1 addition & 1 deletion v5/ooapi.v5.core.UnitTests/Helpers/OneOfConverterTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using Newtonsoft.Json;
using ooapi.v5.Helpers;

Expand Down
2 changes: 1 addition & 1 deletion v5/ooapi.v5.core.UnitTests/Models/AcademicSessionTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using ooapi.v5.core.Models.OneOfModels;
using ooapi.v5.Models;
using Attribute = ooapi.v5.Models.Attribute;
Expand Down
2 changes: 1 addition & 1 deletion v5/ooapi.v5.core.UnitTests/Models/AddressTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using ooapi.v5.Models;
using Attribute = ooapi.v5.Models.Attribute;

Expand Down
2 changes: 1 addition & 1 deletion v5/ooapi.v5.core.UnitTests/Models/AssociationTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using ooapi.v5.core.Models.OneOfModels;
using ooapi.v5.Models;

Expand Down
2 changes: 1 addition & 1 deletion v5/ooapi.v5.core.UnitTests/Models/BuildingTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using ooapi.v5.Models;
using Attribute = ooapi.v5.Models.Attribute;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using ooapi.v5.core.Models.OneOfModels;
using ooapi.v5.Models;

Expand Down
2 changes: 1 addition & 1 deletion v5/ooapi.v5.core.UnitTests/Models/ComponentTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using ooapi.v5.core.Models.OneOfModels;
using ooapi.v5.Models;
using Attribute = ooapi.v5.Models.Attribute;
Expand Down
2 changes: 1 addition & 1 deletion v5/ooapi.v5.core.UnitTests/Models/CostTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using ooapi.v5.Models;

namespace ooapi.v5.core.UnitTests.Models;
Expand Down
2 changes: 1 addition & 1 deletion v5/ooapi.v5.core.UnitTests/Models/CourseOfferingTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using ooapi.v5.core.Models.OneOfModels;
using ooapi.v5.Models;

Expand Down
2 changes: 1 addition & 1 deletion v5/ooapi.v5.core.UnitTests/Models/CourseResultTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using ooapi.v5.Models;

namespace ooapi.v5.core.UnitTests.Models;
Expand Down
2 changes: 1 addition & 1 deletion v5/ooapi.v5.core.UnitTests/Models/CourseTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using ooapi.v5.core.Models.OneOfModels;
using ooapi.v5.Models;
using Attribute = ooapi.v5.Models.Attribute;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using ooapi.v5.core.Models.OneOfModels;
using ooapi.v5.Models;
using Attribute = ooapi.v5.Models.Attribute;

namespace ooapi.v5.core.UnitTests.Models;

Expand Down
2 changes: 1 addition & 1 deletion v5/ooapi.v5.core.UnitTests/Models/ErrorResponseTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using ooapi.v5.Models;

namespace ooapi.v5.core.UnitTests.Models;
Expand Down
2 changes: 1 addition & 1 deletion v5/ooapi.v5.core.UnitTests/Models/GroupTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using ooapi.v5.core.Models.OneOfModels;
using ooapi.v5.Models;
using Attribute = ooapi.v5.Models.Attribute;
Expand Down
2 changes: 1 addition & 1 deletion v5/ooapi.v5.core.UnitTests/Models/NewsFeedTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using ooapi.v5.Models;
using Attribute = ooapi.v5.Models.Attribute;

Expand Down
2 changes: 1 addition & 1 deletion v5/ooapi.v5.core.UnitTests/Models/NewsItemTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using ooapi.v5.Models;
using Attribute = ooapi.v5.Models.Attribute;

Expand Down
18 changes: 11 additions & 7 deletions v5/ooapi.v5.core.UnitTests/Models/OfferingTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using ooapi.v5.core.Models.OneOfModels;
using ooapi.v5.Models;
using Attribute = ooapi.v5.Models.Attribute;
Expand Down Expand Up @@ -126,7 +126,7 @@ public void GetName_WhenAttributesExist_ReturnsListLanguageTypedString()
{
// Arrange
var offering = _fixture.Build<Offering>()
.With(x => x.Attributes, new List<Attribute>() { new() { PropertyName = "name", Language = "en", Value = "TestName" } })
.With(x => x.Attributes, new List<LanguageTypedProperty>() { new() { PropertyName = "name", Language = "en", Value = "TestName" } })
.OmitAutoProperties()
.Create();

Expand All @@ -141,12 +141,13 @@ public void GetName_WhenAttributesExist_ReturnsListLanguageTypedString()
result[0].Value.Should().Be("TestName");
}


[Test]
public void GetName_WhenAttributesAreEmpty_ReturnsEmptyListLanguageTypedString()
{
// Arrange
var offering = _fixture.Build<Offering>()
.With(x => x.Attributes, new List<Attribute>() { })
.With(x => x.Attributes, new List<LanguageTypedProperty>() { })
.OmitAutoProperties()
.Create();

Expand All @@ -158,13 +159,14 @@ public void GetName_WhenAttributesAreEmpty_ReturnsEmptyListLanguageTypedString()
result.Should().BeOfType<List<LanguageTypedString>>();
result.Should().HaveCount(0);
}



[Test]
public void GetDescription_WhenAttributesExist_ReturnsListLanguageTypedString()
{
// Arrange
var offering = _fixture.Build<Offering>()
.With(x => x.Attributes, new List<Attribute>() { new() { PropertyName = "description", Language = "en", Value = "TestName" } })
.With(x => x.Attributes, new List<LanguageTypedProperty>() { new() { PropertyName = "description", Language = "en", Value = "TestName" } })
.OmitAutoProperties()
.Create();

Expand All @@ -179,12 +181,13 @@ public void GetDescription_WhenAttributesExist_ReturnsListLanguageTypedString()
result[0].Value.Should().Be("TestName");
}


[Test]
public void GetDescription_WhenAttributesAreEmpty_ReturnsEmptyListLanguageTypedString()
{
// Arrange
var offering = _fixture.Build<Offering>()
.With(x => x.Attributes, new List<Attribute>() { })
.With(x => x.Attributes, new List<LanguageTypedProperty>() { })
.OmitAutoProperties()
.Create();

Expand All @@ -196,7 +199,8 @@ public void GetDescription_WhenAttributesAreEmpty_ReturnsEmptyListLanguageTypedS
result.Should().BeOfType<List<LanguageTypedString>>();
result.Should().HaveCount(0);
}



[TestCase("distance-learning", Enums.ModeOfDelivery.distance_learning)]
[TestCase("on campus", Enums.ModeOfDelivery.on_campus)]
[TestCase("online", Enums.ModeOfDelivery.online)]
Expand Down
2 changes: 1 addition & 1 deletion v5/ooapi.v5.core.UnitTests/Models/OrganizationTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using ooapi.v5.core.Models.OneOfModels;
using ooapi.v5.Models;
using Attribute = ooapi.v5.Models.Attribute;
Expand Down
6 changes: 3 additions & 3 deletions v5/ooapi.v5.core.UnitTests/Models/PaginationTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using MockQueryable.NSubstitute;
using ooapi.v5.core.Utility;
using ooapi.v5.Models;
Expand All @@ -20,7 +20,7 @@ public async Task Constructor_WithoutFilter_SetItems()
.With(x => x.PageSize, 100)
.Without(x => x.Filter)
.Create();
var db = items.AsQueryable().BuildMockDbSet();
var db = items.BuildMockDbSet();

// act
var pagination = await Pagination<TestObject>.CreateAsync(db, parameters);
Expand All @@ -44,7 +44,7 @@ public async Task Constructor_WithFilter_SetItems()
.With(x => x.PageSize, 2)
.With(x => x.Filter, "value eq test")
.Create();
var db = items.AsQueryable().BuildMockDbSet();
var db = items.BuildMockDbSet();

// act
var pagination = await Pagination<TestObject>.CreateAsync(db, parameters);
Expand Down
2 changes: 1 addition & 1 deletion v5/ooapi.v5.core.UnitTests/Models/PersonTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using Newtonsoft.Json.Linq;
using ooapi.v5.Enums;
using ooapi.v5.Models;
Expand Down
2 changes: 1 addition & 1 deletion v5/ooapi.v5.core.UnitTests/Models/PostResponseTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using Newtonsoft.Json;
using ooapi.v5.Models;

Expand Down
2 changes: 1 addition & 1 deletion v5/ooapi.v5.core.UnitTests/Models/ProgramOfferingTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using ooapi.v5.core.Models.OneOfModels;
using ooapi.v5.Models;

Expand Down
2 changes: 1 addition & 1 deletion v5/ooapi.v5.core.UnitTests/Models/ProgramResultTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using ooapi.v5.Models;

namespace ooapi.v5.core.UnitTests.Models;
Expand Down
2 changes: 1 addition & 1 deletion v5/ooapi.v5.core.UnitTests/Models/ProgramTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AutoFixture;
using FluentAssertions;
using AwesomeAssertions;
using Newtonsoft.Json.Linq;
using ooapi.v5.core.Models.OneOfModels;
using ooapi.v5.Enums;
Expand Down
Loading
Loading