-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://quest.svn.codeplex.com/svn/trunk@5322 4a90e977-6436-4932-9605-20e10c2b6fb3
- Loading branch information
1 parent
44f5798
commit 691c335
Showing
7 changed files
with
318 additions
and
10 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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion> | ||
</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{9D7478AE-52D8-41B6-8E5C-D3F483919993}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>LegacyASLTests</RootNamespace> | ||
<AssemblyName>LegacyASLTests</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
</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> | ||
<ItemGroup> | ||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" /> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core"> | ||
<RequiredTargetFramework>3.5</RequiredTargetFramework> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> | ||
<Visible>False</Visible> | ||
</CodeAnalysisDependentAssemblyPaths> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="LegacyGameTests.cs" /> | ||
<Compile Include="TestPlayer.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\IASL\IASL.csproj"> | ||
<Project>{BE34CB28-317F-4732-AA32-9D715B4F2C7E}</Project> | ||
<Name>IASL</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\Legacy\LegacyASL.vbproj"> | ||
<Project>{42EEDC11-C395-4CE8-80E3-057AF4100DDE}</Project> | ||
<Name>LegacyASL</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="test1.asl" /> | ||
</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. | ||
<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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System; | ||
using System.Text; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using AxeSoftware.Quest; | ||
using AxeSoftware.Quest.LegacyASL; | ||
|
||
namespace LegacyASLTests | ||
{ | ||
[TestClass] | ||
public class LegacyGameTests | ||
{ | ||
private IASL m_game; | ||
private TestPlayer m_player = new TestPlayer(); | ||
|
||
[TestInitialize] | ||
public void Init() | ||
{ | ||
m_game = new LegacyGame(@"..\..\..\LegacyASLTests\test1.asl"); | ||
m_game.PrintText += m_player.PrintText; | ||
m_game.RequestRaised += m_player.RequestRaised; | ||
m_game.Initialise(m_player); | ||
m_game.Begin(); | ||
} | ||
|
||
[TestMethod] | ||
public void TestLookAt() | ||
{ | ||
m_player.ClearBuffer(); | ||
m_game.SendCommand("look at object"); | ||
Assert.AreEqual("> look at object", m_player.Buffer(0)); | ||
Assert.AreEqual("object look desc", m_player.Buffer(1)); | ||
} | ||
|
||
[TestMethod] | ||
public void TestWait() | ||
{ | ||
m_player.ClearBuffer(); | ||
m_game.SendCommand("wait"); | ||
Assert.AreEqual("Start wait", m_player.Buffer(1)); | ||
Assert.AreEqual(true, m_player.IsWaiting); | ||
Assert.AreEqual(2, m_player.BufferLength, "Expected nothing else in the output buffer after the wait command"); | ||
m_player.IsWaiting = false; | ||
m_game.FinishWait(); | ||
Assert.AreEqual("Done wait", m_player.Buffer(2)); | ||
} | ||
|
||
[TestMethod] | ||
public void TestEnter() | ||
{ | ||
m_player.ClearBuffer(); | ||
m_game.SendCommand("enter"); | ||
Assert.AreEqual("Enter text", m_player.Buffer(1)); | ||
Assert.AreEqual(2, m_player.BufferLength, "Expected nothing else in the output buffer after the enter command"); | ||
m_game.SendCommand("response"); | ||
Assert.AreEqual("You entered: response", m_player.Buffer(2)); | ||
} | ||
|
||
[TestMethod] | ||
public void TestMenu() | ||
{ | ||
m_player.ClearBuffer(); | ||
m_player.LatestMenu = null; | ||
m_game.SendCommand("x twin"); | ||
Assert.AreEqual("- <i>Please select which twin you mean:</i>", m_player.Buffer(1)); | ||
Assert.AreEqual(2, m_player.BufferLength, "Expected nothing else in the output buffer after menu displayed"); | ||
Assert.AreNotEqual(null, m_player.LatestMenu); | ||
Assert.AreEqual(2, m_player.LatestMenu.Options.Count); | ||
Assert.AreEqual("Twin 1", m_player.LatestMenu.Options.ElementAt(0).Value); | ||
Assert.AreEqual("Twin 2", m_player.LatestMenu.Options.ElementAt(1).Value); | ||
m_game.SetMenuResponse(m_player.LatestMenu.Options.ElementAt(0).Key); | ||
Assert.AreEqual("It's twin 1", m_player.Buffer(3)); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("LegacyASLTests")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("LegacyASLTests")] | ||
[assembly: AssemblyCopyright("Copyright © 2011")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("84f50461-ce87-4992-8a6d-e037badea771")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using AxeSoftware.Quest; | ||
|
||
namespace LegacyASLTests | ||
{ | ||
class TestPlayer : IPlayer | ||
{ | ||
private List<string> m_output = new List<string>(); | ||
|
||
public void ClearBuffer() | ||
{ | ||
m_output.Clear(); | ||
} | ||
|
||
public string Buffer(int index) | ||
{ | ||
return m_output[index]; | ||
} | ||
|
||
public int BufferLength | ||
{ | ||
get { return m_output.Count; } | ||
} | ||
|
||
public void PrintText(string text) | ||
{ | ||
if (!text.StartsWith("<output>") || !text.EndsWith("</output>")) | ||
{ | ||
throw new ArgumentException("Invalid output format"); | ||
} | ||
// remove <output> and </output> | ||
text = text.Substring(8, text.Length - 17); | ||
m_output.Add(text); | ||
} | ||
|
||
public void RequestRaised(Request request, string data) | ||
{ | ||
} | ||
|
||
public void ShowMenu(MenuData menuData) | ||
{ | ||
LatestMenu = menuData; | ||
} | ||
|
||
public MenuData LatestMenu { get; set; } | ||
|
||
public void DoWait() | ||
{ | ||
IsWaiting = true; | ||
} | ||
|
||
public bool IsWaiting { get; set; } | ||
|
||
public bool ShowMsgBox(string caption) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void SetWindowMenu(MenuData menuData) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public string GetNewGameFile(string originalFilename, string extensions) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void PlaySound(string filename, bool synchronous, bool looped) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void StopSound() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
!include <stdverbs.lib> | ||
|
||
define game <Unit Test 1> | ||
asl-version <410> | ||
start <room> | ||
end define | ||
|
||
define options | ||
debug on | ||
panes on | ||
abbreviations on | ||
end define | ||
|
||
define room <room> | ||
|
||
command <wait> { | ||
wait <Start wait> | ||
msg <Done wait> | ||
} | ||
|
||
command <enter> { | ||
msg <Enter text> | ||
enter <test> | ||
msg <You entered: #test#> | ||
} | ||
|
||
define object <object> | ||
look <object look desc> | ||
end define | ||
|
||
define object <twin1> | ||
alias <twin> | ||
detail <Twin 1> | ||
look <It's twin 1> | ||
end define | ||
|
||
define object <twin2> | ||
alias <twin> | ||
detail <Twin 2> | ||
look <It's twin 2> | ||
end define | ||
|
||
end define | ||
|
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