You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
883 B
38 lines
883 B
1 year ago
|
using Python.Runtime;
|
||
|
using StabilityMatrix.Python;
|
||
|
|
||
|
namespace StabilityMatrix.Tests.Python;
|
||
|
|
||
|
[TestClass]
|
||
|
public class PyRunnerTests
|
||
|
{
|
||
|
private static readonly PyRunner PyRunner = new();
|
||
|
|
||
|
[ClassInitialize]
|
||
|
public static async Task TestInitialize(TestContext testContext)
|
||
|
{
|
||
|
await PyRunner.Initialize();
|
||
|
}
|
||
|
|
||
|
[TestMethod]
|
||
|
public void PythonEngine_ShouldBeInitialized()
|
||
|
{
|
||
|
Assert.IsTrue(PythonEngine.IsInitialized);
|
||
|
}
|
||
|
|
||
|
[TestMethod]
|
||
|
public async Task RunEval_ShouldReturnOutput()
|
||
|
{
|
||
|
// Arrange
|
||
|
const string script = "print('Hello World')";
|
||
|
|
||
|
// Act
|
||
|
var result = await PyRunner.Eval(script);
|
||
|
var stdout = PyRunner.StdOutStream!.GetBuffer();
|
||
|
|
||
|
// Assert
|
||
|
Assert.AreEqual("Hello World\n", stdout);
|
||
|
Assert.AreEqual("None", result);
|
||
|
}
|
||
|
}
|