Skip to content

Commit e4190bd

Browse files
Matthew ThorntonMatthew Thornton
authored andcommitted
Merge pull request #3 in TECHBUS/winton.domainmodelling.abstractions from feature/BT-6531 to master
* commit '813d572b485ce7c9acf12002f509e5bc07d32a42': Fix Jenkinsfile. Remove generics from EntityNotFoundException class.
2 parents b4bf5c6 + 813d572 commit e4190bd

File tree

4 files changed

+43
-22
lines changed

4 files changed

+43
-22
lines changed

Jenkinsfile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ node {
1212
}
1313

1414
stage("Build") {
15-
bat("\"${tool 'MSBuild15'}\" /p:Configuration=Release")
15+
bat("\"${tool 'MSBuild15'}\" /p:Configuration=Release /p:GetVersion=True /p:WriteVersionInfoToBuildLog=True")
1616
}
1717

1818
stage("Test") {
19-
dir("test\\Winton.DomainModelling.Abstractions.Tests") {
20-
bat("dotnet test Winton.DomainModelling.Abstractions.Tests.csproj --configuration Release --no-restore --no-build")
21-
}
19+
def tests = [
20+
"unit-tests": { test("Winton.DomainModelling.Abstractions.Tests") }
21+
]
22+
parallel tests
2223
}
2324

2425
stage("Publish") {
@@ -40,4 +41,12 @@ node {
4041
finally{
4142
step([$class: 'StashNotifier'])
4243
}
44+
}
45+
46+
def test(testProjectName) {
47+
dir("test") {
48+
dir("${testProjectName}") {
49+
bat("dotnet test --configuration Release --no-restore --no-build")
50+
}
51+
}
4352
}

src/Winton.DomainModelling.Abstractions/EntityNotFoundException.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,25 @@ namespace Winton.DomainModelling
66
/// <summary>
77
/// An error indicating that an entity could not be found.
88
/// </summary>
9-
/// <typeparam name="TEntity">The type of entity.</typeparam>
10-
/// <typeparam name="TEntityId">The type of entity id.</typeparam>
11-
public class EntityNotFoundException<TEntity, TEntityId> : DomainException
12-
where TEntity : Entity<TEntityId>
13-
where TEntityId : IEquatable<TEntityId>
9+
public class EntityNotFoundException : DomainException
1410
{
11+
private EntityNotFoundException(string message)
12+
: base(message)
13+
{
14+
}
15+
1516
/// <summary>
16-
/// Initializes a new instance of the <see cref="EntityNotFoundException{TEntity, TEntityId}" /> class.
17+
/// Creates a new instance of the <see cref="EntityNotFoundException" /> class using the generic constraint to generate
18+
/// the message.
1719
/// </summary>
18-
public EntityNotFoundException()
19-
: base($"The specified {typeof(TEntity).Name} could not be found.")
20+
/// <typeparam name="TEntity">The type of the entity.</typeparam>
21+
/// <typeparam name="TEntityId">The type of the entity id.</typeparam>
22+
/// <returns>A new instance of <see cref="EntityNotFoundException" />.</returns>
23+
public static EntityNotFoundException Create<TEntity, TEntityId>()
24+
where TEntity : Entity<TEntityId>
25+
where TEntityId : IEquatable<TEntityId>
2026
{
27+
return new EntityNotFoundException($"The specified {typeof(TEntity).Name} could not be found.");
2128
}
2229
}
2330
}

src/Winton.DomainModelling.Abstractions/Winton.DomainModelling.Abstractions.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<Copyright>Copyright 2018 Winton</Copyright>
77
<Description>Provides common abstractions for domain modelling.</Description>
88
<GenerateDocumentationFile>True</GenerateDocumentationFile>
9+
<GetVersion>False</GetVersion>
910
<NoWarn>$(NoWarn);SA0001;SA1101;SA1309;SA1413;SA1633;SA1652</NoWarn>
1011
<PackageId>Winton.DomainModelling.Abstractions</PackageId>
1112
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
@@ -15,6 +16,7 @@
1516
<TargetFramework>netstandard1.0</TargetFramework>
1617
<Title>Winton Domain Modelling Abstractions</Title>
1718
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
19+
<WriteVersionInfoToBuildLog>False</WriteVersionInfoToBuildLog>
1820
</PropertyGroup>
1921

2022
<PropertyGroup Condition="'$(Configuration)' == 'Release'">

test/Winton.DomainModelling.Abstractions.Tests/EntityNotFoundExceptionTests.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@ namespace Winton.DomainModelling
55
{
66
public class EntityNotFoundExceptionTests
77
{
8-
[Fact]
9-
private void ShouldSetMessageBasedOnTypeOfEntity()
8+
public sealed class Message : EntityNotFoundExceptionTests
109
{
11-
var exception = new EntityNotFoundException<TestEntity, int>();
10+
[Fact]
11+
private void ShouldSetMessageBasedOnTypeOfEntity()
12+
{
13+
EntityNotFoundException exception = EntityNotFoundException.Create<TestEntity, int>();
1214

13-
exception.Message.Should().Be("The specified TestEntity could not be found.");
14-
}
15+
exception.Message.Should().Be("The specified TestEntity could not be found.");
16+
}
1517

16-
// ReSharper disable once ClassNeverInstantiated.Local
17-
private sealed class TestEntity : Entity<int>
18-
{
19-
public TestEntity(int id)
20-
: base(id)
18+
// ReSharper disable once ClassNeverInstantiated.Local
19+
private sealed class TestEntity : Entity<int>
2120
{
21+
public TestEntity(int id)
22+
: base(id)
23+
{
24+
}
2225
}
2326
}
2427
}

0 commit comments

Comments
 (0)