Skip to content

Commit

Permalink
Merge pull request #263 from sharparchitecture/releases/8.0.0
Browse files Browse the repository at this point in the history
Release 8.0.0
  • Loading branch information
cd21h authored Oct 27, 2021
2 parents c3718f0 + fd1ad3a commit b52db2b
Show file tree
Hide file tree
Showing 91 changed files with 2,654 additions and 814 deletions.
45 changes: 37 additions & 8 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@
<PropertyGroup Label="Build">
<Product>Sharp Architecture</Product>
<Authors>Sharp Architecture Dev Team</Authors>

<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0</TargetFrameworks>
<Copyright>Copyright &#xA9; Sharp Architecture Development Team</Copyright>
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0;net6.0</TargetFrameworks>
<Culture></Culture>
<SignAssembly>false</SignAssembly>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>

<LangVersion>9.0</LangVersion>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<IsTestProject>false</IsTestProject>

<NoWarn>$(NoWarn);0105</NoWarn>
</PropertyGroup>

<PropertyGroup Label="Custom targets">
<!-- target frameworks for unit-tests and applications -->
<AppTargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0</AppTargetFrameworks>
<AppTargetFrameworks>netcoreapp3.1;net5.0;net6.0</AppTargetFrameworks>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Debug'">
Expand All @@ -29,7 +34,7 @@
</PropertyGroup>

<!-- nullable checks -->
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' or '$(TargetFramework)' == 'net5.0' ">
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' or '$(TargetFramework)' == 'net5.0' or '$(TargetFramework)' == 'net6.0'">
<DefineConstants>$(DefineConstants);NULLABLE_REFERENCE_TYPES</DefineConstants>
</PropertyGroup>

Expand All @@ -39,7 +44,7 @@
<PackageIconUrl>https://github.com/sharparchitecture/Sharp-Architecture/raw/master/Artefacts/Documentation/icon.png</PackageIconUrl>
<PackageProjectUrl>http://sharparchitecture.github.io/</PackageProjectUrl>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>https://github.com/sharparchitecture/Sharp-Architecture/releases/tag/7.0.0</PackageReleaseNotes>
<PackageReleaseNotes>https://github.com/sharparchitecture/Sharp-Architecture/releases/tag/8.0.0</PackageReleaseNotes>
<PackageTags>sharp-architecture;sharp-arch</PackageTags>
</PropertyGroup>

Expand All @@ -57,9 +62,33 @@
<NoWarn>$(NoWarn);0618;1591</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(MSBuildProjectFullPath.Contains(Sample))' == true ">
<ItemGroup Condition="'$(MSBuildProjectName.Contains(Tests))' == false">
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>SharpArch.XunitTests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>


<PropertyGroup Condition="'$(MSBuildProjectFullPath.Contains(Sample))' == true">
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>


<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<LangVersion>preview</LangVersion>
</PropertyGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Runtime.InteropServices.ComVisibleAttribute">
<_Parameter1>false</_Parameter1>
<_Parameter1_TypeName>System.Boolean</_Parameter1_TypeName>
</AssemblyAttribute>
</ItemGroup>

<!-- Common references -->
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2021.2.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
</ItemGroup>

<ItemGroup Label="Package References (.NET 5)" Condition=" '$(TargetFramework)' == 'net5' ">
<ItemGroup Label="Package References (.NET 5)" Condition=" '$(TargetFramework)' == 'net5.0' ">
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2021.1.0" PrivateAssets="All" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2021.1.0" />
<PackageReference Include="MediatR" Version="9.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
<ItemGroup>
<PackageReference Include="AutoMapper" Version="10.1.1" />
<PackageReference Include="FluentNHibernate" Version="3.1.0" />
<PackageReference Include="Humanizer.Core" Version="2.8.26" />
<PackageReference Include="JetBrains.Annotations" Version="2021.1.0" />
<PackageReference Include="NHibernate" Version="5.3.8" />
<PackageReference Include="Humanizer.Core" Version="2.11.10" />
<PackageReference Include="NHibernate" Version="5.3.10" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Suteki.TardisBank.Tasks
public interface IUserService
{
Task<User?> GetCurrentUser(CancellationToken cancellationToken = default);
Task<User> GetUser(int userId, CancellationToken cancellationToken = default);
Task<User?> GetUser(int userId, CancellationToken cancellationToken = default);
Task<User?> GetUserByUserName(string userName, CancellationToken cancellationToken = default);
Task<User?> GetUserByActivationKey(string activationKey, CancellationToken cancellationToken = default);
Task SaveUser(User user, CancellationToken cancellationToken = default);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2021.1.0" />
<PackageReference Include="MediatR" Version="9.0.0" />
<PackageReference Include="NHibernate" Version="5.3.8" />
<PackageReference Include="NHibernate" Version="5.3.10" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public UserService(IHttpContextService context, ILinqRepository<Parent, int> par
return GetUserByUserName(_context.UserName, cancellationToken);
}

public Task<User> GetUser(int userId, CancellationToken cancellationToken)
public Task<User?> GetUser(int userId, CancellationToken cancellationToken)
{
return _userRepository.FindOneAsync(userId, cancellationToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ public class TestServerSetup : IDisposable
public TestServerSetup()
{
Server = new TestServer(Program.CreateHostBuilder(Array.Empty<string>())
#if NETCOREAPP3_1 || NET5_0
.UseTestServer()
#endif
.UseStartup<Startup>()
.UseSolutionRelativeContentRoot("TardisBank/Src/Suteki.TardisBank.WebApi/")
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace Suteki.TardisBank.Tests.Model
using Domain;
using FluentAssertions;
using SharpArch.NHibernate;
using SharpArch.NHibernate.Impl;
using SharpArch.Testing.Xunit.NHibernate;
using Xunit;

Expand All @@ -33,40 +32,39 @@ protected override async Task LoadTestData(CancellationToken cancellationToken)

var child = parent.CreateChild("Leo", "leohadlow", "xxx");
await Session.SaveAsync(child, cancellationToken);
await FlushSessionAndEvict(child, cancellationToken);
await FlushSessionAndEvict(parent, cancellationToken);
await Session.FlushAndEvictAsync(cancellationToken, child, parent);
_childId = child.Id;
}

[Fact]
public async Task Should_be_able_to_add_schedule_to_account()
{
var childToTestOn = await _childRepository.GetAsync(_childId);
var childToTestOn = (await _childRepository.GetAsync(_childId))!;
childToTestOn.Should().NotBeNull();

childToTestOn.Account.AddPaymentSchedule(DateTime.UtcNow, Interval.Week, 10, "Weekly pocket money");
await FlushSessionAndEvict(childToTestOn);

var child = await _childRepository.GetAsync(_childId);
var child = (await _childRepository.GetAsync(_childId))!;
child.Should().NotBeNull();
child.Account.PaymentSchedules[0].Id.Should().BePositive("schedule was not persisted");
}

[Fact]
public async Task Should_be_able_to_add_transaction_to_account()
{
var childToTestOn = await _childRepository.GetAsync(_childId);
var childToTestOn = (await _childRepository.GetAsync(_childId))!;
childToTestOn.ReceivePayment(10, "Reward");
await FlushSessionAndEvict(childToTestOn);

var child = await _childRepository.GetAsync(_childId);
var child = (await _childRepository.GetAsync(_childId))!;
child.Account.Transactions[0].Id.Should().BePositive();
}

[Fact]
public async Task Should_be_able_to_create_and_retrieve_a_child()
{
var child = await _childRepository.GetAsync(_childId);
var child = (await _childRepository.GetAsync(_childId))!;
child.Name.Should().Be("Leo");
child.UserName.Should().Be(@"leohadlow");
child.ParentId.Should().Be(_parentId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ namespace Suteki.TardisBank.Tests.Model
using MediatR;
using Moq;
using SharpArch.NHibernate;
using SharpArch.NHibernate.Impl;
using SharpArch.Testing.NHibernate;
using SharpArch.Testing.Xunit.NHibernate;
using Xunit;


public class MessageTests : TransientDatabaseTests<TransientDatabaseSetup>
{
int _userId;
Mock<IMediator> _mediator;
readonly Mock<IMediator> _mediator;

public MessageTests(TransientDatabaseSetup dbSetup) : base(dbSetup)
{
Expand All @@ -36,13 +34,13 @@ protected override async Task LoadTestData(CancellationToken cancellationToken)
public async Task Should_be_able_to_add_a_message_to_a_user()
{
var parentRepository = new LinqRepository<Parent, int>(TransactionManager);
User userToTestWith = await parentRepository.GetAsync(_userId);
User userToTestWith = (await parentRepository.GetAsync(_userId))!;

userToTestWith.SendMessage("some message", _mediator.Object);

await FlushSessionAndEvict(userToTestWith);

Parent parent = await parentRepository.GetAsync(_userId);
Parent parent = (await parentRepository.GetAsync(_userId))!;
parent.Messages.Count.Should().Be(1);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Suteki.TardisBank.Tests.Model
using System.Threading.Tasks;
using Domain;
using FluentAssertions;
using SharpArch.NHibernate.Impl;
using SharpArch.NHibernate;
using SharpArch.Testing.Xunit.NHibernate;
using Xunit;

Expand All @@ -30,15 +30,15 @@ protected override async Task LoadTestData(CancellationToken cancellationToken)
public async Task Should_be_able_to_add_a_child_to_a_parent()
{
var linqRepository = new LinqRepository<Parent, int>(TransactionManager);
Parent savedParent = await linqRepository.GetAsync(_parentId);
Parent savedParent = (await linqRepository.GetAsync(_parentId))!;
savedParent.Should().NotBeNull();

savedParent.CreateChild("jim", "jim123", "passw0rd1");
savedParent.CreateChild("jenny", "jenny123", "passw0rd2");
savedParent.CreateChild("jez", "jez123", "passw0rd3");
await FlushSessionAndEvict(savedParent);

Parent parent = await linqRepository.GetAsync(_parentId);
Parent parent = (await linqRepository.GetAsync(_parentId))!;
parent.Children.Count.Should().Be(3);

parent.Children[0].Name.Should().Be("jim");
Expand All @@ -49,7 +49,7 @@ public async Task Should_be_able_to_add_a_child_to_a_parent()
[Fact]
public async Task Should_be_able_to_create_and_retrieve_Parent()
{
Parent parent = await new LinqRepository<Parent, int>(TransactionManager).GetAsync(_parentId);
Parent parent = (await new LinqRepository<Parent, int>(TransactionManager).GetAsync(_parentId))!;
parent.Should().NotBeNull();
parent.Name.Should().Be("Mike Hadlow");
parent.UserName.Should().Be("[email protected]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class TransientDatabaseSetup : TestDatabaseSetup
{
/// <inheritdoc />
public TransientDatabaseSetup()
: base(typeof(TransientDatabaseSetup).Assembly, new[]
: base(typeof(TransientDatabaseSetup).Assembly, typeof(AutoPersistenceModelGenerator), new[]
{
typeof(AutoPersistenceModelGenerator).Assembly
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,34 @@

<ItemGroup>
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="FluentAssertions" Version="6.2.0" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="3.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NHibernate" Version="5.3.8" />
<PackageReference Include="NHibernate" Version="5.3.10" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.113.7" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.115" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.1.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.5" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="5.0.11" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.0-rc.2.*" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\Src\SharpArch.Testing.Xunit.NHibernate\SharpArch.Testing.Xunit.NHibernate.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ namespace Suteki.TardisBank.WebApi.Controllers
public class AnnouncementsController : ControllerBase
{
readonly ILinqRepository<Announcement, int> _announcementRepository;
#if NETCOREAPP3_1 || NET5_0
readonly LinkGenerator _linkGenerator;
#endif
readonly IMapper _mapper;

/// <summary>
Expand All @@ -35,15 +33,11 @@ public class AnnouncementsController : ControllerBase
/// <param name="announcementRepository">Announcements repository.</param>
/// <param name="mapper">Mapper</param>
public AnnouncementsController(ILinqRepository<Announcement, int> announcementRepository,
#if NETCOREAPP3_1 || NET5_0
LinkGenerator linkGenerator,
#endif
IMapper mapper)
{
_announcementRepository = announcementRepository ?? throw new ArgumentNullException(nameof(announcementRepository));
#if NETCOREAPP3_1 || NET5_0
_linkGenerator = linkGenerator ?? throw new ArgumentNullException(nameof(linkGenerator));
#endif
_mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
}

Expand Down Expand Up @@ -81,12 +75,8 @@ public async Task<ActionResult> Post(NewAnnouncement model)
{
var announcement = _mapper.Map<Announcement>(model);
await _announcementRepository.SaveAsync(announcement, HttpContext.RequestAborted).ConfigureAwait(false);
#if NETCOREAPP3_1 || NET5_0
var location = _linkGenerator.GetPathByName("GetAnnouncement", new {id = announcement.Id});
#else
var location = Url.RouteUrl("GetAnnouncement", new {id = announcement.Id});
#endif
return Created(location, announcement);
return Created(location!, announcement);
}

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions Samples/TardisBank/Src/Suteki.TardisBank.WebApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ namespace Suteki.TardisBank.WebApi
using Serilog.Exceptions;
using Serilog.Formatting.Json;
using Serilog.Sinks.SystemConsole.Themes;
#if NETCOREAPP3_1 || NET5_0
using Microsoft.Extensions.Hosting;
#endif


public class Program
Expand Down
Loading

0 comments on commit b52db2b

Please sign in to comment.