48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
using NUnit.Framework;
|
|
|
|
namespace Tests
|
|
{
|
|
internal class ScriptAddingTests
|
|
{
|
|
private const string pathToFile = "Assets/Tests/TempScript.cs";
|
|
|
|
[Test]
|
|
public void YourTestGoesHere()
|
|
{
|
|
|
|
}
|
|
|
|
private void CreateScript()
|
|
{
|
|
try
|
|
{
|
|
File.WriteAllText(pathToFile, @"
|
|
public class MyTempScript {
|
|
public string Verify()
|
|
{
|
|
return ""OK"";
|
|
}
|
|
}");
|
|
}
|
|
catch(DirectoryNotFoundException)
|
|
{
|
|
Assert.Inconclusive("The path to file is incorrect. Please make sure that the path to TempScript is valid.");
|
|
}
|
|
}
|
|
|
|
private string VerifyScript()
|
|
{
|
|
Type type = Type.GetType("MyTempScript", true);
|
|
|
|
object instance = Activator.CreateInstance(type);
|
|
|
|
var verifyMethod = type.GetMethod("Verify", BindingFlags.Instance | BindingFlags.Public);
|
|
|
|
var verifyResult = verifyMethod.Invoke(instance, new object[0]);
|
|
return verifyResult as string;
|
|
}
|
|
}
|
|
} |