mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2025-12-31 15:49:31 -06:00
60 lines
2.2 KiB
C#
60 lines
2.2 KiB
C#
#if(DEBUG)
|
|
|
|
namespace BasicNodes.Tests
|
|
{
|
|
using FileFlows.BasicNodes.Functions;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
[TestClass]
|
|
public class PatternReplacerTests
|
|
{
|
|
[TestMethod]
|
|
public void PatternReplacer_Basic()
|
|
{
|
|
PatternReplacer node = new PatternReplacer();
|
|
node.Replacements = new List<KeyValuePair<string, string>>
|
|
{
|
|
new KeyValuePair<string, string>("Seinfeld", "Batman")
|
|
};
|
|
node.UnitTest = true;
|
|
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Seinfeld.mkv", new TestLogger(), false, string.Empty, null);;
|
|
|
|
var result = node.Execute(args);
|
|
Assert.AreEqual(1, result);
|
|
Assert.AreEqual(@"c:\test\Batman.mkv", args.WorkingFile);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void PatternReplacer_Regex()
|
|
{
|
|
PatternReplacer node = new PatternReplacer();
|
|
node.Replacements = new List<KeyValuePair<string, string>>
|
|
{
|
|
new KeyValuePair<string, string>(@"s([\d]+)e([\d]+)", "$1x$2"),
|
|
new KeyValuePair<string, string>(@"0([1-9]+x[\d]+)", "$1"),
|
|
};
|
|
node.UnitTest = true;
|
|
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Seinfeld S03E06.mkv", new TestLogger(), false, string.Empty, null);;
|
|
|
|
var result = node.Execute(args);
|
|
Assert.AreEqual(1, result);
|
|
Assert.AreEqual(@"c:\test\Seinfeld 3x06.mkv", args.WorkingFile);
|
|
}
|
|
[TestMethod]
|
|
public void PatternReplacer_Empty()
|
|
{
|
|
PatternReplacer node = new PatternReplacer();
|
|
node.Replacements = new List<KeyValuePair<string, string>>
|
|
{
|
|
new KeyValuePair<string, string>(@"\.h265", "EMPTY")
|
|
};
|
|
node.UnitTest = true;
|
|
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Seinfeld.h265.mkv", new TestLogger(), false, string.Empty, null);;
|
|
|
|
var result = node.RunReplacements(args, args.WorkingFile);
|
|
Assert.AreEqual(@"c:\test\Seinfeld.mkv", result);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif |