Added WebRequest node

This commit is contained in:
John Andrews
2022-03-12 19:45:29 +13:00
parent 3375cdec40
commit b0b0067f6c
7 changed files with 216 additions and 1 deletions
+6
View File
@@ -4,6 +4,7 @@ namespace BasicNodes.Tests
{
using FileFlows.BasicNodes.File;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Text.RegularExpressions;
[TestClass]
public class ExecutorTests
@@ -24,6 +25,11 @@ namespace BasicNodes.Tests
string output = args.Variables["ExecOutput"] as string;
Assert.IsNotNull(output);
}
[TestMethod]
public void Executor_VariablePattern_Tests()
{
Assert.IsFalse(Regex.IsMatch(string.Empty, Executor.VariablePattern));
}
}
}
+38
View File
@@ -0,0 +1,38 @@
#if(DEBUG)
namespace BasicNodes.Tests
{
using BasicNodes.Tools;
using FileFlows.BasicNodes.File;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class WebRequestTests
{
[TestMethod]
public void WebRequest_PostJson()
{
var logger = new TestLogger();
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", logger, false, string.Empty);
WebRequest node = new();
node.Method = "POST";
node.Url = "http://localhost:7096/Users/New";
node.ContentType = "application/json";
node.Headers = new List<KeyValuePair<string, string>>();
node.Headers.Add(new KeyValuePair<string, string> ("X-MediaBrowser-Token", ""));
node.Body = @$"{{
""Name"": ""{Guid.NewGuid()}""
}}";
var result = node.Execute(args);
string body = node.Variables["web.Body"] as string;
Assert.IsFalse(string.IsNullOrWhiteSpace(body));
Assert.AreEqual(1, result);
}
}
}
#endif