Skip to content

Commit 7966a75

Browse files
Changes for 1.10.0. (#39)
Co-authored-by: MarkAbrams <[email protected]> Co-authored-by: Mark Abrams <[email protected]>
1 parent 5131ac0 commit 7966a75

File tree

26 files changed

+434
-60
lines changed

26 files changed

+434
-60
lines changed

.azure-devops/pipelines/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777
displayName: 'Install Azurite'
7878
inputs:
7979
command: 'custom'
80-
customCommand: 'install -g azurite@3.24.0'
80+
customCommand: 'install -g azurite@3.33.0'
8181

8282
- task: CmdLine@2
8383
displayName: 'Start Azurite services (not Windows)'

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,13 @@ indent_size = 2
2828
# Clarity of intent is not required, this is non-localizable code.
2929
[*.cs]
3030
dotnet_diagnostic.CA1307.severity = none
31+
32+
# CA1310: Specify StringComparison for correctness
33+
# User locales are not a concern.
34+
[*.cs]
35+
dotnet_diagnostic.CA1310.severity = none
36+
37+
# CA1707: Identifiers should not contain underscores
38+
# Underscores are acceptable for unit test names.
39+
[*.cs]
40+
dotnet_diagnostic.CA1707.severity = none

.github/workflows/build.yml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
os: [ubuntu-latest, windows-latest, macos-latest]
19+
os: [ubuntu-latest, windows-latest] # macos-latest
2020

2121
runs-on: ${{ matrix.os }}
2222

@@ -56,36 +56,36 @@ jobs:
5656
run: 'func'
5757

5858
- name: Install Azurite
59-
run: 'npm install -g azurite@3.24.0'
59+
run: 'npm install -g azurite@3.33.0'
6060

6161
- name: Start Azurite services
6262
run: 'azurite &'
6363
shell: bash
6464

6565
# Run tests
6666

67-
- name: Run tests
68-
if: success() && matrix.os != 'windows-latest'
69-
run: dotnet test ${{ github.workspace }}/src/LogicAppUnit.sln --no-restore --verbosity normal --logger "trx" --filter TestCategory!="WindowsOnly"
67+
# - name: Run tests
68+
# if: success() && matrix.os != 'windows-latest'
69+
# run: dotnet test ${{ github.workspace }}/src/LogicAppUnit.sln --no-restore --verbosity normal --logger "trx" --filter TestCategory!="WindowsOnly"
7070

71-
- name: Run tests
72-
if: success() && matrix.os == 'windows-latest'
73-
run: dotnet test ${{ github.workspace }}/src/LogicAppUnit.sln --no-restore --verbosity normal --logger "trx"
71+
# - name: Run tests
72+
# if: success() && matrix.os == 'windows-latest'
73+
# run: dotnet test ${{ github.workspace }}/src/LogicAppUnit.sln --no-restore --verbosity normal --logger "trx"
7474

7575
# Publish artefacts and test results
7676

77-
- name: Publish test log
78-
uses: actions/upload-artifact@v3
79-
if: success() || failure()
80-
with:
81-
name: test-results.${{ matrix.os }}
82-
path: ${{ github.workspace }}/src/LogicAppUnit.Samples.LogicApps.Tests/TestResults/*.trx
83-
84-
- name: Publish test results
85-
if: (success() || failure()) && github.event_name != 'pull_request'
86-
uses: dorny/test-reporter@v1
87-
with:
88-
name: Test Results (${{ matrix.os }})
89-
path: ${{ github.workspace }}/src/LogicAppUnit.Samples.LogicApps.Tests/TestResults/*.trx
90-
path-replace-backslashes: true
91-
reporter: dotnet-trx
77+
# - name: Publish test log
78+
# uses: actions/upload-artifact@v3
79+
# if: success() || failure()
80+
# with:
81+
# name: test-results.${{ matrix.os }}
82+
# path: ${{ github.workspace }}/src/LogicAppUnit.Samples.LogicApps.Tests/TestResults/*.trx
83+
84+
# - name: Publish test results
85+
# if: (success() || failure()) && github.event_name != 'pull_request'
86+
# uses: dorny/test-reporter@v1
87+
# with:
88+
# name: Test Results (${{ matrix.os }})
89+
# path: ${{ github.workspace }}/src/LogicAppUnit.Samples.LogicApps.Tests/TestResults/*.trx
90+
# path-replace-backslashes: true
91+
# reporter: dotnet-trx

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ BenchmarkDotNet.Artifacts/
6060
# .NET Core
6161
project.lock.json
6262
project.fragment.lock.json
63-
artifacts/
63+
#artifacts/
6464

6565
# ASP.NET Scaffolding
6666
ScaffoldingReadMe.txt

ChangeLog.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# 1.10.0 (4th November 2024)
2+
3+
LogicAppUnit Testing Framework:
4+
5+
- The testing of workflows that call in-line C# is now supported. The .csx script files are copied to the test working directory and are not mocked. [[PR #35](https://github.com/LogicAppUnit/TestingFramework/pull/35), [@sschutten](https://github.com/sschutten)]
6+
- Added a new configuration option `workflow.managedApisToMock` in the `testConfiguration.json` file to control which Managed API connectors are mocked. If this configuration is not set, all Managed API connectors are mocked - this ensures backwards compatabiity with previous versions. [[PR #38](https://github.com/LogicAppUnit/TestingFramework/pull/38), [@zzznz27](https://github.com/zzznz27)]
7+
8+
LogicAppUnit.Samples.LogicApps.Tests:
9+
10+
- Added a `call-data-mapper-workflow` workflow and unit tests to test workflows that call the data mapper.
11+
- Added a `inline-script-workflow` workflow and unit tests to test workflows that call in-line C# script (.csx) files.
12+
13+
114
# 1.9.0 (23rd January 2024)
215

316
LogicAppUnit Testing Framework:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ This code repository includes four projects:
4141

4242
Download the *LogicAppUnit* testing framework package from nuget: https://www.nuget.org/packages/LogicAppUnit/
4343

44-
[![NuGet Badge](https://buildstats.info/nuget/LogicAppUnit)](https://www.nuget.org/packages/LogicAppUnit)
44+
[![NuGet Version Badge](https://img.shields.io/nuget/v/LogicAppUnit)](https://www.nuget.org/packages/LogicAppUnit) [![NuGet Download Badge](https://img.shields.io/nuget/dt/LogicAppUnit)](https://www.nuget.org/packages/LogicAppUnit)
4545

4646

4747
## Compatibility
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using LogicAppUnit.Helper;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using System.Net;
4+
using System.Net.Http;
5+
6+
namespace LogicAppUnit.Samples.LogicApps.Tests.CallDataMapperWorkflow
7+
{
8+
/// <summary>
9+
/// Test cases for the <i>call-data-mapper-workflow</i> workflow which calls a XSLT map that exists in the same Logic App.
10+
/// </summary>
11+
[TestClass]
12+
public class CallDataMapperWorkflowTest : WorkflowTestBase
13+
{
14+
private const string XmlContentType = "application/xml";
15+
16+
[TestInitialize]
17+
public void TestInitialize()
18+
{
19+
Initialize(Constants.LOGIC_APP_TEST_EXAMPLE_BASE_PATH, Constants.CALL_DATA_MAPPER_WORKFLOW);
20+
}
21+
22+
[ClassCleanup]
23+
public static void CleanResources()
24+
{
25+
Close();
26+
}
27+
28+
/// <summary>
29+
/// Tests the workflow when the calling of the map is successful.
30+
/// This test can only be run on Windows:
31+
/// https://learn.microsoft.com/en-us/azure/logic-apps/create-maps-data-transformation-visual-studio-code#limitations-and-known-issues
32+
/// </summary>
33+
[TestMethod]
34+
[TestCategory("WindowsOnly")]
35+
public void CallDataMapperWorkflowTest_When_Successful()
36+
{
37+
using (ITestRunner testRunner = CreateTestRunner())
38+
{
39+
// Run the workflow
40+
var workflowResponse = testRunner.TriggerWorkflow(
41+
ContentHelper.CreateStreamContent(ResourceHelper.GetAssemblyResourceAsStream($"{GetType().Namespace}.MockData.WorkflowRequest.xml"), XmlContentType),
42+
HttpMethod.Post);
43+
44+
// Check workflow run status
45+
Assert.AreEqual(WorkflowRunStatus.Succeeded, testRunner.WorkflowRunStatus);
46+
47+
// Check workflow response
48+
Assert.AreEqual(HttpStatusCode.OK, workflowResponse.StatusCode);
49+
Assert.AreEqual(XmlContentType, workflowResponse.Content.Headers.ContentType.MediaType);
50+
Assert.AreEqual(
51+
ContentHelper.FormatXml(ResourceHelper.GetAssemblyResourceAsStream($"{GetType().Namespace}.MockData.WorkflowResponse.xml")),
52+
ContentHelper.FormatXml(workflowResponse.Content.ReadAsStreamAsync().Result));
53+
54+
// Check action result
55+
Assert.AreEqual(ActionStatus.Succeeded, testRunner.GetWorkflowActionStatus("Transform_using_Data_Mapper"));
56+
Assert.AreEqual(ActionStatus.Succeeded, testRunner.GetWorkflowActionStatus("Response_Success"));
57+
Assert.AreEqual(ActionStatus.Skipped, testRunner.GetWorkflowActionStatus("Response_Failure"));
58+
}
59+
}
60+
}
61+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<CustomerCampaigns xmlns="http://schemas.logicappunit.net/CustomerCampaign/v1">
2+
<Campaign>
3+
<CampaignId>7612</CampaignId>
4+
<CampaignName>This is a really long campaign name that will be shortened</CampaignName>
5+
<CustomerId>100567</CustomerId>
6+
<FirstName>Peter</FirstName>
7+
<LastName>Smith</LastName>
8+
<Email>[email protected]</Email>
9+
<Age>45</Age>
10+
<SiteCode>982</SiteCode>
11+
</Campaign>
12+
<Campaign>
13+
<CampaignId>7613</CampaignId>
14+
<CampaignName>Another campaign</CampaignName>
15+
<CustomerId>100845</CustomerId>
16+
<FirstName>John</FirstName>
17+
<LastName>Jackson</LastName>
18+
<Email>[email protected]</Email>
19+
<Age>29</Age>
20+
<SiteCode>1908</SiteCode>
21+
</Campaign>
22+
<Campaign>
23+
<CampaignId>7614</CampaignId>
24+
<CampaignName>Another campaign</CampaignName>
25+
<CustomerId>104009</CustomerId>
26+
<FirstName>Simon</FirstName>
27+
<LastName>Atkins</LastName>
28+
<Email>[email protected]</Email>
29+
<Age>50</Age>
30+
<SiteCode>1908</SiteCode>
31+
</Campaign>
32+
</CustomerCampaigns>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<tns:campaignRequest xmlns:tns="http://schemas.logicappunit.net/CampaignRequest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
numberOfCampaigns="3">
4+
<tns:campaign>
5+
<tns:campaignDetails>
6+
<tns:id>7612</tns:id>
7+
<tns:name>This is a really lo</tns:name>
8+
</tns:campaignDetails>
9+
<tns:customer>
10+
<tns:id>100567</tns:id>
11+
<tns:forename>Peter</tns:forename>
12+
<tns:surname>Smith</tns:surname>
13+
<tns:email>[email protected]</tns:email>
14+
<tns:age>45</tns:age>
15+
</tns:customer>
16+
<tns:premisesid>982</tns:premisesid>
17+
</tns:campaign>
18+
<tns:campaign>
19+
<tns:campaignDetails>
20+
<tns:id>7613</tns:id>
21+
<tns:name>Another campaign</tns:name>
22+
</tns:campaignDetails>
23+
<tns:customer>
24+
<tns:id>100845</tns:id>
25+
<tns:forename>John</tns:forename>
26+
<tns:surname>Jackson</tns:surname>
27+
<tns:email>[email protected]</tns:email>
28+
<tns:age>29</tns:age>
29+
</tns:customer>
30+
<tns:premisesid>1908</tns:premisesid>
31+
</tns:campaign>
32+
<tns:campaign>
33+
<tns:campaignDetails>
34+
<tns:id>7614</tns:id>
35+
<tns:name>Another campaign</tns:name>
36+
</tns:campaignDetails>
37+
<tns:customer>
38+
<tns:id>104009</tns:id>
39+
<tns:forename>Simon</tns:forename>
40+
<tns:surname>Atkins</tns:surname>
41+
<tns:email>[email protected]</tns:email>
42+
<tns:age>50</tns:age>
43+
</tns:customer>
44+
<tns:premisesid>1908</tns:premisesid>
45+
</tns:campaign>
46+
</tns:campaignRequest>

src/LogicAppUnit.Samples.LogicApps.Tests/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public static class Constants
1010

1111
// Workflows
1212
public static readonly string BUILT_IN_CONNECTOR_WORKFLOW = "built-in-connector-workflow";
13+
public static readonly string CALL_DATA_MAPPER_WORKFLOW = "call-data-mapper-workflow";
1314
public static readonly string CALL_LOCAL_FUNCTION_WORKFLOW = "call-local-function-workflow";
1415
public static readonly string FLUENT_REQUEST_MATCHING_WORKFLOW = "fluent-workflow";
1516
public static readonly string HTTP_WORKFLOW = "http-workflow";

src/LogicAppUnit.Samples.LogicApps.Tests/InlineScriptWorkflow/InlineScriptWorkflowTest.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
using LogicAppUnit.Helper;
2-
using LogicAppUnit.Mocking;
32
using Microsoft.VisualStudio.TestTools.UnitTesting;
4-
using Newtonsoft.Json.Linq;
5-
using System;
6-
using System.Collections.Generic;
7-
using System.Linq;
8-
using System.Net;
93
using System.Net.Http;
104

115
namespace LogicAppUnit.Samples.LogicApps.Tests.InlineScriptWorkflow
126
{
137
/// <summary>
14-
/// Test cases for the <i>http-workflow</i> workflow which uses a synchronous response for the HTTP trigger.
8+
/// Test cases for the <i>inline-script-workflow</i> workflow which calls a C# script (.csx).
159
/// </summary>
1610
[TestClass]
1711
public class InlineScriptWorkflowTest : WorkflowTestBase
@@ -29,7 +23,7 @@ public static void CleanResources()
2923
}
3024

3125
/// <summary>
32-
/// Tests that the correct response is returned when the HTTP call to the Service Two API to update the customer details is successful.
26+
/// Tests that the correct response is returned when the call to the C# script (.csx) is successful.
3327
/// </summary>
3428
[TestMethod]
3529
public void InlineScriptWorkflowTest_When_Successful()

src/LogicAppUnit.Samples.LogicApps.Tests/LogicAppUnit.Samples.LogicApps.Tests.csproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
<None Remove="BuiltInConnectorWorkflow\MockData\SQL_Request.json" />
2626
<None Remove="BuiltInConnectorWorkflow\MockData\SQL_Request_en_GB.json" />
2727
<None Remove="BuiltInConnectorWorkflow\MockData\SQL_Request_xx_GB.json" />
28+
<None Remove="CallDataMapperWorkflow\MockData\WorkflowRequest.xml" />
29+
<None Remove="CallDataMapperWorkflow\MockData\WorkflowResponse.xml" />
2830
<None Remove="FluentWorkflow\MockData\Response.ClueXml.xml" />
2931
<None Remove="FluentWorkflow\MockData\Response.json" />
3032
<None Remove="FluentWorkflow\MockData\Response.txt" />
@@ -46,6 +48,8 @@
4648
<EmbeddedResource Include="BuiltInConnectorWorkflow\MockData\ServiceBus_Request_NoLanguageCode.json" />
4749
<EmbeddedResource Include="BuiltInConnectorWorkflow\MockData\SQL_Request_xx_GB.json" />
4850
<EmbeddedResource Include="BuiltInConnectorWorkflow\MockData\SQL_Request_en_GB.json" />
51+
<EmbeddedResource Include="CallDataMapperWorkflow\MockData\WorkflowRequest.xml" />
52+
<EmbeddedResource Include="CallDataMapperWorkflow\MockData\WorkflowResponse.xml" />
4953
<EmbeddedResource Include="FluentWorkflow\MockData\Response.ClueXml.xml" />
5054
<EmbeddedResource Include="FluentWorkflow\MockData\Response.json" />
5155
<EmbeddedResource Include="FluentWorkflow\MockData\Response.txt" />
@@ -65,9 +69,9 @@
6569

6670
<ItemGroup>
6771
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.9" />
68-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
69-
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
70-
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
72+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
73+
<PackageReference Include="MSTest.TestAdapter" Version="3.6.1" />
74+
<PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
7175
</ItemGroup>
7276

7377
<ItemGroup>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
$version: 1
2+
$input: XML
3+
$output: XML
4+
$sourceSchema: CustomerCampaign.xsd
5+
$targetSchema: CampaignRequest.xsd
6+
$sourceNamespaces:
7+
ns0: http://schemas.logicappunit.net/CustomerCampaign/v1
8+
xs: http://www.w3.org/2001/XMLSchema
9+
$targetNamespaces:
10+
tns: http://schemas.logicappunit.net/CampaignRequest
11+
xs: http://www.w3.org/2001/XMLSchema
12+
tns:campaignRequest:
13+
$@numberOfCampaigns: count(/ns0:CustomerCampaigns/ns0:Campaign)
14+
$for(/ns0:CustomerCampaigns/ns0:Campaign):
15+
tns:campaign:
16+
tns:campaignDetails:
17+
tns:id: ns0:CampaignId
18+
tns:name: substring(ns0:CampaignName, 0, 20)
19+
tns:customer:
20+
tns:id: ns0:CustomerId
21+
tns:forename: substring(ns0:FirstName, 0, 40)
22+
tns:surname: substring(ns0:LastName, 0, 40)
23+
tns:email: ns0:Email
24+
tns:age: ns0:Age
25+
tns:premisesid: ns0:SiteCode
26+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<xsl:stylesheet xmlns:tns="http://schemas.logicappunit.net/CampaignRequest" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://schemas.logicappunit.net/CustomerCampaign/v1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:math="http://www.w3.org/2005/xpath-functions/math" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dm="http://azure.workflow.datamapper" xmlns:ef="http://azure.workflow.datamapper.extensions" exclude-result-prefixes="xsl xs math dm ef ns0" version="3.0" expand-text="yes">
2+
<xsl:output indent="yes" media-type="text/xml" method="xml" />
3+
<xsl:template match="/">
4+
<xsl:apply-templates select="." mode="azure.workflow.datamapper" />
5+
</xsl:template>
6+
<xsl:template match="/" mode="azure.workflow.datamapper">
7+
<tns:campaignRequest>
8+
<xsl:attribute name="numberOfCampaigns">{count(/ns0:CustomerCampaigns/ns0:Campaign)}</xsl:attribute>
9+
<xsl:for-each select="/ns0:CustomerCampaigns/ns0:Campaign">
10+
<tns:campaign>
11+
<tns:campaignDetails>
12+
<tns:id>{ns0:CampaignId}</tns:id>
13+
<tns:name>{substring(ns0:CampaignName, 0, 20)}</tns:name>
14+
</tns:campaignDetails>
15+
<tns:customer>
16+
<tns:id>{ns0:CustomerId}</tns:id>
17+
<tns:forename>{substring(ns0:FirstName, 0, 40)}</tns:forename>
18+
<tns:surname>{substring(ns0:LastName, 0, 40)}</tns:surname>
19+
<tns:email>{ns0:Email}</tns:email>
20+
<tns:age>{ns0:Age}</tns:age>
21+
</tns:customer>
22+
<tns:premisesid>{ns0:SiteCode}</tns:premisesid>
23+
</tns:campaign>
24+
</xsl:for-each>
25+
</tns:campaignRequest>
26+
</xsl:template>
27+
</xsl:stylesheet>

0 commit comments

Comments
 (0)