-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
241 additions
and
21 deletions.
There are no files selected for viewing
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
29 changes: 29 additions & 0 deletions
29
TransformerBeeClient/ExampleAspNetCoreApplication.Test/ApplicationTest.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,29 @@ | ||
using System.Net; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
using FluentAssertions; | ||
using Microsoft.AspNetCore.Mvc.Testing; | ||
using TransformerBeeClient.Model; | ||
|
||
namespace ExampleAspNetCoreApplication.Test; | ||
|
||
public class ApplicationTest : IClassFixture<WebApplicationFactory<Program>> | ||
{ | ||
protected readonly WebApplicationFactory<Program> Factory; | ||
|
||
public ApplicationTest(WebApplicationFactory<Program> factory) | ||
{ | ||
Factory = factory; | ||
} | ||
|
||
[Fact] | ||
public async Task Test_That_Setup_Works_As_Designed() | ||
{ | ||
var client = Factory.CreateDefaultClient(); | ||
var response = await client.GetAsync("/talkToTransformerBee"); | ||
response.StatusCode.Should().Be(HttpStatusCode.OK); | ||
var content = await response.Content.ReadAsStringAsync(); | ||
var bo4e = JsonSerializer.Deserialize<BOneyComb>(content, new JsonSerializerOptions { Converters = { new JsonStringEnumConverter() } }); | ||
bo4e.Should().NotBeNull(); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...ormerBeeClient/ExampleAspNetCoreApplication.Test/ExampleAspNetCoreApplication.Test.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,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="6.12.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.1" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/> | ||
<PackageReference Include="xunit" Version="2.4.2"/> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ExampleAspNetCoreApplication\ExampleAspNetCoreApplication.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
1 change: 1 addition & 0 deletions
1
TransformerBeeClient/ExampleAspNetCoreApplication.Test/GlobalUsings.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 @@ | ||
global using Xunit; |
3 changes: 3 additions & 0 deletions
3
TransformerBeeClient/ExampleAspNetCoreApplication.Test/xunit.runner.json
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,3 @@ | ||
{ | ||
"shadowCopy": false | ||
} |
12 changes: 12 additions & 0 deletions
12
TransformerBeeClient/ExampleAspNetCoreApplication/ExampleAspNetCoreApplication.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,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<PreserveCompilationContext>true</PreserveCompilationContext> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\TransformerBeeClient\TransformerBeeClient.csproj"/> | ||
</ItemGroup> | ||
</Project> |
29 changes: 29 additions & 0 deletions
29
TransformerBeeClient/ExampleAspNetCoreApplication/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,29 @@ | ||
using EDILibrary; | ||
using TransformerBeeClient; | ||
|
||
var builder = WebApplication.CreateBuilder(args); | ||
builder.Services.AddHttpClient(); | ||
|
||
builder.Services.AddTransient<ITransformerBeeAuthenticator, NoAuthenticator>(); // Or you could use ClientIdClientSecretAuthenticator | ||
builder.Services.AddHttpClient("TransformerBee", client => | ||
{ | ||
client.BaseAddress = new Uri("http://localhost:5021/"); // or https://transformerstage.utilibee.io | ||
}); | ||
builder.Services.AddTransient<ICanConvertToBo4e, TransformerBeeRestClient>(); | ||
builder.Services.AddTransient<ICanConvertToEdifact, TransformerBeeRestClient>(); | ||
|
||
var app = builder.Build(); | ||
|
||
app.MapGet("/", () => "I ❤ BO4E"); | ||
app.MapGet("/talkToTransformerBee", async (ICanConvertToBo4e transformerBeeRestClient) => | ||
{ | ||
var bo4e = await transformerBeeRestClient.ConvertToBo4e( | ||
"UNA:+,? 'UNB+UNOC:3+9912345789012:500+9909876543210:500+230703:1059+ASDFHGJ'UNH+11223344556678+UTILMD:D:11A:UN:S1.1'BGM+E01+918273746512345678901'DTM+137:202306300558?+00:303'NAD+MS+9912345789012::293'NAD+MR+9909876543210::293'IDE+24+918273746512345678901'IMD++Z36+Z13'DTM+92:202212312300?+00:303'STS+7++E01'LOC+Z16+78889918283'LOC+Z17+DE0000111122223333444455556667778'RFF+Z13:55001'SEQ+Z01'CCI+Z30++Z07'CCI+Z19++11X0-0000-0116-J'CCI+++Z15'CCI+++Z88'CAV+Z74:::Z09'CAV+Z73:::Z11'SEQ+Z12'QTY+Z16:0:P1'SEQ+Z03'CCI+++E13'CAV+Z30:::788811123'SEQ+Z75'CCI+Z61++ZG1'NAD+Z09+++Schaefer:Ulrike:::Frau:Z01'NAD+Z04+++Schaefer:Ulrike:::Frau:Z01+Flughafenstrasse::64+Vilseck++92247+DE'NAD+DP++++Flughafenstrasse::64+Vilseck++92247+DE'NAD+Z05+++Schaefer:Ulrike:::Frau:Z01+Flughafenstrasse::64+Vilseck++92247+DE'UNT+31+11223344556678'UNZ+1+ASDFHGJ'", | ||
EdifactFormatVersion.FV2310); | ||
return bo4e.Single().Transaktionen.Single(); | ||
Check warning on line 23 in TransformerBeeClient/ExampleAspNetCoreApplication/Program.cs GitHub Actions / test (ubuntu-latest, 6.0.201)
Check warning on line 23 in TransformerBeeClient/ExampleAspNetCoreApplication/Program.cs GitHub Actions / test (ubuntu-latest, 6.0.201)
Check warning on line 23 in TransformerBeeClient/ExampleAspNetCoreApplication/Program.cs GitHub Actions / test (ubuntu-latest, 7.0.100)
Check warning on line 23 in TransformerBeeClient/ExampleAspNetCoreApplication/Program.cs GitHub Actions / test (ubuntu-latest, 8.0.100)
|
||
}); | ||
app.Run(); | ||
|
||
public partial class Program | ||
{ | ||
} // required for integration testing; If you miss this the test will complain, that it cannot find a 'testhost.deps.json' |
38 changes: 38 additions & 0 deletions
38
TransformerBeeClient/ExampleAspNetCoreApplication/Properties/launchSettings.json
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 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:26369", | ||
"sslPort": 44341 | ||
} | ||
}, | ||
"profiles": { | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "http://localhost:5137", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"https": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "https://localhost:7030;http://localhost:5137", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
TransformerBeeClient/ExampleAspNetCoreApplication/appsettings.Development.json
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,8 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
TransformerBeeClient/ExampleAspNetCoreApplication/appsettings.json
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,9 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
} |
33 changes: 33 additions & 0 deletions
33
TransformerBeeClient/TransformerBeeClient.IntegrationTest/MweWithoutAspNetTest.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,33 @@ | ||
using EDILibrary; | ||
using Xunit; | ||
|
||
namespace TransformerBeeClient.IntegrationTest; | ||
|
||
/// <summary> | ||
/// A minimal working example on how to use this library without ASP.NET | ||
/// </summary> | ||
public class MweWithoutAspNetTest | ||
{ | ||
/// <summary> | ||
/// in asp.net applications, there's a service collection that is used to create the http client factory for you | ||
/// </summary> | ||
internal class MyHttpClientFactory : IHttpClientFactory | ||
{ | ||
public HttpClient CreateClient(string name) | ||
{ | ||
return new HttpClient | ||
{ | ||
BaseAddress = new Uri("http://localhost:5021") | ||
}; | ||
} | ||
} | ||
|
||
[Fact] | ||
public async Task Test_Transformer_Bee_Communication() | ||
{ | ||
IHttpClientFactory myFactory = new MyHttpClientFactory(); | ||
ITransformerBeeAuthenticator myAuthenticator = new NoAuthenticator(); // or use ClientIdClientSecretAuthenticator | ||
var client = new TransformerBeeRestClient(myFactory, myAuthenticator); | ||
await client.ConvertToBo4e("UNA:+,? 'UNB+UNOC:3+9912345789012:500+9909876543210:500+230703:1059+ASDFHGJ'UNH+11223344556678+UTILMD:D:11A:UN:S1.1'BGM+E01+918273746512345678901'DTM+137:202306300558?+00:303'NAD+MS+9912345789012::293'NAD+MR+9909876543210::293'IDE+24+918273746512345678901'IMD++Z36+Z13'DTM+92:202212312300?+00:303'STS+7++E01'LOC+Z16+78889918283'LOC+Z17+DE0000111122223333444455556667778'RFF+Z13:55001'SEQ+Z01'CCI+Z30++Z07'CCI+Z19++11X0-0000-0116-J'CCI+++Z15'CCI+++Z88'CAV+Z74:::Z09'CAV+Z73:::Z11'SEQ+Z12'QTY+Z16:0:P1'SEQ+Z03'CCI+++E13'CAV+Z30:::788811123'SEQ+Z75'CCI+Z61++ZG1'NAD+Z09+++Schaefer:Ulrike:::Frau:Z01'NAD+Z04+++Schaefer:Ulrike:::Frau:Z01+Flughafenstrasse::64+Vilseck++92247+DE'NAD+DP++++Flughafenstrasse::64+Vilseck++92247+DE'NAD+Z05+++Schaefer:Ulrike:::Frau:Z01+Flughafenstrasse::64+Vilseck++92247+DE'UNT+31+11223344556678'UNZ+1+ASDFHGJ'", EdifactFormatVersion.FV2310); | ||
} | ||
} |
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
16 changes: 4 additions & 12 deletions
16
TransformerBeeClient/TransformerBeeClient.sln.DotSettings.user
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 |
---|---|---|
@@ -1,15 +1,7 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=1c8bdc71_002Dfc3e_002D44fe_002D9812_002D1b49b4ba3413/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
 | ||
|
||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=4fa21289_002Debff_002D4c5a_002D8d89_002D3c311da32c05/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution #2" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
 | ||
<Solution />
 | ||
</SessionState></s:String> | ||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=4fa21289_002Debff_002D4c5a_002D8d89_002D3c311da32c05/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" Name="All tests from Solution #2" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
 | ||
<Solution />
 | ||
</SessionState></s:String> | ||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=591857ee_002D832a_002D4abe_002D964d_002Db61be9cce36e/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" IsActive="True" Name="BOneyComb_Can_Be_Converted_To_Edifact" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
 | ||
<TestAncestor>
 | ||
<TestId>xUnit::77598126-7BB0-4C07-BF06-331033E0DE78::net8.0::TransformerBeeClient.IntegrationTest.Bo4eToEdifactTests.BOneyComb_Can_Be_Converted_To_Edifact</TestId>
 | ||
</TestAncestor>
 | ||
</SessionState></s:String> | ||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=de4efd69_002D9f4a_002D4e00_002D83fa_002Ddaa381865bd8/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" Name="ConnectionTest" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
 | ||
<Solution />
 | ||
</SessionState></s:String></wpf:ResourceDictionary> | ||
|
||
</wpf:ResourceDictionary> |
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