-
Notifications
You must be signed in to change notification settings - Fork 5
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
4 changed files
with
263 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/obj | ||
/bin |
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,136 @@ | ||
using System; | ||
using System.Collections; | ||
using Inferno; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace InfernoTest | ||
{ | ||
[TestClass] | ||
public class CoroutineSystemTest | ||
{ | ||
private TestCoroutineSystem testCoroutineSystem; | ||
|
||
[TestInitialize()] | ||
public void Initialize() | ||
{ | ||
testCoroutineSystem = new TestCoroutineSystem(); | ||
} | ||
|
||
[TestMethod] | ||
public void AddCroutine時にそれぞれ別のidが連番で割り振られる() | ||
{ | ||
|
||
for (uint expected = 0; expected < 10; expected++) | ||
{ | ||
var resultId = testCoroutineSystem.AddCrotoutine(testEnumerator(1)); | ||
Assert.AreEqual(expected,resultId); | ||
} | ||
|
||
//10個登録されている | ||
Assert.AreEqual(10,testCoroutineSystem.RegisteredCoroutineCount); | ||
} | ||
|
||
[TestMethod] | ||
public void RemoveCoroutineで該当のCoroutineが削除される() | ||
{ | ||
//10個登録 | ||
for (uint expected = 0; expected < 10; expected++) | ||
{ | ||
testCoroutineSystem.AddCrotoutine(testEnumerator(1)); | ||
} | ||
|
||
//IDは10個全て存在する | ||
Assert.AreEqual(10, testCoroutineSystem.RegisteredCoroutineCount); | ||
for (uint id = 0; id < 10; id++) | ||
{ | ||
Assert.IsTrue(testCoroutineSystem.IsContains(id)); | ||
} | ||
|
||
//偶数のIDを除去 | ||
for (uint id = 0; id < 10; id++) | ||
{ | ||
if (id%2 == 0) | ||
{ | ||
testCoroutineSystem.RemoveCoroutine(id); | ||
} | ||
} | ||
|
||
//登録コルーチン数は5個になっている | ||
Assert.AreEqual(5, testCoroutineSystem.RegisteredCoroutineCount); | ||
for (uint id = 0; id < 10; id++) | ||
{ | ||
if (id%2 == 0) | ||
{ | ||
//偶数のキーは存在しない | ||
Assert.IsFalse(testCoroutineSystem.IsContains(id)); | ||
} | ||
else | ||
{ | ||
Assert.IsTrue(testCoroutineSystem.IsContains(id)); | ||
} | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void RemoveCoroutineで存在しないキーを削除しても例外にならない() | ||
{ | ||
testCoroutineSystem.RemoveCoroutine(0); | ||
} | ||
|
||
[TestMethod] | ||
public void CoroutineLoopで終了したコルーチンから削除される() | ||
{ | ||
//3個登録 | ||
for (var id = 0; id < 3; id++) | ||
{ | ||
//それぞれ実行回数の違うコルーチンを登録 | ||
testCoroutineSystem.AddCrotoutine(testEnumerator(id)); | ||
} | ||
//登録コルーチン数は3個になっている | ||
Assert.AreEqual(3, testCoroutineSystem.RegisteredCoroutineCount); | ||
|
||
//実行 | ||
testCoroutineSystem.CoroutineLoop(); | ||
|
||
//登録コルーチン数は2個になっている | ||
Assert.AreEqual(2, testCoroutineSystem.RegisteredCoroutineCount); | ||
|
||
//実行 | ||
testCoroutineSystem.CoroutineLoop(); | ||
|
||
//登録コルーチン数は1個になっている | ||
Assert.AreEqual(1, testCoroutineSystem.RegisteredCoroutineCount); | ||
|
||
//実行 | ||
testCoroutineSystem.CoroutineLoop(); | ||
|
||
//登録コルーチン数は0個になっている | ||
Assert.AreEqual(0, testCoroutineSystem.RegisteredCoroutineCount); | ||
} | ||
|
||
|
||
private IEnumerator testEnumerator(int actionCount) | ||
{ | ||
for (int i = 0; i < actionCount; i++) | ||
{ | ||
yield return null; | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// テスト用コルーチンシステム | ||
/// </summary> | ||
public class TestCoroutineSystem : CoroutineSystem | ||
{ | ||
public int RegisteredCoroutineCount | ||
{ | ||
get { return _coroutines.Count; } | ||
} | ||
|
||
public bool IsContains(uint Id) | ||
{ | ||
return _coroutines.ContainsKey(Id); | ||
} | ||
} | ||
} |
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,89 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{CB63D2CF-1E9F-400D-B177-5C9DFD62ADB3}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>InfernoTest</RootNamespace> | ||
<AssemblyName>InfernoTest</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</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> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
</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="CoroutineSystemTest.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Inferno\Inferno.csproj"> | ||
<Project>{66b723b1-4776-448b-947a-1f0792e77f7f}</Project> | ||
<Name>Inferno</Name> | ||
</ProjectReference> | ||
</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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。 | ||
// アセンブリに関連付けられている情報を変更するには、 | ||
// これらの属性値を変更してください。 | ||
[assembly: AssemblyTitle("InfernoTest")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("InfernoTest")] | ||
[assembly: AssemblyCopyright("Copyright © 2015")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから | ||
// 参照できなくなります。このアセンブリ内で COM から型にアクセスする必要がある場合は、 | ||
// その型の ComVisible 属性を true に設定してください。 | ||
[assembly: ComVisible(false)] | ||
|
||
// このプロジェクトが COM に公開される場合、次の GUID がタイプ ライブラリの ID になります。 | ||
[assembly: Guid("83f88d7c-f370-4420-bea4-dfcb4eff8b96")] | ||
|
||
// アセンブリのバージョン情報は、以下の 4 つの値で構成されています: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// すべての値を指定するか、以下のように '*' を使用してビルド番号とリビジョン番号を | ||
// 既定値にすることができます: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |