-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
91 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,27 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using net.r_eg.LuNari.API; | ||
using net.r_eg.LuNari.API.Lua51; | ||
using Xunit; | ||
|
||
namespace net.r_eg.LuNariTest.API | ||
namespace LuNariTest.API | ||
{ | ||
[TestClass] | ||
public class BridgeTest | ||
{ | ||
[TestMethod] | ||
//[ExpectedException(typeof(ArgumentException))] | ||
[Fact] | ||
public void providerTest1() | ||
{ | ||
try { | ||
Assert.Throws<ArgumentException>(() => | ||
{ | ||
new Bridge<ILua51>(null); | ||
Assert.Fail("1"); | ||
} | ||
catch(Exception ex) { Assert.IsTrue(ex.GetType() == typeof(ArgumentException), ex.GetType().ToString()); } | ||
}); | ||
} | ||
|
||
var bridge = new Bridge<ILua51>(new _Lua()); | ||
[Fact] | ||
public void providerTest2() | ||
{ | ||
var l = new Bridge<ILua51>(new StubLua()); | ||
Assert.NotNull(l.Lua); | ||
Assert.Equal(LuaVersion.Lua53, l.Version); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{BC464A8F-DA52-4F2B-87FC-F79D130A15FF}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>net.r_eg.LuNariTest</RootNamespace> | ||
<AssemblyName>LuNariTest</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath> | ||
<IsCodedUITest>False</IsCodedUITest> | ||
<TestProjectType>UnitTest</TestProjectType> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.0</TargetFramework> | ||
<IsPackable>false</IsPackable> | ||
<SignAssembly>true</SignAssembly> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile> | ||
<RootNamespace>LuNariTest</RootNamespace> | ||
<NoWarn>IDE0063,IDE1006</NoWarn> | ||
<PlatformTarget>x64</PlatformTarget> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core"> | ||
<RequiredTargetFramework>3.5</RequiredTargetFramework> | ||
</Reference> | ||
</ItemGroup> | ||
<Choose> | ||
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'"> | ||
<ItemGroup> | ||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" /> | ||
</ItemGroup> | ||
</When> | ||
<Otherwise> | ||
<ItemGroup> | ||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" /> | ||
</ItemGroup> | ||
</Otherwise> | ||
</Choose> | ||
<ItemGroup> | ||
<Compile Include="API\BridgeTest.cs" /> | ||
<Compile Include="LuaTest.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="_Lua.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Conari\Conari\Conari.csproj"> | ||
<Project>{27152fd4-7b94-4af0-a7ed-be7e7a196d57}</Project> | ||
<Name>Conari</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\LuNari\LuNari.csproj"> | ||
<Project>{359a216f-1b6d-4a82-b75a-09509a23830a}</Project> | ||
<Name>LuNari</Name> | ||
</ProjectReference> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="1.1.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="key.snk" /> | ||
<ProjectReference Include="..\Conari\Conari\Conari.csproj" /> | ||
<ProjectReference Include="..\LuNari\LuNari.csproj" /> | ||
</ItemGroup> | ||
<Choose> | ||
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'"> | ||
<ItemGroup> | ||
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<Private>False</Private> | ||
</Reference> | ||
</ItemGroup> | ||
</When> | ||
</Choose> | ||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" /> | ||
<Import Project="$(MSBuildToolsPath)\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. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,135 +1,122 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using net.r_eg.Conari.Exceptions; | ||
using net.r_eg.LuNari; | ||
using net.r_eg.LuNari.API; | ||
using net.r_eg.LuNari.API.Lua51; | ||
using net.r_eg.LuNari.API.Lua52; | ||
using Xunit; | ||
|
||
namespace net.r_eg.LuNariTest | ||
namespace LuNariTest | ||
{ | ||
[TestClass] | ||
public class LuaTest | ||
{ | ||
private const string STUB_LIB_NAME = "__ThisIsNotRealLuaLib"; | ||
|
||
[TestMethod] | ||
[Fact] | ||
public void loadTest1() | ||
{ | ||
try { | ||
new Lua(null); | ||
Assert.Fail("1"); | ||
} | ||
catch(Exception ex) { Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException), ex.GetType().ToString()); } | ||
Assert.Throws<ArgumentNullException>(() => new Lua(null)); | ||
|
||
try { | ||
new Lua(STUB_LIB_NAME); | ||
Assert.Fail("2"); | ||
} | ||
catch(Exception ex) { Assert.IsTrue(ex.GetType() == typeof(LoadLibException), ex.GetType().ToString()); } | ||
|
||
Assert.Throws<LoadLibException>(() => new Lua(STUB_LIB_NAME)); | ||
|
||
Assert.Throws<ArgumentNullException>(() => new Lua(string.Empty)); | ||
} | ||
|
||
[TestMethod] | ||
//[ExpectedException(typeof(ArgumentException))] | ||
public void loadTest2() | ||
/// <summary> | ||
/// [high to low] | ||
/// To pass, we shouldn't see InvalidCastException | ||
/// </summary> | ||
[Fact] | ||
public void castingTest1() | ||
{ | ||
new _Lua(); | ||
var cfg = new LuaConfig() { LazyLoading = true }; | ||
|
||
using(var l = new Lua<ILua52>(cfg)) | ||
{ | ||
Assert.Equal(LuaVersion.Lua52, l.API.Version); | ||
|
||
Assert.Equal(LuaVersion.Lua52, ((ILua51)l.API).Version); | ||
|
||
try { | ||
new Lua(""); | ||
Assert.Fail("2"); | ||
Assert.Equal(LuaVersion.Lua51, (l.v<ILua51>()).Version); | ||
} | ||
catch(Exception ex) { Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException), ex.GetType().ToString()); } | ||
} | ||
|
||
/// <summary> | ||
/// [high to low] | ||
/// To pass, we shouldn't see InvalidCastException | ||
/// </summary> | ||
[TestMethod] | ||
public void castingTest1() | ||
[Fact] | ||
public void castingTest2() | ||
{ | ||
var cfg = new LuaConfig() { LazyLoading = true }; | ||
|
||
using(var l = new Lua<ILua52>(cfg)) { | ||
var a = (ILua51)l.API; | ||
var b = l.v<ILua51>(); | ||
} | ||
using(ILua l = new Lua<ILua52>(cfg)) | ||
{ | ||
Assert.Equal(LuaVersion.Lua53, ((ILua51)l.U).Version); // because l.U contains latest ILuaN | ||
|
||
using(ILua l = new Lua<ILua52>(cfg)) { | ||
var a = (ILua51)l.U; | ||
var b = l.v<ILua51>(); | ||
Assert.Equal(LuaVersion.Lua51, (l.v<ILua51>()).Version); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// [low to high] | ||
/// To pass, we shouldn't see InvalidCastException | ||
/// </summary> | ||
[TestMethod] | ||
public void castingTest2() | ||
[Fact] | ||
public void castingTest3() | ||
{ | ||
var cfg = new LuaConfig() { LazyLoading = true }; | ||
|
||
using(ILua l = new Lua<ILua51>(cfg)) { | ||
var a = (ILua52)l.U; // because l.U contains latest ILuaN | ||
var b = l.v<ILua52>(); // because it recreates initial bridge | ||
} | ||
using(ILua l = new Lua<ILua51>(cfg)) | ||
{ | ||
Assert.Equal(LuaVersion.Lua53, ((ILua52)l.U).Version); // because l.U contains latest ILuaN | ||
|
||
using(var l = new Lua<ILua51>(cfg)) { | ||
var a = (ILua52)l.U; // because l.U contains latest ILuaN | ||
var b = l.v<ILua52>(); // because it recreates initial bridge | ||
Assert.Equal(LuaVersion.Lua52, (l.v<ILua52>()).Version); // because it recreates initial bridge | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// [low to high] | ||
/// </summary> | ||
[TestMethod] | ||
[ExpectedException(typeof(InvalidCastException))] | ||
public void castingTest3() | ||
[Fact] | ||
public void castingTest4() | ||
{ | ||
var cfg = new LuaConfig() { LazyLoading = true }; | ||
|
||
using(var l = new Lua<ILua51>(cfg)) { | ||
var a = (ILua52)l.API; // std. l.API contains the initialized 51 | ||
using(var l = new Lua<ILua51>(cfg)) | ||
{ | ||
Assert.Throws<InvalidCastException>(() => (ILua52)l.API); // std. l.API contains the initialized 51 | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// between ILua | ||
/// To pass, we shouldn't see InvalidCastException | ||
/// </summary> | ||
[TestMethod] | ||
public void castingTest4() | ||
[Fact] | ||
public void castingTest5() | ||
{ | ||
var cfg = new LuaConfig() { LazyLoading = true }; | ||
|
||
using(ILua l = new Lua<ILua51>(cfg)) { | ||
var a = ((Lua<ILua51>)l).API; | ||
using(ILua l = new Lua<ILua51>(cfg)) | ||
{ | ||
Assert.Equal(LuaVersion.Lua51, (((Lua<ILua51>)l).API).Version); | ||
} | ||
|
||
using(ILua l = new Lua<ILua52>(cfg)) { | ||
var a = ((Lua<ILua52>)l).API; | ||
using(ILua l = new Lua<ILua52>(cfg)) | ||
{ | ||
Assert.Equal(LuaVersion.Lua52, (((Lua<ILua52>)l).API).Version); | ||
} | ||
} | ||
|
||
[TestMethod] | ||
[Fact] | ||
public void funcNameTest1() | ||
{ | ||
var l = new _Lua(); | ||
var l = new StubLua(); | ||
|
||
try { | ||
l.procName(""); | ||
Assert.Fail("1"); | ||
} | ||
catch(Exception ex) { Assert.IsTrue(ex.GetType() == typeof(ArgumentException), ex.GetType().ToString()); } | ||
Assert.Throws<ArgumentException>(() => l.procName(string.Empty)); | ||
|
||
try { | ||
l.procName(null); | ||
Assert.Fail("2"); | ||
} | ||
catch(Exception ex) { Assert.IsTrue(ex.GetType() == typeof(ArgumentException), ex.GetType().ToString()); } | ||
Assert.Throws<ArgumentException>(() => l.procName(null)); | ||
} | ||
} | ||
} |
Oops, something went wrong.