mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2026-02-05 05:08:55 -06:00
FF-333 - fixing variable matches
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
61
BasicNodes/Tests/VariableMatchTests.cs
Normal file
61
BasicNodes/Tests/VariableMatchTests.cs
Normal 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.
Reference in New Issue
Block a user