Skip to content

Commit

Permalink
chore: Refactor to fit new structure
Browse files Browse the repository at this point in the history
  • Loading branch information
thygesteffensen committed Jul 29, 2024
1 parent e0b6d65 commit 924467c
Show file tree
Hide file tree
Showing 127 changed files with 82 additions and 98 deletions.
Empty file added samples/.gitkeep
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
using Parser;
using Parser.ExpressionParser;
using Parser.FlowParser.ActionExecutors;
using Parser.FlowParser.ActionExecutors.Implementations;
using Parser.FlowParser.ActionExecutors.Implementations.ControlActions;

namespace Test.ActionTests
namespace PowerAutomateMockUp.Tests.ActionTests
{
[TestFixture]
public class DoUntilActionExecutorTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
using Parser;
using Parser.ExpressionParser;
using Parser.FlowParser.ActionExecutors;
using Parser.FlowParser.ActionExecutors.Implementations;
using Parser.FlowParser.ActionExecutors.Implementations.ControlActions;

namespace Test.ActionTests
namespace PowerAutomateMockUp.Tests.ActionTests
{
[TestFixture]
public class ForEachActionExecutorTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using Parser.FlowParser.ActionExecutors;
using Parser.FlowParser.ActionExecutors.Implementations.ControlActions;

namespace Test.ActionTests
namespace PowerAutomateMockUp.Tests.ActionTests
{
[TestFixture]
public class IfActionExecutorTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Parser;
using Parser.FlowParser.ActionExecutors;

namespace Test.ActionTests
namespace PowerAutomateMockUp.Tests.ActionTests
{
[TestFixture]
public class ScopeActionExecutorTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
using Parser;
using Parser.ExpressionParser;
using Parser.FlowParser.ActionExecutors;
using Parser.FlowParser.ActionExecutors.Implementations;
using Parser.FlowParser.ActionExecutors.Implementations.ControlActions;

namespace Test.ActionTests
namespace PowerAutomateMockUp.Tests.ActionTests
{
[TestFixture]
public class SwitchActionTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Parser.FlowParser.ActionExecutors;
using Parser.FlowParser.ActionExecutors.Implementations.ControlActions;

namespace Test.ActionTests
namespace PowerAutomateMockUp.Tests.ActionTests
{
[TestFixture]
public class TerminateActionTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Parser.ExpressionParser;
using Parser.ExpressionParser.Functions.Implementations.CollectionFunctions;

namespace Test.Expression
namespace PowerAutomateMockUp.Tests.Expressions
{
public class CollectionFunctionTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Parser.ExpressionParser;
using Parser.ExpressionParser.Functions.Implementations.ConversionFunctions;

namespace Test.Expression
namespace PowerAutomateMockUp.Tests.Expressions
{
public class ConversionFunctionTest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Parser.ExpressionParser;
using Parser.ExpressionParser.Functions.Base;

namespace Test.Expression
namespace PowerAutomateMockUp.Tests.Expressions
{
[TestFixture]
public class GenericExpressionTest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Parser.ExpressionParser;
using Parser.ExpressionParser.Functions.Implementations.LogicalComparisonFunctions;

namespace Test.Expression
namespace PowerAutomateMockUp.Tests.Expressions
{
public class LogicalFunctionTest
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Parser.ExpressionParser;
using Parser.ExpressionParser.Functions.Math;

namespace Test.Expression
namespace PowerAutomateMockUp.Tests.Expressions
{
public class MathFunctionTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Parser.ExpressionParser;
using Parser.ExpressionParser.Functions.Implementations.StringFunctions;

namespace Test.Expression
namespace PowerAutomateMockUp.Tests.Expressions
{
[TestFixture]
public class StringFunctionTests
Expand Down Expand Up @@ -49,7 +49,7 @@ public class StringFunctionTests
new FormatNumberFunction(),
"formatNumber",
new[] {new ValueContainer(17.35), new ValueContainer("C2"), new ValueContainer("is-is")},
new ValueContainer("17,35 kr")
new ValueContainer("17,35 ISK")
},
new object[]
{
Expand All @@ -73,13 +73,6 @@ public class StringFunctionTests
new ValueContainer(0)
},
new object[]
{
new LastIndexOfFunction(),
"lastIndexOf",
new[] {new ValueContainer("Hey there"), new ValueContainer("e")},
new ValueContainer(8)
},
new object[]
{
new LastIndexOfFunction(),
"lastIndexOf",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
Expand All @@ -8,17 +9,17 @@
using Parser.FlowParser;
using Parser.FlowParser.ActionExecutors;

namespace Test
namespace PowerAutomateMockUp.Tests
{
[TestFixture]
public class FullFlowTest
{
private static readonly string TestFlowPath = System.IO.Path.GetFullPath(@"FlowSamples");
private static readonly string TestFlowPath = Path.GetFullPath("FlowSamples");

[Test]
public async Task TestFlowFalse()
{
var path = @$"{TestFlowPath}\PowerAutomateMockUpSampleFlow.json";
var path = Path.Combine(TestFlowPath, "PowerAutomateMockUpSampleFlow.json");

var services = new ServiceCollection();

Expand Down Expand Up @@ -56,7 +57,7 @@ public async Task TestFlowFalse()
private class TriggerActionExecutor : DefaultBaseActionExecutor
{
public const string ApiId = "/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps";
public static readonly string[] SupportedOperations = {"SubscribeWebhookTrigger"};
public static readonly string[] SupportedOperations = { "SubscribeWebhookTrigger" };

public override Task<ActionResult> Execute()
{
Expand All @@ -65,26 +66,28 @@ public override Task<ActionResult> Execute()
ActionStatus = ActionStatus.Succeeded, ActionOutput = new ValueContainer(
new Dictionary<string, ValueContainer>
{
{"body/name", new ValueContainer("Alice Bob")},
{"body/accountid", new ValueContainer(Guid.NewGuid().ToString())}
{ "body/name", new ValueContainer("Alice Bob") },
{ "body/accountid", new ValueContainer(Guid.NewGuid().ToString()) }
})
});
}
}

private class UpdateAccountInvalidId :
private class UpdateAccountInvalidId :
OpenApiConnectionActionExecutorBase
{
public const string FlowActionName =
public const string FlowActionName =
"Update_Account_-_Invalid_Id";

public override Task<ActionResult> Execute()
{
Assert.AreEqual(FlowActionName, ActionName);

return Task.FromResult(new ActionResult
{ActionStatus = ActionStatus.Failed,
ActionOutput = new ValueContainer(true)});
{
ActionStatus = ActionStatus.Failed,
ActionOutput = new ValueContainer(true)
});
}

public UpdateAccountInvalidId(
Expand All @@ -96,7 +99,7 @@ public UpdateAccountInvalidId(
private class SendEmailNotification : OpenApiConnectionActionExecutorBase
{
public const string ApiId = "/providers/Microsoft.PowerApps/apis/shared_flowpush";
public static readonly string[] SupportedOperations = {"SendEmailNotification"};
public static readonly string[] SupportedOperations = { "SendEmailNotification" };

public override Task<ActionResult> Execute()
{
Expand All @@ -105,7 +108,7 @@ public override Task<ActionResult> Execute()
Console.WriteLine($"Email Title: {Parameters["NotificationEmailDefinition/notificationSubject"]}");
Console.WriteLine($"Email Content: {Parameters["NotificationEmailDefinition/notificationBody"]}");

return Task.FromResult(new ActionResult {ActionOutput = new ValueContainer(true)});
return Task.FromResult(new ActionResult { ActionOutput = new ValueContainer(true) });
}

public SendEmailNotification(IExpressionEngine expressionEngine) : base(expressionEngine)
Expand All @@ -128,7 +131,7 @@ public override Task<ActionResult> Execute()
Assert.AreEqual("accounts", Parameters["entityName"].GetValue<string>());
Assert.AreNotEqual(ValueContainer.ValueType.Null, Parameters["recordId"]);

return Task.FromResult(new ActionResult {ActionOutput = new ValueContainer(true)});
return Task.FromResult(new ActionResult { ActionOutput = new ValueContainer(true) });
}
}

Expand Down Expand Up @@ -165,4 +168,4 @@ public SendOutWarning(IExpressionEngine expressionEngine) :
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
Expand All @@ -8,17 +9,17 @@
using Parser.FlowParser;
using Parser.FlowParser.ActionExecutors;

namespace Test
namespace PowerAutomateMockUp.Tests
{
[TestFixture]
public class FullFlowTestV2
{
private static readonly string TestFlowPath = System.IO.Path.GetFullPath(@"FlowSamples");
private static readonly string TestFlowPath = Path.GetFullPath("FlowSamples");

[Test]
public async Task TestFlowFalse()
{
var path = @$"{TestFlowPath}\PowerAutomateMockUpSampleFlow.json";
var path = Path.Combine(TestFlowPath, "PowerAutomateMockUpSampleFlow.json");

var services = new ServiceCollection();
services.AddFlowRunner();
Expand Down Expand Up @@ -55,6 +56,7 @@ public async Task TestFlowFalse()
Assert.IsTrue(flowResult.ActionStates.ContainsKey(actionName), "Action is expected to be triggered.");
Assert.NotNull(flowResult.ActionStates[actionName].ActionInput?["parameters"], "Action input is expected.");
var actionInput = flowResult.ActionStates[actionName].ActionInput?["parameters"].AsDict();
Assert.IsNotNull(actionInput);
Assert.IsTrue(actionInput.ContainsKey("NotificationEmailDefinition"),
"Action input should contain this object.");
var notification = actionInput["NotificationEmailDefinition"].AsDict();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
using Parser;
using Parser.ExpressionParser;
using Parser.ExpressionParser.Functions.Base;
using Parser.ExpressionParser.Functions.Implementations.ConversionFunctions;
using Parser.FlowParser;
using Parser.FlowParser.ActionExecutors;

namespace Test
namespace PowerAutomateMockUp.Tests
{
[TestFixture]
public class FullFlowTestWithException
{
private static readonly string TestFlowPath = System.IO.Path.GetFullPath(@"FlowSamples");
private static readonly string TestFlowPath = Path.GetFullPath("FlowSamples");

[Test]
public void TestFlowFalse()
{
var path = @$"{TestFlowPath}\PowerAutomateMockUpSampleFlow.json";
var path = Path.Combine(TestFlowPath, "PowerAutomateMockUpSampleFlow.json");

var services = new ServiceCollection();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
using Parser;
using Parser.ExpressionParser;
using Parser.ExpressionParser.Functions.Base;
using Parser.FlowParser;
using Parser.FlowParser.ActionExecutors;

namespace Test
namespace PowerAutomateMockUp.Tests
{
[TestFixture]
public class OpenApiConnectionActionExecutorBaseTest
{
private static readonly string TestFlowPath = System.IO.Path.GetFullPath(@"FlowSamples");
private static readonly string TestFlowPath = Path.GetFullPath("FlowSamples");

[Test]
public async Task TestFlowFalse()
{
var path = @$"{TestFlowPath}\Pure CDS ce.json";
var path = Path.Combine(TestFlowPath, "Pure CDS ce.json");

var services = new ServiceCollection();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
using Parser;
using Parser.ExpressionParser;
using Parser.ExpressionParser.Functions.Base;
using Parser.FlowParser;
using Parser.FlowParser.ActionExecutors;

namespace Test
namespace PowerAutomateMockUp.Tests
{
[TestFixture]
public class PAMUApplyToEachTest
{
private static readonly string TestFlowPath = System.IO.Path.GetFullPath(@"FlowSamples");
private static readonly string TestFlowPath = Path.GetFullPath("FlowSamples");

[Test]
public async Task TestForEachFlow()
{
var path = @$"{TestFlowPath}\PAMUApplyToEach.json";
var path = Path.Combine(TestFlowPath, "PAMUApplyToEach.json");

var services = new ServiceCollection();

Expand Down
Loading

0 comments on commit 924467c

Please sign in to comment.