FF-333 - fixing variable matches

This commit is contained in:
John Andrews
2022-09-26 10:57:13 +13:00
parent 76b8ecdd91
commit 3bf9ee3d03
4 changed files with 64 additions and 2 deletions

View File

@@ -7,7 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BasicNodes.Functions;
namespace FileFlows.BasicNodes.Functions;
/// <summary>
/// Tests if an input value is matched by a variable
@@ -33,7 +33,8 @@ public class VariableMatch : Node
public override int Execute(NodeParameters args)
{
bool matches = args.MatchesVariable(Variable?.Name, Input);
string test= args.ReplaceVariables(Input, stripMissing: true);
bool matches = args.MatchesVariable(Variable.Name, test);
return matches ? 1 : 2;
}
}

View File

@@ -0,0 +1,61 @@
#if(DEBUG)
namespace BasicNodes.Tests;
using FileFlows.BasicNodes.Functions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class VariableMatchTests
{
FileFlows.Plugin.NodeParameters Args;
private string TestVariable = @"Batman
/bobby/i
/Bobby Drake/
";
[TestInitialize]
public void TestStarting()
{
Args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", new TestLogger(), false, string.Empty);
Args.GetToolPathActual = (arg) => TestVariable;
}
[TestMethod]
public void VariableMatch_Match()
{
VariableMatch vm = new VariableMatch();
vm.Variable = new FileFlows.Plugin.ObjectReference() { Name = "test" };
vm.Input = "bobby drake";
vm.PreExecute(Args);
var result = vm.Execute(Args);
Assert.AreEqual(1, result);
}
[TestMethod]
public void VariableMatch_Match2()
{
VariableMatch vm = new VariableMatch();
vm.Variable = new FileFlows.Plugin.ObjectReference() { Name = "test" };
vm.Input = "BOBBY Two";
vm.PreExecute(Args);
var result = vm.Execute(Args);
Assert.AreEqual(1, result);
}
[TestMethod]
public void VariableMatch_NoMatch()
{
VariableMatch vm = new VariableMatch();
vm.Variable = new FileFlows.Plugin.ObjectReference() { Name = "test" };
vm.Input = "Robert Drake";
vm.PreExecute(Args);
var result = vm.Execute(Args);
Assert.AreEqual(2, result);
}
}
#endif

Binary file not shown.

Binary file not shown.