Skip to content

Commit 9618e76

Browse files
authored
Update references to latest versions (#30)
- Update references to latest versions. - Update xUnit to v3. - Remove FluentAssertions.
1 parent 632df5e commit 9618e76

9 files changed

+96
-122
lines changed

build-ci.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

build.yml

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,47 @@
11
trigger:
2-
tags:
2+
batch: true
3+
branches:
34
include:
4-
- v*
5+
- master
56

67
pool: Default
78

8-
resources:
9-
repositories:
10-
- repository: templates
11-
type: git
12-
name: DevShared/Templates
13-
149
variables:
1510
- group: Nuget
16-
- name: buildConfiguration
17-
value: 'Release'
1811

1912
steps:
20-
- template: steps/delete-nupkgs.yml@templates
21-
22-
- task: DotNetCoreCLI@2
23-
displayName: 'Build'
24-
inputs:
25-
command: build
26-
projects: '**/*.csproj'
27-
arguments: '--configuration $(BuildConfiguration)'
13+
- pwsh: |
14+
dotnet build "$(Build.SourcesDirectory)/Kros.KORM.Extensions.Asp.sln" --configuration Release
15+
displayName: Build
2816
29-
- template: steps/dotnet-test-and-publish-results.yml@templates
17+
- pwsh: |
18+
dotnet test "$(Build.SourcesDirectory)/Kros.KORM.Extensions.Asp.sln" --configuration Release --logger trx --results-directory "$(Common.TestResultsDirectory)"
19+
displayName: Test
3020
31-
- task: CopyFiles@2
32-
displayName: 'Copy package files to staging directory'
21+
- task: PublishTestResults@2
22+
displayName: Publish test results
23+
condition: succeededOrFailed()
3324
inputs:
34-
Contents: |
35-
**/*.nupkg
36-
**/*.snupkg
37-
TargetFolder: '$(build.artifactStagingDirectory)'
38-
FlattenFolders: true
39-
40-
- template: steps/nuget-push.yml@templates
41-
parameters:
42-
feed: $(nuget.feed)
25+
testResultsFormat: VSTest
26+
testResultsFiles: '*.trx'
27+
searchFolder: $(Common.TestResultsDirectory)
28+
29+
- ${{ if ne(variables['Build.Reason'], 'PullRequest') }}:
30+
- task: CopyFiles@2
31+
displayName: Copy packages to staging folder
32+
inputs:
33+
contents: |
34+
**/*.nupkg
35+
**/*.snupkg
36+
targetFolder: $(Build.ArtifactStagingDirectory)
37+
flattenFolders: true
38+
39+
- pwsh: |
40+
$nupkgFiles = Get-ChildItem -Path "$(Build.ArtifactStagingDirectory)" -Filter "*.nupkg"
41+
Write-Host "Found $($nupkgFiles.Count) .nupkg file(s) to push"
42+
$nupkgFiles | ForEach-Object {
43+
Write-Host "Pushing $($_.FullName)"
44+
& dotnet nuget push "$($_.FullName)" --source https://api.nuget.org/v3/index.json --api-key $(nugetOrgApiKey) --skip-duplicate
45+
Write-Host
46+
}
47+
displayName: Push packages to server

src/Kros.KORM.Extensions.Asp.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>net10.0</TargetFramework>
55
<Company>KROS a. s.</Company>
6-
<Version>3.0.0</Version>
6+
<Version>3.1.0</Version>
77
<Authors>KROS a. s.</Authors>
88
<Title>Kros.KORM.Extensions.Asp</Title>
99
<Description>Extensions for Kros.KORM library for ASP.NET Core projects.</Description>
@@ -44,12 +44,12 @@
4444
</ItemGroup>
4545

4646
<ItemGroup>
47-
<PackageReference Include="Kros.KORM" Version="8.0.0" />
48-
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.0" />
49-
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.1" />
50-
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.1" />
51-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.1" />
52-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
47+
<PackageReference Include="Kros.KORM" Version="8.1.0" />
48+
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.9" />
49+
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.3" />
50+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.3" />
51+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.3" />
52+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.103" PrivateAssets="All" />
5353
</ItemGroup>
5454

5555
<ItemGroup>

tests/ConfigurationExtensionsShould.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using FluentAssertions;
2-
using Microsoft.Extensions.Configuration;
1+
using Microsoft.Extensions.Configuration;
32
using Xunit;
43

54
namespace Kros.KORM.Extensions.Api.UnitTests
@@ -28,14 +27,14 @@ public void LoadCorrectKormConnectionSetings(string name, string connectionStrin
2827

2928
KormConnectionSettings actual = configuration.GetKormConnectionString(name);
3029

31-
actual.Should().BeEquivalentTo(expected);
30+
Assert.Equivalent(expected, actual, strict: true);
3231
}
3332

3433
[Fact]
3534
public void ReturnNullIfNameIsNotInEitherSection()
3635
{
3736
IConfigurationRoot configuration = ConfigurationHelper.GetConfiguration();
38-
configuration.GetKormConnectionString("ThisNameDoesNotExist").Should().BeNull();
37+
Assert.Null(configuration.GetKormConnectionString("ThisNameDoesNotExist"));
3938
}
4039
}
4140
}

tests/Converters/JsonConverterShould.cs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using FluentAssertions;
2-
using Kros.KORM.Converter;
1+
using Kros.KORM.Converter;
32
using System;
43
using System.Text.Json;
54
using System.Text.RegularExpressions;
@@ -12,9 +11,7 @@ public class JsonConverterShould
1211
[Fact]
1312
public void ThrowArgumentExceptionWhenSerializationOptionsAreNull()
1413
{
15-
Action action = () => new JsonConverter<TestClass>(null);
16-
17-
action.Should().Throw<ArgumentException>();
14+
Assert.Throws<ArgumentNullException>(() => new JsonConverter<TestClass>(null));
1815
}
1916

2017
[Fact]
@@ -25,8 +22,8 @@ public void ConvertJsonToEntity()
2522
TestClass expected = GetSampleClass();
2623
var actual = converter.Convert(GetSampleJson());
2724

28-
actual.Should().BeOfType<TestClass>();
29-
((TestClass)actual).Should().BeEquivalentTo(expected);
25+
var typedActual = Assert.IsType<TestClass>(actual);
26+
Assert.Equivalent(expected, typedActual, strict: true);
3027
}
3128

3229
[Fact]
@@ -36,7 +33,7 @@ public void ThrowJsonExceptionWhenTryingToConvertImproperlyFormattedJsonToEntity
3633

3734
Action action = () => converter.Convert(GetSampleImproperlyFormattedJson());
3835

39-
action.Should().Throw<JsonException>();
36+
Assert.Throws<JsonException>(action);
4037
}
4138

4239
[Fact]
@@ -51,8 +48,8 @@ public void ConvertImproperlyFormattedJsonToEntityWhenUsingCorrectOptions()
5148
TestClass expected = GetSampleClass();
5249
var actual = converter.Convert(GetSampleImproperlyFormattedJson());
5350

54-
actual.Should().BeOfType<TestClass>();
55-
((TestClass)actual).Should().BeEquivalentTo(expected);
51+
var typedActual = Assert.IsType<TestClass>(actual);
52+
Assert.Equivalent(expected, typedActual, strict: true);
5653
}
5754

5855
[Fact]
@@ -63,11 +60,11 @@ public void ConvertEntityToJson()
6360
string expected = GetSampleJson();
6461
var actual = converter.ConvertBack(GetSampleClass());
6562

66-
actual.Should().BeOfType<string>();
67-
((string)actual).Should().Be(expected);
63+
var typedActual = Assert.IsType<string>(actual);
64+
Assert.Equal(expected, typedActual);
6865
}
6966

70-
private TestClass GetSampleClass()
67+
private static TestClass GetSampleClass()
7168
=> new TestClass()
7269
{
7370
BoolProperty = true,
@@ -77,7 +74,7 @@ private TestClass GetSampleClass()
7774
ObjectProperty = new TestClass() { StringProperty = "DolorSitAmet" }
7875
};
7976

80-
private string GetSampleJson()
77+
private static string GetSampleJson()
8178
=> Regex.Replace(
8279
@"{
8380
""BoolProperty"":true,
@@ -94,7 +91,7 @@ private string GetSampleJson()
9491
}
9592
}", @"\s+", "");
9693

97-
private string GetSampleImproperlyFormattedJson()
94+
private static string GetSampleImproperlyFormattedJson()
9895
=> Regex.Replace(
9996
@"{
10097
""boolProperty"":true,

tests/KormBuilderShould.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using FluentAssertions;
2-
using Kros.KORM.Extensions.Asp;
1+
using Kros.KORM.Extensions.Asp;
32
using Kros.KORM.Metadata;
43
using Microsoft.Extensions.DependencyInjection;
54
using NSubstitute;
@@ -16,20 +15,20 @@ public void ThrowArgumentExceptionWhenArgumentsAreInvalid()
1615
const string connectionString = "server=localhost";
1716
var services = new ServiceCollection();
1817

19-
Action action = () => new KormBuilder(null, connectionString);
20-
action.Should().Throw<ArgumentNullException>().And.ParamName.Should().Be("services");
18+
var exception = Assert.Throws<ArgumentNullException>(() => new KormBuilder(null, connectionString));
19+
Assert.Equal("services", exception.ParamName);
2120

22-
action = () => new KormBuilder(services, (KormConnectionSettings)null);
23-
action.Should().Throw<ArgumentNullException>().And.ParamName.Should().Be("connectionSettings");
21+
exception = Assert.Throws<ArgumentNullException>(() => new KormBuilder(services, (KormConnectionSettings)null));
22+
Assert.Equal("connectionSettings", exception.ParamName);
2423

25-
action = () => new KormBuilder(services, (string)null);
26-
action.Should().Throw<ArgumentNullException>().And.ParamName.Should().Be("connectionSettings");
24+
exception = Assert.Throws<ArgumentNullException>(() => new KormBuilder(services, (string)null));
25+
Assert.Equal("connectionSettings", exception.ParamName);
2726

28-
action = () => new KormBuilder(services, string.Empty);
29-
action.Should().Throw<ArgumentException>().And.ParamName.Should().Be("connectionSettings");
27+
var argumentException = Assert.Throws<ArgumentException>(() => new KormBuilder(services, string.Empty));
28+
Assert.Equal("connectionSettings", argumentException.ParamName);
3029

31-
action = () => new KormBuilder(services, " \t ");
32-
action.Should().Throw<ArgumentException>().And.ParamName.Should().Be("connectionSettings");
30+
argumentException = Assert.Throws<ArgumentException>(() => new KormBuilder(services, " \t "));
31+
Assert.Equal("connectionSettings", argumentException.ParamName);
3332
}
3433

3534
[Fact]
@@ -41,11 +40,11 @@ public void UseDatabaseConfiguration()
4140
kormBuilder.UseDatabaseConfiguration(configuration);
4241
IDatabase database = kormBuilder.Build();
4342

44-
database.Should().NotBeNull();
43+
Assert.NotNull(database);
4544
configuration.Received().OnModelCreating(Arg.Any<ModelConfigurationBuilder>());
4645
}
4746

48-
private KormBuilder CreateKormBuilder(bool autoMigrate)
47+
private static KormBuilder CreateKormBuilder(bool autoMigrate)
4948
=> new KormBuilder(new ServiceCollection(), $"server=localhost;KormAutoMigrate={autoMigrate}");
5049
}
5150
}

tests/KormBuilderWithDatabaseShould.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using FluentAssertions;
2-
using Kros.Data;
1+
using Kros.Data;
32
using Kros.KORM.Extensions.Asp;
43
using Kros.UnitTests;
54
using Microsoft.Data.SqlClient;
@@ -41,16 +40,16 @@ private void CheckTableAndProcedure()
4140
using (SqlCommand cmd = ServerHelper.Connection.CreateCommand())
4241
{
4342
cmd.CommandText = "SELECT Count(*) FROM sys.tables WHERE name = 'IdStore' AND type = 'U'";
44-
((int)cmd.ExecuteScalar()).Should().Be(1);
43+
Assert.Equal(1, (int)cmd.ExecuteScalar());
4544

4645
cmd.CommandText = "SELECT Count(*) FROM sys.procedures WHERE name = 'spGetNewId' AND type = 'P'";
47-
((int)cmd.ExecuteScalar()).Should().Be(1);
46+
Assert.Equal(1, (int)cmd.ExecuteScalar());
4847

4948
cmd.CommandText = "SELECT Count(*) FROM sys.tables WHERE name = 'IdStoreInt64' AND type = 'U'";
50-
((int)cmd.ExecuteScalar()).Should().Be(1);
49+
Assert.Equal(1, (int)cmd.ExecuteScalar());
5150

5251
cmd.CommandText = "SELECT Count(*) FROM sys.procedures WHERE name = 'spGetNewIdInt64' AND type = 'P'";
53-
((int)cmd.ExecuteScalar()).Should().Be(1);
52+
Assert.Equal(1, (int)cmd.ExecuteScalar());
5453
}
5554
}
5655
}

tests/Kros.KORM.Extensions.Api.UnitTests.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="FluentAssertions" Version="[7.2.0]" />
10-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.1" />
9+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.3" />
1110
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
1211
<PackageReference Include="NSubstitute" Version="5.3.0" />
13-
<PackageReference Include="xunit" Version="2.9.3" />
1412
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
1513
<PrivateAssets>all</PrivateAssets>
1614
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1715
</PackageReference>
16+
<PackageReference Include="xunit.v3" Version="3.2.2" />
1817
</ItemGroup>
1918

2019
<ItemGroup>

0 commit comments

Comments
 (0)