Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FLP-1003 Added optional argument in UseLearningTransport extension me… #845

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<ItemGroup>
<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.11.0" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.ServiceBus" Version="5.2.0" />
<PackageReference Include="NServiceBus" Version="7.8.0" />
<PackageReference Include="NServiceBus.AzureFunctions.InProcess.ServiceBus" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.Azure.ServiceBus" Version="5.2.0" />
<PackageReference Include="NServiceBus.Transport.AzureServiceBus" Version="2.0.3" />
<PackageReference Include="Microsoft.Azure.ServiceBus" Version="5.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageReference Include="NServiceBus" Version="7.8.0" />
<PackageReference Include="NServiceBus.Newtonsoft.Json" Version="2.4.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Text.RegularExpressions;
using NServiceBus;

Expand Down Expand Up @@ -33,9 +34,12 @@ public static EndpointConfiguration UseInstallers(this EndpointConfiguration con
return config;
}

public static EndpointConfiguration UseLearningTransport(this EndpointConfiguration config, Action<RoutingSettings> routing = null)
public static EndpointConfiguration UseLearningTransport(this EndpointConfiguration config, Action<RoutingSettings> routing = null, string learningTransportFolderPath = null)
{
var transport = config.UseTransport<LearningTransport>();

if(!string.IsNullOrWhiteSpace(learningTransportFolderPath))
transport.StorageDirectory(learningTransportFolderPath);

transport.Transactions(TransportTransactionMode.ReceiveOnly);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.6.0" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
<PackageReference Include="Azure.Identity" Version="1.13.1" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="NServiceBus.Extensions.DependencyInjection" Version="1.0.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class UnitOfWorkTests : FluentTest<UnitOfWorkTestsFixture>
[Test]
public Task CommitAsync_WhenCommittingUnitOfWork_ThenShouldSaveChangesBeforeNextTask()
{
return RunAsync(f => f.CommitAsync(), f => f.DbContext.Verify(d => d.SaveChangesAsync(), Times.Once()));
return TestAsync(f => f.CommitAsync(), f => f.DbContext.Verify(d => d.SaveChangesAsync(), Times.Once()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

<ItemGroup>
<PackageReference Include="EntityFramework" Version="6.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="Moq" Version="4.10.0" />
<PackageReference Include="NUnit" Version="3.10.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
<PackageReference Include="SFA.DAS.Testing" Version="2.0.5" />
<PackageReference Include="SFA.DAS.Testing.EntityFramework" Version="2.0.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="SFA.DAS.Testing" Version="3.0.169" />
<PackageReference Include="SFA.DAS.Testing.EntityFramework" Version="3.0.169" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class UnitOfWorkTests : FluentTest<UnitOfWorkTestsFixture>
[Test]
public Task CommitAsync_WhenCommittingUnitOfWork_ThenShouldSaveChangesBeforeNextTask()
{
return RunAsync(f => f.CommitAsync(), f => f.DbContext.Verify(d => d.SaveChangesAsync(default(CancellationToken)), Times.Once()));
return TestAsync(f => f.CommitAsync(), f => f.DbContext.Verify(d => d.SaveChangesAsync(default(CancellationToken)), Times.Once()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

<PropertyGroup>
<LangVersion>latest</LangVersion>
<TargetFrameworks>netcoreapp2.0;net462</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="Moq" Version="4.10.0" />
<PackageReference Include="NUnit" Version="3.10.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
<PackageReference Include="SFA.DAS.Testing" Version="2.0.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="SFA.DAS.Testing" Version="3.0.169" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<LangVersion>latest</LangVersion>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

<Authors>DAS</Authors>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if NETCOREAPP2_0
using System;
using System;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.AspNetCore.Http;
Expand All @@ -17,25 +16,25 @@ public class UnitOfWorkManagerMiddlewareTests : FluentTest<UnitOfWorkManagerMidd
[Test]
public Task InvokeAsync_WhenInvokingMiddleware_ThenShouldBeginUnitOfWorkManagerBeforeNextTask()
{
return RunAsync(f => f.InvokeAsync(), f => f.UnitOfWorkManager.Verify(m => m.BeginAsync(), Times.Once));
return TestAsync(f => f.InvokeAsync(), f => f.UnitOfWorkManager.Verify(m => m.BeginAsync(), Times.Once));
}

[Test]
public Task InvokeAsync_WhenInvokingMiddleware_ThenShouldEndUnitOfWorkManagerAfterNextTask()
{
return RunAsync(f => f.InvokeAsync(), f => f.UnitOfWorkManager.Verify(m => m.EndAsync(null), Times.Once));
return TestAsync(f => f.InvokeAsync(), f => f.UnitOfWorkManager.Verify(m => m.EndAsync(null), Times.Once));
}

[Test]
public Task InvokeAsync_WhenInvokingMiddlewareAndAnExceptionIsThrown_ThenShouldEndUnitOfWorkManagerWithException()
{
return RunAsync(f => f.SetException(), f => f.InvokeAsyncAndSwallowException(), f => f.UnitOfWorkManager.Verify(m => m.EndAsync(f.Exception), Times.Once));
return TestAsync(f => f.SetException(), f => f.InvokeAsyncAndSwallowException(), f => f.UnitOfWorkManager.Verify(m => m.EndAsync(f.Exception), Times.Once));
}

[Test]
public Task InvokeAsync_WhenInvokingMiddlewareAndAnExceptionIsThrown_ThenShouldThrowException()
{
return RunAsync(f => f.SetException(), f => f.InvokeAsync(), (f, a) => a.Should().Throw<Exception>());
return TestExceptionAsync(f => Task.FromResult(f.SetException()), f => f.InvokeAsync(), (f, r) => Assert.ThrowsAsync<Exception>(() => r()));
}
}

Expand Down Expand Up @@ -95,5 +94,4 @@ public UnitOfWorkManagerMiddlewareTestsFixture SetException()
return this;
}
}
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,17 @@

<PropertyGroup>
<LangVersion>latest</LangVersion>
<TargetFrameworks>netcoreapp2.0;net462</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="Moq" Version="4.10.0" />
<PackageReference Include="NUnit" Version="3.10.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
<PackageReference Include="SFA.DAS.Testing" Version="2.0.5" />
</ItemGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<DefineConstants>NETCOREAPP2_0</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net462'">
<DefineConstants>NET462</DefineConstants>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.1.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.3" />
<PackageReference Include="FluentAssertions" Version="6.12.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="SFA.DAS.Testing" Version="3.0.169" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETCOREAPP2_0
//#if net_core_8
using Microsoft.AspNetCore.Builder;
using SFA.DAS.UnitOfWork.Mvc.Middleware;

Expand All @@ -12,4 +12,4 @@ public static IApplicationBuilder UseUnitOfWork(this IApplicationBuilder app)
}
}
}
#endif
//#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if NETCOREAPP2_0
using System;
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using SFA.DAS.UnitOfWork.Managers;
Expand Down Expand Up @@ -33,5 +32,4 @@ public async Task InvokeAsync(HttpContext context, IUnitOfWorkManager unitOfWork
await unitOfWorkManager.EndAsync().ConfigureAwait(false);
}
}
}
#endif
}
Loading
Loading