This commit is contained in:
John Andrews
2024-08-17 09:42:14 +12:00
parent 2bdfea4999
commit c465a2843e
4 changed files with 27 additions and 4 deletions

View File

@@ -93,6 +93,7 @@ public class Matches : Node
}
catch (Exception)
{
// Ignored
}
}

View File

@@ -6,12 +6,11 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace BasicNodes.Tests;
[TestClass]
public class MatchesTests
public class MatchesTests : TestBase
{
[TestMethod]
public void Matches_Math()
{
var logger = new TestLogger();
Matches ele = new ();
ele.MatchConditions = new()
{
@@ -19,14 +18,37 @@ public class MatchesTests
new("{file.Size}", ">100KB"),
new("{file.Size}", ">10MB"),
};
var args = new FileFlows.Plugin.NodeParameters(null, logger,
var args = new FileFlows.Plugin.NodeParameters(null, Logger,
false, string.Empty, new LocalFileService());
args.Variables["file.Size"] = 120_000; // 120KB
var result = ele.Execute(args);
var log = logger.ToString();
Assert.AreEqual(2, result);
}
[TestMethod]
public void Matches_EqualsOne()
{
foreach (var test in new[]
{
((object)1, "=1"),
((object)"1", "=1"),
((object)1, "1"),
((object)"1", "1"),
})
{
Matches ele = new();
ele.MatchConditions = new()
{
new("{myVariable}", test.Item2)
};
var args = new FileFlows.Plugin.NodeParameters(null, Logger,
false, string.Empty, new LocalFileService());
args.Variables["myVariable"] = test.Item1;
var result = ele.Execute(args);
Assert.AreEqual(1, result);
}
}
[TestMethod]
public void Matches_String()

Binary file not shown.

Binary file not shown.