Added unmanaged VBScrip Test.
--HG-- rename : aspclassiccompiler/VBScriptTest/TestRunner.cs => aspclassiccompiler/VBScriptTest/VBscriptDotNetTest.cs
This commit is contained in:
parent
48c9b91e26
commit
1a17abff27
14 changed files with 240 additions and 82 deletions
|
@ -29,6 +29,22 @@
|
|||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Dlrsoft.Asp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
|
|
@ -30,6 +30,22 @@
|
|||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Dlrsoft.Asp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
|
|
@ -84,6 +84,27 @@
|
|||
<WarningLevel>1</WarningLevel>
|
||||
<NoWarn>42016,42017,42018,42019,42032</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DefineDebug>true</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<DocumentationFile>Dlrsoft.VBParser.xml</DocumentationFile>
|
||||
<WarningLevel>1</WarningLevel>
|
||||
<NoWarn>42016,42017,42018,42019,42032</NoWarn>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<DocumentationFile>Dlrsoft.VBParser.xml</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<WarningLevel>1</WarningLevel>
|
||||
<NoWarn>42016,42017,42018,42019,42032</NoWarn>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<Name>System</Name>
|
||||
|
|
|
@ -1,20 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Dlrsoft.VBScript.Runtime
|
||||
{
|
||||
public interface IAssert
|
||||
{
|
||||
void AreEqual(object expected, object actual);
|
||||
void AreEqual(object expected, object actual, string message);
|
||||
void AreNotEqual(object notExpected, object actual);
|
||||
void AreNotEqual(object notExpected, object actual, string message);
|
||||
void Fail();
|
||||
void Fail(string message);
|
||||
void IsFalse(bool condition);
|
||||
void IsFalse(bool condition, string message);
|
||||
void IsTrue(bool condition);
|
||||
void IsTrue(bool condition, string message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,22 @@
|
|||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;USE35</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;USE35</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Dynamic, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
|
53
aspclassiccompiler/VBScriptTest/DirectoryWalker.cs
Normal file
53
aspclassiccompiler/VBScriptTest/DirectoryWalker.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Dlrsoft.VBScriptTest
|
||||
{
|
||||
public class DirectoryWalker
|
||||
{
|
||||
static public string AssemblyDirectory
|
||||
{
|
||||
get
|
||||
{
|
||||
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
|
||||
UriBuilder uri = new UriBuilder(codeBase);
|
||||
string path = Uri.UnescapeDataString(uri.Path);
|
||||
return Path.GetDirectoryName(path);
|
||||
}
|
||||
}
|
||||
|
||||
static public void Walk(string path, Action<string> fileHandler)
|
||||
{
|
||||
FileAttributes fa = File.GetAttributes(path);
|
||||
if ((fa & FileAttributes.Directory) == FileAttributes.Directory)
|
||||
{
|
||||
Walk(new DirectoryInfo(path), fileHandler);
|
||||
}
|
||||
else
|
||||
{
|
||||
Walk(new FileInfo(path), fileHandler);
|
||||
}
|
||||
}
|
||||
|
||||
static private void Walk(DirectoryInfo di, Action<string> fileHandler)
|
||||
{
|
||||
foreach (FileInfo fi in di.GetFiles())
|
||||
{
|
||||
Walk(fi, fileHandler);
|
||||
}
|
||||
|
||||
foreach (DirectoryInfo cdi in di.GetDirectories())
|
||||
{
|
||||
Walk(cdi, fileHandler);
|
||||
}
|
||||
}
|
||||
|
||||
static private void Walk(FileInfo fi, Action<string> fileHandler)
|
||||
{
|
||||
fileHandler(fi.FullName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,58 +3,35 @@ using System.Collections.Generic;
|
|||
using System.Text;
|
||||
using Dlrsoft.VBScript.Runtime;
|
||||
using NUnit.Framework;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Dlrsoft.VBScriptTest
|
||||
{
|
||||
[ComVisible(true)]
|
||||
public class NunitAssert : IAssert
|
||||
{
|
||||
#region IAssert Members
|
||||
|
||||
public void AreEqual(object expected, object actual)
|
||||
{
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
public void AreEqual(object expected, object actual, string message)
|
||||
{
|
||||
Assert.AreEqual(expected, actual, message);
|
||||
}
|
||||
|
||||
public void AreNotEqual(object notExpected, object actual)
|
||||
{
|
||||
Assert.AreNotEqual(notExpected, actual);
|
||||
}
|
||||
|
||||
public void AreNotEqual(object notExpected, object actual, string message)
|
||||
{
|
||||
Assert.AreNotEqual(notExpected, actual, message);
|
||||
}
|
||||
|
||||
public void Fail()
|
||||
{
|
||||
Assert.Fail();
|
||||
}
|
||||
|
||||
public void Fail(string message)
|
||||
{
|
||||
Assert.Fail(message);
|
||||
}
|
||||
|
||||
public void IsFalse(bool condition)
|
||||
{
|
||||
Assert.IsFalse(condition);
|
||||
}
|
||||
|
||||
public void IsFalse(bool condition, string message)
|
||||
{
|
||||
Assert.IsFalse(condition, message);
|
||||
}
|
||||
|
||||
public void IsTrue(bool condition)
|
||||
{
|
||||
Assert.IsTrue(condition);
|
||||
}
|
||||
|
||||
public void IsTrue(bool condition, string message)
|
||||
{
|
||||
Assert.IsTrue(condition, message);
|
||||
|
|
34
aspclassiccompiler/VBScriptTest/UnmanagedVBScriptTest.cs
Normal file
34
aspclassiccompiler/VBScriptTest/UnmanagedVBScriptTest.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using System.IO;
|
||||
|
||||
namespace Dlrsoft.VBScriptTest
|
||||
{
|
||||
[TestFixture]
|
||||
public class UnmanagedVBScriptTest
|
||||
{
|
||||
[Test]
|
||||
public void RunTest()
|
||||
{
|
||||
DirectoryWalker.Walk(
|
||||
Path.Combine(DirectoryWalker.AssemblyDirectory, "../../VBScripts"),
|
||||
f =>
|
||||
{
|
||||
if (f.EndsWith(".vbs", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
try
|
||||
{
|
||||
UnmangedVBScriptHost.Run(f);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Assert.Fail(f + ":" + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
38
aspclassiccompiler/VBScriptTest/UnmangedVBScriptHost.cs
Normal file
38
aspclassiccompiler/VBScriptTest/UnmangedVBScriptHost.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using MSScriptControl;
|
||||
using System.IO;
|
||||
using Dlrsoft.VBScript.Runtime;
|
||||
|
||||
namespace Dlrsoft.VBScriptTest
|
||||
{
|
||||
public class UnmangedVBScriptHost
|
||||
{
|
||||
public static void Run(string filePath)
|
||||
{
|
||||
ScriptControlClass scripter = new ScriptControlClass();
|
||||
|
||||
try {
|
||||
scripter.Language = "VBScript";
|
||||
scripter.AllowUI = false;
|
||||
scripter.UseSafeSubset = true;
|
||||
IAssert assert = new NunitAssert();
|
||||
scripter.AddObject("Assert", assert, false);
|
||||
|
||||
string code = File.ReadAllText(filePath);
|
||||
scripter.AddCode(code);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(scripter);
|
||||
scripter = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -55,10 +55,13 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DirectoryWalker.cs" />
|
||||
<Compile Include="NunitAssert.cs" />
|
||||
<Compile Include="UnmanagedVBScriptTest.cs" />
|
||||
<Compile Include="UnmangedVBScriptHost.cs" />
|
||||
<Compile Include="VBScriptTestHelper.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TestRunner.cs" />
|
||||
<Compile Include="VBscriptDotNetTest.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\VBScript\VBScript.csproj">
|
||||
|
@ -69,6 +72,16 @@
|
|||
<ItemGroup>
|
||||
<Content Include="VBScripts\DataTypes.vbs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<COMReference Include="MSScriptControl">
|
||||
<Guid>{0E59F1D2-1FBE-11D0-8FF2-00A0D10038BC}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Dynamic;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
#if USE35
|
||||
using Microsoft.Scripting.Hosting;
|
||||
using Microsoft.Scripting.Ast;
|
||||
|
@ -39,48 +37,5 @@ namespace Dlrsoft.VBScriptTest
|
|||
feo.SetVariable("Assert", new NunitAssert());
|
||||
compiledCode.Execute(feo);
|
||||
}
|
||||
|
||||
static public string AssemblyDirectory
|
||||
{
|
||||
get
|
||||
{
|
||||
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
|
||||
UriBuilder uri = new UriBuilder(codeBase);
|
||||
string path = Uri.UnescapeDataString(uri.Path);
|
||||
return Path.GetDirectoryName(path);
|
||||
}
|
||||
}
|
||||
|
||||
static public void Walk(string path, Action<string> fileHandler)
|
||||
{
|
||||
FileAttributes fa = File.GetAttributes(path);
|
||||
if ((fa & FileAttributes.Directory) == FileAttributes.Directory)
|
||||
{
|
||||
Walk(new DirectoryInfo(path), fileHandler);
|
||||
}
|
||||
else
|
||||
{
|
||||
Walk(new FileInfo(path), fileHandler);
|
||||
}
|
||||
}
|
||||
|
||||
static private void Walk(DirectoryInfo di, Action<string> fileHandler)
|
||||
{
|
||||
foreach (FileInfo fi in di.GetFiles())
|
||||
{
|
||||
Walk(fi, fileHandler);
|
||||
}
|
||||
|
||||
foreach (DirectoryInfo cdi in di.GetDirectories())
|
||||
{
|
||||
Walk(cdi, fileHandler);
|
||||
}
|
||||
}
|
||||
|
||||
static private void Walk(FileInfo fi, Action<string> fileHandler)
|
||||
{
|
||||
fileHandler(fi.FullName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
dim a
|
||||
Assert.IsTrue(IsEmpty(a), "Unassigned variable must be empty")
|
||||
Assert.IsTrue IsEmpty(a), "Unassigned variable must be empty"
|
||||
|
|
|
@ -10,9 +10,9 @@ namespace Dlrsoft.VBScriptTest
|
|||
/// Summary description for UnitTest1
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class TestRunner
|
||||
public class VBscriptDotNetTest
|
||||
{
|
||||
public TestRunner()
|
||||
public VBscriptDotNetTest()
|
||||
{
|
||||
//
|
||||
// TODO: Add constructor logic here
|
||||
|
@ -62,13 +62,20 @@ namespace Dlrsoft.VBScriptTest
|
|||
[Test]
|
||||
public void RunTest()
|
||||
{
|
||||
VBScriptTestHelper.Walk(
|
||||
Path.Combine(VBScriptTestHelper.AssemblyDirectory, "../../VBScripts"),
|
||||
DirectoryWalker.Walk(
|
||||
Path.Combine(DirectoryWalker.AssemblyDirectory, "../../VBScripts"),
|
||||
f =>
|
||||
{
|
||||
if (f.EndsWith(".vbs", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
VBScriptTestHelper.Run(f);
|
||||
try
|
||||
{
|
||||
VBScriptTestHelper.Run(f);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Assert.Fail(f + ":" + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
|
@ -30,6 +30,22 @@
|
|||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Dynamic, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
|
Loading…
Add table
Reference in a new issue