-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #310 from SkillsFundingAgency/PA-282-EAS-CoC
PA-282 EAS CoC
- Loading branch information
Showing
114 changed files
with
4,407 additions
and
248 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/SFA.DAS.EmployerCommitmentsV2.Api.FakeServers/CommitmentsOuterApiBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System.Net; | ||
using WireMock.RequestBuilders; | ||
using WireMock.ResponseBuilders; | ||
using WireMock.Server; | ||
|
||
namespace SFA.DAS.EmployerCommitmentsV2.Api.FakeServers | ||
{ | ||
public class CommitmentsOuterApiBuilder | ||
{ | ||
private readonly WireMockServer _server; | ||
|
||
public CommitmentsOuterApiBuilder(int port) | ||
{ | ||
_server = WireMockServer.StartWithAdminInterface(port, true); | ||
} | ||
|
||
public static CommitmentsOuterApiBuilder Create(int port) | ||
{ | ||
return new CommitmentsOuterApiBuilder(port); | ||
} | ||
|
||
public MockApi Build() | ||
{ | ||
return new MockApi(_server); | ||
} | ||
|
||
internal CommitmentsOuterApiBuilder WithCourseDeliveryModels() | ||
{ | ||
_server | ||
.Given(Request.Create() | ||
.WithPath("/Providers/*/courses/*") | ||
.UsingGet()) | ||
.RespondWith(Response.Create() | ||
.WithStatusCode(HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBodyAsJson(new | ||
{ | ||
DeliveryModels = new[] { "Regular", "PortableFlexiJob" }, | ||
})); | ||
|
||
_server | ||
.Given(Request.Create() | ||
.WithPath("/Providers/*/courses/650") | ||
.UsingGet()) | ||
.RespondWith(Response.Create() | ||
.WithStatusCode(HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBodyAsJson(new | ||
{ | ||
DeliveryModels = new[] { "Regular" }, | ||
})); | ||
|
||
return this; | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/SFA.DAS.EmployerCommitmentsV2.Api.FakeServers/MockApi.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using WireMock.Server; | ||
|
||
namespace SFA.DAS.EmployerCommitmentsV2.Api.FakeServers | ||
{ | ||
public class MockApi : IDisposable | ||
{ | ||
private readonly WireMockServer _server; | ||
|
||
private bool _isDisposed; | ||
|
||
public MockApi(WireMockServer server) | ||
{ | ||
_server = server; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
Dispose(true); | ||
GC.SuppressFinalize(this); | ||
} | ||
|
||
protected virtual void Dispose(bool disposing) | ||
{ | ||
if (_isDisposed) return; | ||
|
||
if (disposing) | ||
{ | ||
if (_server != null && _server.IsStarted) | ||
_server.Stop(); | ||
|
||
_server?.Dispose(); | ||
} | ||
|
||
_isDisposed = true; | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/SFA.DAS.EmployerCommitmentsV2.Api.FakeServers/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
|
||
namespace SFA.DAS.EmployerCommitmentsV2.Api.FakeServers | ||
{ | ||
public static class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
CommitmentsOuterApiBuilder.Create(44328) | ||
.WithCourseDeliveryModels() | ||
.Build(); | ||
|
||
Console.WriteLine("Approvals Outer API running on port 44328"); | ||
Console.WriteLine("Course Games Developer (650) has a Single DeliveryModel, all other course have multiple"); | ||
Console.WriteLine("Press any key to stop the APIs server"); | ||
Console.ReadKey(); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...mployerCommitmentsV2.Api.FakeServers/SFA.DAS.EmployerCommitmentsV2.Api.FakeServers.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> | ||
<PackageReference Include="WireMock.Net" Version="1.4.20" /> | ||
<PackageReference Include="WireMock.Net.StandAlone" Version="1.4.20" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.