OSDN Git Service

na-get-lib,タスクセットの改修(NaGetTaskSet2)および、そのUnitTestを追加
authorttp <ttp@users.sourceforge.jp>
Tue, 3 May 2011 14:01:19 +0000 (23:01 +0900)
committerttp <ttp@users.sourceforge.jp>
Tue, 3 May 2011 14:01:19 +0000 (23:01 +0900)
13 files changed:
AppliStation.proj
na-get-lib/NaGet.SubCommands.SubTask/DownloadSubTask.cs
na-get-lib/NaGet.SubCommands.SubTask/FunctionalSubTask.cs [new file with mode: 0644]
na-get-lib/NaGet.SubCommands.SubTask/NaGetSubTask.cs
na-get-lib/NaGet.SubCommands/NaGetTaskSet2.cs [new file with mode: 0644]
na-get-lib/NaGet.Tasks/Task.cs
na-get-lib/na-get-lib.csproj
test-na-get-lib/AssemblyInfo.cs [new file with mode: 0644]
test-na-get-lib/FunctionalSubTaskTest.cs [new file with mode: 0644]
test-na-get-lib/NaGetSubTaskTest.cs [new file with mode: 0644]
test-na-get-lib/NaGetTaskSet2Test.cs [new file with mode: 0644]
test-na-get-lib/TaskTest.cs [new file with mode: 0644]
test-na-get-lib/test-na-get-lib.csproj [new file with mode: 0644]

index d1cc0ee..ff1ec50 100644 (file)
     <AppliStationBin Include="$(AppliStationBinDir)/*.png;$(AppliStationBinDir)/*.exe;$(AppliStationBinDir)/*.pdb" />
   </ItemGroup>
 
+  <Target Name="na-get-lib">
+    <MSBuild Projects="na-get-lib/na-get-lib.csproj" Properties="Configuration=$(Configuration)" />
+  </Target>
+  <Target Name="all-get" DependsOnTargets="na-get-lib">
+    <MSBuild Projects="all-get/all-get.csproj" Properties="Configuration=$(Configuration)" />
+  </Target>
+  <Target Name="archive-inst" DependsOnTargets="na-get-lib">
+    <MSBuild Projects="archive-inst/archive-inst.csproj" Properties="Configuration=$(Configuration)" />
+  </Target>
+  <Target Name="AppliStation" DependsOnTargets="na-get-lib">
+    <MSBuild Projects="AppliStation/AppliStation.csproj" Properties="Configuration=$(Configuration)" />
+  </Target>
+  <Target Name="test-na-get-lib" DependsOnTargets="na-get-lib">
+    <MSBuild Projects="test-na-get-lib/test-na-get-lib.csproj" Properties="Configuration=$(Configuration)" />
+  </Target>
+
   <Target Name="Build">
-    <MSBuild Projects="AppliStation.sln" Properties="Configuration=$(Configuration)" />
+    <CallTarget Targets="na-get-lib;all-get;archive-inst;AppliStation" RunEachTargetSeparately="true" />
+  </Target>
+
+  <Target Name="BuildTest">
+    <CallTarget Targets="test-na-get-lib" RunEachTargetSeparately="true" />
   </Target>
 
   <Target Name="Dist">
index efd7da0..e24ad4f 100644 (file)
@@ -87,6 +87,33 @@ namespace NaGet.SubCommands.SubTask
                        get { return downloadedFileName; }
                }
                
+               /// <summary>
+               /// キャンセル可能
+               /// </summary>
+               public override bool Cancelable {
+                       get { return !this.cancelCalled; }
+               }
+               
+               /// <summary>
+               /// ダウンロード処理をキャンセルする
+               /// </summary>
+               /// <returns>キャンセルに成功したときtrue</returns>
+               public override bool Cancel()
+               {
+                       if (! this.cancelCalled && ! this.Done) {
+                               this.cancelCalled = true;
+                               if (request != null) {
+                                       try {
+                                               request.Abort();
+                                       } catch (WebException) {
+                                       }
+                               }
+                               return true;
+                       } else {
+                               return false;
+                       }
+               }
+               
                public override void Run()
                {
                        NotifyStarted();
@@ -255,26 +282,6 @@ namespace NaGet.SubCommands.SubTask
                }
                
                /// <summary>
-               /// ダウンロード処理をキャンセルする
-               /// </summary>
-               /// <returns>キャンセルに成功したときtrue</returns>
-               public override bool Cancel()
-               {
-                       if (! this.cancelCalled && ! this.Done) {
-                               this.cancelCalled = true;
-                               if (request != null) {
-                                       try {
-                                               request.Abort();
-                                       } catch (WebException) {
-                                       }
-                               }
-                               return true;
-                       } else {
-                               return false;
-                       }
-               }
-               
-               /// <summary>
                /// Webレスポンスからダウンロードしたファイルの名前を取得
                /// </summary>
                /// <remarks>Content-Dispositionヘッダから取得あるいはURLの末尾から推定します</remarks>
diff --git a/na-get-lib/NaGet.SubCommands.SubTask/FunctionalSubTask.cs b/na-get-lib/NaGet.SubCommands.SubTask/FunctionalSubTask.cs
new file mode 100644 (file)
index 0000000..e26f3f1
--- /dev/null
@@ -0,0 +1,44 @@
+using System;
+using System.Diagnostics;
+using NaGet.Tasks;
+
+namespace NaGet.SubCommands.SubTask
+{
+       /// <summary>
+       /// 関数をサブタスク化
+       /// </summary>
+       public class FunctionalSubTask : NaGetSubTask
+       {
+               private Action<object> func = null;
+               
+               private object arg = null;
+               
+               /// <summary>
+               /// コンストラクタ
+               /// </summary>
+               /// <param name="func">関数</param>
+               /// <param name="arg">関数への引数</param>
+               public FunctionalSubTask(Action<object> func, object arg)
+               {
+                       this.func = func;
+                       this.arg = arg;
+               }
+               
+               public override void Run()
+               {
+                       NotifyStarted();
+                       try {
+                               func(arg);
+                       } finally {
+                               NotifyCompleted();
+                       }
+               }
+               
+               /// <summary>
+               /// 進捗は提供しない。
+               /// </summary>
+               public override bool UseProgress {
+                       get { return false; }
+               }
+       }
+}
index 4661725..e1de4d8 100644 (file)
@@ -18,6 +18,15 @@ namespace NaGet.SubCommands.SubTask
                {
                }
                
+               /// <summary>
+               /// 進捗情報を提供するか?
+               /// </summary>
+               public virtual bool UseProgress {
+                       get {
+                               return true;
+                       }
+               }
+               
                public override bool Running {
                        get {
                                return isRunning;
@@ -36,19 +45,35 @@ namespace NaGet.SubCommands.SubTask
                        }
                }
                
-               protected virtual void NotifyStarted() {
+               #region フラグ処理の便利メソッド
+               
+               /// <summary>
+               /// 開始時に関するフラグの処理を行う
+               /// </summary>
+               protected virtual void NotifyStarted()
+               {
                        isRunning = true;
                        isDone = false;
                }
                
-               protected virtual void NotifyCancelled() {
+               /// <summary>
+               /// キャンセル中断時に関するフラグの処理を行う
+               /// </summary>
+               protected virtual void NotifyCancelled()
+               {
                        isRunning = false;
                        isCancelled = true;
                }
                
-               protected virtual void NotifyCompleted() {
+               /// <summary>
+               /// 成功終了時に関するフラグの処理を行う
+               /// </summary>
+               protected virtual void NotifyCompleted()
+               {
                        isRunning = false;
                        isDone = true;
                }
+               
+               #endregion
        }
 }
diff --git a/na-get-lib/NaGet.SubCommands/NaGetTaskSet2.cs b/na-get-lib/NaGet.SubCommands/NaGetTaskSet2.cs
new file mode 100644 (file)
index 0000000..eb43c19
--- /dev/null
@@ -0,0 +1,192 @@
+using System;
+using System.Collections.Generic;
+using NaGet.SubCommands.SubTask;
+using NaGet.Tasks;
+
+namespace NaGet.SubCommands
+{
+       /// <summary>
+       /// NaGetタスク処理のパック
+       /// </summary>
+       public abstract class NaGetTaskSet2 : NaGetTaskSet
+       {
+               /// <summary>
+               /// サブタスクのハンドラ
+               /// </summary>
+               public virtual event EventHandler<TaskEventArgs> SubTaskEventRaised;
+               
+               /// <summary>
+               /// サブタスクのリスト
+               /// </summary>
+               protected IList<NaGetSubTask> subTasks;
+               
+               /// <summary>
+               /// 現在実行中のサブタスクのインデックス
+               /// </summary>
+               private int currentSubTaskIndex = -1;
+               
+               /// <summary>
+               /// 終了したか
+               /// </summary>
+               protected bool isDone = false;
+               
+               /// <summary>
+               /// キャンセルされたか
+               /// </summary>
+               protected bool isCancelled = false;
+               
+               /// <summary>
+               /// キャンセルが呼ばれたか
+               /// </summary>
+               protected bool cancelCalled = false;
+               
+               /// <summary>
+               /// キャンセル呼び出し時のイベント。
+               /// </summary>
+               protected event Action<object> onCancelCalled;
+               
+               public NaGetTaskSet2()
+               {
+               }
+               
+               /// <summary>
+               /// キャンセル処理を行う
+               /// </summary>
+               /// <returns>成功したか否か</returns>
+               public override bool Cancel()
+               {
+                       if (Cancelable) {
+                               if (! cancelCalled && ! isDone) {
+                                       cancelCalled = true;
+                                       if (onCancelCalled != null) {
+                                               onCancelCalled(null);
+                                       }
+                                       
+                                       if (currentSubTask != null && currentSubTask.Cancelable) {
+                                               return currentSubTask.Cancel();
+                                       } else {
+                                               return true;
+                                       }
+                               } else {
+                                       return false;
+                               }
+                       } else {
+                               return false;
+                       }
+               }
+               
+               public override int CurrentTaskSetIndex {
+                       get { return currentSubTaskIndex; }
+               }
+               
+               public override bool Done {
+                       get { return isDone; }
+               }
+               
+               public virtual bool Cancelled {
+                       get { return isCancelled; }
+               }
+               
+               #region フラグ処理の便利メソッド
+               
+               /// <summary>
+               /// 開始時に関するフラグの処理を行う
+               /// </summary>
+               protected virtual void NotifyStarted()
+               {
+                       currentSubTaskIndex = 0;
+                       isDone = false;
+               }
+               
+               /// <summary>
+               /// キャンセル中断時に関するフラグの処理を行う
+               /// </summary>
+               protected virtual void NotifyCancelled()
+               {
+                       isCancelled = true;
+               }
+               
+               /// <summary>
+               /// 成功終了時に関するフラグの処理を行う
+               /// </summary>
+               protected virtual void NotifyCompleted()
+               {
+                       isDone = true;
+               }
+               
+               /// <summary>
+               /// サブタスク実行を次へ。
+               /// </summary>
+               protected virtual void NotifyGoToNextSubTask()
+               {
+                       currentSubTaskIndex ++;
+               }
+               
+               /// <summary>
+               /// サブタスク実行をジャンプする。
+               /// </summary>
+               /// <param name="subTaskIndex">ジャンプ先のサブタスク番号</param>
+               protected virtual void NotifyGoToSubTask(int subTaskIndex)
+               {
+                       currentSubTaskIndex = subTaskIndex;
+               }
+               
+               #endregion
+               
+               #region サブタスク実行時における便利メソッド
+                               
+               protected virtual string currentSubTaskName {
+                       get { return taskSetNames[currentSubTaskIndex]; }
+               }
+               
+               protected virtual NaGetSubTask currentSubTask {
+                       get { return subTasks[currentSubTaskIndex]; }
+               }
+               
+               protected virtual bool hasMoreSubTask {
+                       get { return currentSubTaskIndex < taskSetNames.Count; }
+               }
+               
+               #endregion
+               
+               #region サブタスク初期化・登録便利メソッド
+               
+               protected void initSubTask()
+               {
+                       taskSetNames = new List<string>();
+                       subTasks = new List<NaGetSubTask>();
+               }
+               
+               /// <summary>
+               /// サブタスクを登録する
+               /// </summary>
+               /// <param name="name">名称</param>
+               /// <param name="task">サブタスクオブジェクト</param>
+               protected void registSubTask(string name, NaGetSubTask task)
+               {
+                       taskSetNames.Add(name);
+                       subTasks.Add(task);
+                       
+                       // サブタスクのイベントをSubTaskEventRaised,TaskEventRaisedに転送
+                       task.TaskEventRaised += new EventHandler<TaskEventArgs>(subtaskEventTransformer);
+               }
+               
+               /// <summary>
+               /// サブタスクのイベントをSubTaskEventRaised,TaskEventRaisedに転送する関数
+               /// </summary>
+               /// <param name="sender">送信元のサブタスク</param>
+               /// <param name="e">イベントオブジェクト</param>
+               private void subtaskEventTransformer(object sender, TaskEventArgs e)
+               {
+                       if (SubTaskEventRaised != null) {
+                               SubTaskEventRaised(sender, e);
+                       }
+                       if (e.ProgressPercent >= 0) {
+                               RaiseTaskSetEvent(TaskEventType.PING, null, GetProgressPercent(TaskEventType.PING, e.ProgressPercent));
+                       }
+               }
+               
+               #endregion
+
+       }
+}
index 3b8feb2..dc48c19 100644 (file)
@@ -48,7 +48,7 @@ namespace NaGet.Tasks
                }\r
                \r
                #region TaskEvent便利メソッド\r
-                               \r
+               \r
                protected virtual void RaiseTaskSetEvent(TaskEventType type, string message, float percent)\r
                {\r
                        if (TaskEventRaised != null) {\r
index 949645f..62c3dda 100644 (file)
     <Compile Include="NaGet.Packages\PackageListsManager.cs" />\r
     <Compile Include="NaGet.Packages\RepositoriesList.cs" />\r
     <Compile Include="NaGet.Packages\VersionComparetor.cs" />\r
+    <Compile Include="NaGet.SubCommands.SubTask\FunctionalSubTask.cs" />\r
     <Compile Include="NaGet.SubCommands.SubTask\DownloadSubTask.cs" />\r
     <Compile Include="NaGet.SubCommands.SubTask\NaGetSubTask.cs" />\r
     <Compile Include="NaGet.SubCommands\NaGetDownloadToCache.cs" />\r
     <Compile Include="NaGet.SubCommands\NaGetInstall.cs" />\r
     <Compile Include="NaGet.SubCommands\NaGetTaskSet.cs" />\r
+    <Compile Include="NaGet.SubCommands\NaGetTaskSet2.cs" />\r
     <Compile Include="NaGet.SubCommands\NaGetUninstall.cs" />\r
     <Compile Include="NaGet.Tasks\Task.cs" />\r
     <Compile Include="NaGet.Tasks\TaskCanceledException.cs" />\r
diff --git a/test-na-get-lib/AssemblyInfo.cs b/test-na-get-lib/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..d2a37e9
--- /dev/null
@@ -0,0 +1,31 @@
+#region Using directives
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+#endregion
+
+// 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("test-na-get-lib")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("test-na-get-lib")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// This sets the default COM visibility of types in the assembly to invisible.
+// If you need to expose a type to COM, use [ComVisible(true)] on that type.
+[assembly: ComVisible(false)]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all the values or you can use the default the Revision and 
+// Build Numbers by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.*")]
diff --git a/test-na-get-lib/FunctionalSubTaskTest.cs b/test-na-get-lib/FunctionalSubTaskTest.cs
new file mode 100644 (file)
index 0000000..39bf9ba
--- /dev/null
@@ -0,0 +1,93 @@
+using System;
+using System.Threading;
+using NUnit.Framework;
+
+using NaGet.SubCommands.SubTask;
+
+namespace test_na_get_lib
+{
+       [TestFixture]
+       public class FunctionalSubTaskTest
+       {
+               [Test]
+               public void UseProgress()
+               {
+                       FunctionalSubTask subtask = new FunctionalSubTask(null, null);
+                       Assert.IsFalse(subtask.UseProgress);
+               }
+               
+               [Test]
+               public void Cancelable()
+               {
+                       FunctionalSubTask subtask = new FunctionalSubTask(null, null);
+                       Assert.IsFalse(subtask.Cancelable);
+               }
+               
+               [Test]
+               public void Run()
+               {
+                       object arg = new object();
+                       bool passBlock = false;
+                       FunctionalSubTask subtask = null;
+                       
+                       // 正常動作
+                       
+                       Action<object> func1 = delegate (object argv) {
+                               passBlock = true;
+                               Assert.IsTrue(subtask.Running);
+                               Assert.IsFalse(subtask.Done);
+                               Assert.AreEqual(arg, argv);
+                       };
+                       subtask = new FunctionalSubTask(func1, arg);
+                       passBlock = false;
+                       subtask.Run();
+                       Assert.IsFalse(subtask.Running);
+                       Assert.IsFalse(subtask.Cancelled);
+                       Assert.IsTrue(subtask.Done);
+                       Assert.IsTrue(passBlock);
+                       
+                       // 例外時動作
+                       
+                       Action<object> func2 = delegate (object argv) {
+                               passBlock = true;
+                               Assert.IsNull(argv);
+                               throw new TestException("foobar");
+                       };
+                       passBlock = false;
+                       subtask = new FunctionalSubTask(func2, null);
+                       try {
+                               subtask.Run();
+                               Assert.IsTrue(passBlock);
+                               Assert.Fail("shall not be reached here");
+                       } catch (TestException ex) {
+                               Assert.IsTrue(passBlock);
+                               Assert.AreEqual("foobar", ex.Message);
+                       } finally {
+                               // 例外が起こったとしても終了扱い
+                               Assert.IsTrue(subtask.Done);
+                               Assert.IsFalse(subtask.Cancelled);
+                       }
+                       
+                       // 異常設定
+                       
+                       subtask = new FunctionalSubTask(null, null);
+                       passBlock = false;
+                       try {
+                               subtask.Run();
+                               Assert.Fail("shall not be reached here");
+                       } catch (NullReferenceException) {
+                       } finally {
+                               // 例外が起こったとしても終了扱い
+                               Assert.IsTrue(subtask.Done);
+                               Assert.IsFalse(subtask.Cancelled);
+                       }
+               }
+               
+               private class TestException : Exception
+               {
+                       public TestException(string msg)
+                               : base(msg) {
+                       }
+               }
+       }
+}
diff --git a/test-na-get-lib/NaGetSubTaskTest.cs b/test-na-get-lib/NaGetSubTaskTest.cs
new file mode 100644 (file)
index 0000000..95973bb
--- /dev/null
@@ -0,0 +1,100 @@
+using System;
+using System.Threading;
+using NUnit.Framework;
+
+using NaGet.SubCommands.SubTask;
+
+namespace test_na_get_lib
+{
+       [TestFixture]
+       public class NaGetSubTaskTest
+       {
+               [Test]
+               public void Running()
+               {
+                       ASubTaskForTest subtask = new ASubTaskForTest();
+                       Assert.IsFalse(subtask.Running);
+                       subtask.CallNotifyStarted();
+                       Assert.IsTrue(subtask.Running);
+                       subtask.CallNotifyCompleted();
+                       Assert.IsFalse(subtask.Running);
+                       
+                       subtask = new ASubTaskForTest();
+                       Assert.IsFalse(subtask.Running);
+                       subtask.CallNotifyStarted();
+                       Assert.IsTrue(subtask.Running);
+                       subtask.CallNotifyCancelled();
+                       Assert.IsFalse(subtask.Running);
+               }
+               
+               [Test]
+               public void Cancelled()
+               {
+                       ASubTaskForTest subtask = new ASubTaskForTest();
+                       Assert.IsFalse(subtask.Cancelled);
+                       subtask.CallNotifyStarted();
+                       Assert.IsFalse(subtask.Cancelled);
+                       subtask.CallNotifyCancelled();
+                       Assert.IsTrue(subtask.Cancelled);
+               }
+               
+               [Test]
+               public void Done()
+               {
+                       ASubTaskForTest subtask = new ASubTaskForTest();
+                       subtask.CallNotifyStarted();
+                       Assert.IsFalse(subtask.Done);
+                       subtask.CallNotifyCompleted();
+                       Assert.IsTrue(subtask.Done);
+               }
+               
+               [Test]
+               public void UseProgress()
+               {
+                       ASubTaskForTest subtask = new ASubTaskForTest();
+                       Assert.IsTrue(subtask.UseProgress);
+               }
+               
+               [Test]
+               public void Run()
+               {
+                       ASubTaskForTest subtask = new ASubTaskForTest();
+                       Assert.IsFalse(subtask.Running);
+                       Assert.IsFalse(subtask.Done);
+                       subtask.Run();
+                       Assert.IsFalse(subtask.Running);
+                       Assert.IsTrue(subtask.Done);
+               }
+               
+               #region テスト用派生クラス
+               
+               private class ASubTaskForTest : NaGetSubTask
+               {
+                       public override void Run()
+                       {
+                               NotifyStarted();
+                               Thread.Sleep(1);
+                               NotifyCompleted();
+                       }
+                       
+                       public void CallNotifyStarted()
+                       {
+                               NotifyStarted();
+                       }
+                       
+                       public void CallNotifyCompleted()
+                       {
+                               NotifyCompleted();
+                       }
+                       
+                       public void CallNotifyCancelled()
+                       {
+                               NotifyCancelled();
+                       }
+               }
+               
+               #endregion
+               
+       }
+       
+}
diff --git a/test-na-get-lib/NaGetTaskSet2Test.cs b/test-na-get-lib/NaGetTaskSet2Test.cs
new file mode 100644 (file)
index 0000000..e27ef07
--- /dev/null
@@ -0,0 +1,468 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using NUnit.Framework;
+using NaGet.SubCommands.SubTask;
+using NaGet.Tasks;
+
+using NaGet.SubCommands;
+
+namespace test_na_get_lib
+{
+       [TestFixture]
+       public class NaGetTaskSet2Test
+       {
+               [Test]
+               public void SubTasks()
+               {
+                       IList<string> subTaskMsgs = new string[]{"0", "1", "2"};
+                       IList<NaGetSubTask> subTasks = new NaGetSubTask[] {
+                               new FunctionalSubTask(null, null),
+                               new FunctionalSubTask(null, null),
+                               new FunctionalSubTask(null, null),
+                       };
+                       ATaskSetForTest task = new ATaskSetForTest(subTaskMsgs, subTasks);
+                       
+                       Assert.AreEqual(subTaskMsgs, task.TaskSetNames);
+               }
+               
+               [Test]
+               public void NotifyGoToNextSubTask()
+               {
+                       ATaskSetForTest task = null;
+                       IList<NaGetSubTask> subTasks = null;
+                       
+                       IList<string> subTaskMsgs = new string[]{"0", "1", "2"};
+                       int blockCount = 0;
+                       Action<object>[] funcs = new Action<object>[] {
+                               delegate (object arg) {
+                                       blockCount ++;
+                                       Assert.AreEqual(0, task.CurrentTaskSetIndex);
+                                       Assert.IsTrue(task.Running);
+                                       Assert.IsTrue(subTasks[0].Running);
+                                       Assert.IsFalse(subTasks[1].Running);
+                               },
+                               delegate (object arg) {
+                                       blockCount ++;
+                                       Assert.IsTrue(task.Running);
+                                       Assert.IsTrue(subTasks[0].Done);
+                                       Assert.IsTrue(subTasks[1].Running);
+                                       Assert.IsFalse(subTasks[2].Running);
+                               },
+                               delegate (object arg) {
+                                       blockCount ++;
+                                       Assert.IsTrue(task.Running);
+                                       Assert.IsTrue(subTasks[1].Done);
+                                       Assert.IsTrue(subTasks[2].Running);
+                               }
+                       };
+                       subTasks = new NaGetSubTask[] {
+                               new FunctionalSubTask(funcs[0], null),
+                               new FunctionalSubTask(funcs[1], null),
+                               new FunctionalSubTask(funcs[2], null),
+                       };
+                       task = new ATaskSetForTest(subTaskMsgs, subTasks);
+                       blockCount = 0;
+                       task.Run();
+                       Assert.IsTrue(task.Done);
+                       Assert.IsTrue(subTasks[0].Done);
+                       Assert.IsTrue(subTasks[1].Done);
+                       Assert.IsTrue(subTasks[2].Done);
+                       Assert.AreEqual(3, blockCount);
+               }
+               
+               [Test]
+               public void NotifyGoToSubTask()
+               {
+                       ATaskSetForTest task = null;
+                       IList<NaGetSubTask> subTasks = null;
+                       
+                       IList<string> subTaskMsgs = new string[]{"0", "1"};
+                       List<int> blockPass = new List<int>();
+                       Action<object>[] funcs = new Action<object>[] {
+                               delegate (object arg) {
+                                       blockPass.Add(0);
+                                       Assert.AreEqual(0, task.CurrentTaskSetIndex);
+                                       Assert.IsTrue(task.Running);
+                                       Assert.IsTrue(subTasks[0].Running);
+                                       Assert.IsFalse(subTasks[1].Running);
+                               },
+                               delegate (object arg) {
+                                       blockPass.Add(1);
+                                       Assert.IsTrue(task.Running);
+                                       Assert.IsTrue(subTasks[0].Done);
+                                       Assert.IsTrue(subTasks[1].Running);
+                                       
+                                       if (blockPass.Count < 6) {
+                                               throw new JumpTaskException(0);
+                                       }
+                               }
+                       };
+                       subTasks = new NaGetSubTask[] {
+                               new FunctionalSubTask(funcs[0], null),
+                               new FunctionalSubTask(funcs[1], null),
+                       };
+                       task = new ATaskSetForTest(subTaskMsgs, subTasks);
+                       blockPass.Clear();
+                       task.Run();
+                       Assert.IsTrue(task.Done);
+                       Assert.AreEqual(new int[]{0, 1, 0, 1, 0, 1}, blockPass.ToArray());
+               }
+               
+               [Test]
+               public void TaskEventRaised()
+               {
+                       ATaskSetForTest task = null;
+                       IList<string> subTaskMsgs = new string[]{"0", "1"};
+                       IList<NaGetSubTask> subTasks = null;
+                       List<TaskEventArgs> taskEventList = new List<TaskEventArgs>();
+                       List<TaskEventArgs> subtaskEventList = new List<TaskEventArgs>();
+                       
+                       Action<ASubTaskForEventTest> subTaskBody = delegate(ASubTaskForEventTest subTask) {
+                               subTask.RaiseTaskSetEventExt(TaskEventType.STARTED,     "S", -1);
+                               subTask.RaiseTaskSetEventExt(TaskEventType.INFO,                "I", 0);
+                               subTask.RaiseTaskSetEventExt(TaskEventType.PING,                "P", 50);
+                               subTask.RaiseTaskSetEventExt(TaskEventType.WARNING,     "W", 75);
+                               subTask.RaiseTaskSetEventExt(TaskEventType.COMPLETED,"C", 100);
+                       };
+                       subTasks = new NaGetSubTask[] {
+                               new ASubTaskForEventTest(subTaskBody),
+                               new ASubTaskForEventTest(subTaskBody),
+                       };
+                       task = new ATaskSetForTest(subTaskMsgs, subTasks);
+                       
+                       EventHandler<TaskEventArgs> taskEventHandler = delegate(object sender, TaskEventArgs e) {
+                               Assert.AreEqual(task, sender);
+                               taskEventList.Add(e);
+                       };
+                       EventHandler<TaskEventArgs> subtaskEventHandler = delegate(object sender, TaskEventArgs e) {
+                               Assert.AreEqual(subTasks[task.CurrentTaskSetIndex], sender);
+                               subtaskEventList.Add(e);
+                       };
+                       
+                       // イベントをフックしているときの動作確認
+                       
+                       task.TaskEventRaised += taskEventHandler;
+                       task.SubTaskEventRaised += subtaskEventHandler;
+                       
+                       taskEventList.Clear();
+                       subtaskEventList.Clear();
+                       task.Run();
+                       Assert.IsTrue(task.Done);
+                       
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.STARTED,                   "", 0),                 taskEventList[0]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.STARTED_SUBTASK,   "0", 0),                taskEventList[1]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.PING,                              null, 0),               taskEventList[2]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.PING,                              null, 25),              taskEventList[3]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.PING,                              null, 37.5f),   taskEventList[4]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.PING,                              null, 50),              taskEventList[5]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.COMPLETED_SUBTASK,"0", 50),                taskEventList[6]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.STARTED_SUBTASK,   "1", 50),               taskEventList[7]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.PING,                              null, 50),              taskEventList[8]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.PING,                              null, 75),              taskEventList[9]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.PING,                              null, 87.5f),   taskEventList[10]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.PING,                              null, 100),     taskEventList[11]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.COMPLETED_SUBTASK,"1", 100),               taskEventList[12]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.COMPLETED,         "", 100),               taskEventList[13]);
+                       Assert.AreEqual(14, taskEventList.Count);
+                       
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.STARTED,   "S", -1),       subtaskEventList[0]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.INFO,              "I", 0),        subtaskEventList[1]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.PING,              "P", 50),       subtaskEventList[2]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.WARNING,   "W", 75),       subtaskEventList[3]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.COMPLETED,"C", 100),       subtaskEventList[4]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.STARTED,   "S", -1),       subtaskEventList[5]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.INFO,              "I", 0),        subtaskEventList[6]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.PING,              "P", 50),       subtaskEventList[7]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.WARNING,   "W", 75),       subtaskEventList[8]);
+                       AreSameTaskEventArgs(new TaskEventArgs(TaskEventType.COMPLETED,"C", 100),       subtaskEventList[9]);
+                       Assert.AreEqual(10, subtaskEventList.Count);
+                       
+                       // イベントをフックしていないときの動作確認
+                       
+                       task.TaskEventRaised -= taskEventHandler;
+                       task.SubTaskEventRaised -= subtaskEventHandler;
+                       
+                       taskEventList.Clear();
+                       subtaskEventList.Clear();
+                       task.Run();
+                       Assert.IsTrue(task.Done);
+               }
+               
+               [Test]
+               public void Cancel()
+               {
+                       ATaskSetForTest task = null;
+                       IList<string> subTaskMsgs = new string[]{"0"};
+                       IList<NaGetSubTask> subTasks = null;
+                       
+                       Action<ASubTaskForEventTest> subTaskBody = delegate(ASubTaskForEventTest subTask) {
+                               subTask.RaiseTaskSetEventExt(TaskEventType.STARTED,     "S", 0);
+                               Thread.Sleep(50);
+                               subTask.RaiseTaskSetEventExt(TaskEventType.COMPLETED,"C", 100);
+                       };
+                       bool? cancelRetVal = null;
+                       ParameterizedThreadStart cancelThread = new ParameterizedThreadStart(
+                               delegate (object param) {
+                                       Thread.Sleep((int) param);
+                                       cancelRetVal = task.Cancel();
+                               }
+                       );
+                       
+                       // キャンセル無効なときはキャンセル処理は行われない。
+                       
+                       subTasks = new NaGetSubTask[] { new ASubTaskForEventTest(subTaskBody) };
+                       task = new ATaskSetForTest(subTaskMsgs, subTasks);
+                       task._Cancelable = false;
+                       cancelRetVal = null;
+                       (new Thread(cancelThread)).Start((object) 10);
+                       task.Run();
+                       Assert.AreEqual(false, cancelRetVal);
+                       Assert.IsTrue(task.Done);
+                       Assert.IsFalse(task.Cancelable);
+                       
+                       // すでに終了しているものにはキャンセルはできない
+                       Assert.IsFalse(task.Cancel());
+                       
+                       // キャンセル有効なときでキャンセルするとき
+                       subTasks = new NaGetSubTask[] { new ASubTaskForEventTest(subTaskBody) };
+                       task = new ATaskSetForTest(subTaskMsgs, subTasks);
+                       task._Cancelable = true;
+                       cancelRetVal = null;
+                       (new Thread(cancelThread)).Start((object) 10);
+                       task.Run();
+                       Assert.AreEqual(true, cancelRetVal);
+                       Assert.IsTrue(task.Cancelled);
+                       Assert.IsFalse(task.Cancelable);
+                       
+                       // すでにキャンセルしているものにはキャンセルはできない
+                       Assert.IsFalse(task.Cancel());
+                       
+                       // キャンセルトリガの挙動確認
+                       bool cancelBlockPassed = false;
+                       subTasks = new NaGetSubTask[] { new ASubTaskForEventTest(subTaskBody) };
+                       task = new ATaskSetForTest(subTaskMsgs, subTasks);
+                       task._Cancelable = true;
+                       task.OnCancelCalled += delegate(object arg) {
+                               Assert.IsFalse(task.Cancelled);
+                               Assert.IsTrue(task.Running);
+                               Assert.IsFalse(task.Cancelable);
+                               Assert.IsFalse(task.Cancel());
+                               
+                               ASubTaskForEventTest subTask = ((ASubTaskForEventTest) subTasks[0]);
+                               Assert.IsFalse(subTask.Cancelled);
+                               Assert.IsTrue(subTask.Running);
+                               Assert.IsFalse(subTask.Cancelable);
+                               Assert.IsFalse(subTask.Cancel());
+                               
+                               cancelBlockPassed = true;
+                       };
+                       ((ASubTaskForEventTest) subTasks[0])._Cancelable = true;
+                       cancelRetVal = null;
+                       (new Thread(cancelThread)).Start((object) 10);
+                       task.Run();
+                       Assert.AreEqual(true, cancelRetVal);
+                       Assert.IsTrue(task.Cancelled);
+                       Assert.IsFalse(task.Cancelable);
+                       Assert.IsTrue(((ASubTaskForEventTest) subTasks[0]).Cancelled);
+                       Assert.IsFalse(((ASubTaskForEventTest) subTasks[0]).Cancelable);
+                       Assert.IsTrue(cancelBlockPassed);
+               }
+               
+               [Test]
+               public void RaiseTaskSetQueryEvent()
+               {
+                       IList<string> subTaskMsgs = new string[]{"0"};
+                       ATaskSetForTest task = null;
+                       Action<object> subTaskBody = null;
+                       IList<NaGetSubTask> subTasks = null;
+                       bool blockPassed = false;
+                       
+                       subTaskBody = delegate (object arg) {
+                               NaGetTaskQueryResult ret;
+                               ret = task.RaiseTaskSetQueryEventExt("#1", NaGetTaskQueryResult.CONTINUE);
+                               Assert.AreEqual(NaGetTaskQueryResult.CANCELED_AUTOMATICALLY, ret);
+                               
+                               blockPassed = true;
+                       };
+                       subTasks = new NaGetSubTask[] {
+                               new FunctionalSubTask(subTaskBody, null),
+                       };
+                       task = new ATaskSetForTest(subTaskMsgs, subTasks);
+                       task.Run();
+                       Assert.IsTrue(task.Done);
+                       Assert.IsTrue(blockPassed);
+                       
+                       
+                       subTaskBody = delegate (object arg) {
+                               NaGetTaskQueryResult ret;
+                               ret = task.RaiseTaskSetQueryEventExt("#1", NaGetTaskQueryResult.CONTINUE);
+                               Assert.AreEqual(NaGetTaskQueryResult.CONTINUE, ret);
+                               ret = task.RaiseTaskSetQueryEventExt("#2", (NaGetTaskQueryResult.RETRY | NaGetTaskQueryResult.CANCEL));
+                               Assert.AreEqual(NaGetTaskQueryResult.RETRY, ret);
+                               
+                               blockPassed = true;
+                       };
+                       subTasks = new NaGetSubTask[] {
+                               new FunctionalSubTask(subTaskBody, null),
+                       };
+                       task = new ATaskSetForTest(subTaskMsgs, subTasks);
+                       task.TaskQueryRaised += delegate (object sender, NaGetTaskQueryArgs e) {
+                               if (e.Message == "#1") {
+                                       Assert.AreEqual(NaGetTaskQueryResult.CONTINUE, e.SelectionFlag);
+                                       return NaGetTaskQueryResult.CONTINUE;
+                               } else {
+                                       Assert.AreEqual((NaGetTaskQueryResult.RETRY | NaGetTaskQueryResult.CANCEL), e.SelectionFlag);
+                                       return NaGetTaskQueryResult.RETRY;
+                               }
+                       };
+                       task.Run();
+                       Assert.IsTrue(task.Done);
+                       Assert.IsTrue(blockPassed);
+               }
+               
+               private void AreSameTaskEventArgs(TaskEventArgs expected, TaskEventArgs actual)
+               {
+                       string expectedLabel= string.Format("[type={0}, message=\"{1}\", percent={2}%]", expected.Type, expected.TaskMessage, expected.ProgressPercent);
+                       string actualLabel      = string.Format("[type={0}, message=\"{1}\", percent={2}%]", actual.Type, actual.TaskMessage, actual.ProgressPercent);
+                       string failtureMsg = string.Format("Expected: {0}\tBut was: {1}", expectedLabel, actualLabel);
+                       
+                       Assert.AreEqual(expected.Type, actual.Type, failtureMsg);
+                       Assert.AreEqual(expected.TaskMessage, actual.TaskMessage, failtureMsg);
+                       Assert.AreEqual(expected.ProgressPercent, actual.ProgressPercent, failtureMsg);
+               }
+               
+               #region テスト用派生クラス
+               
+               private class JumpTaskException : Exception
+               {
+                       public int subTaskId = -1;
+                       
+                       /// <summary>
+                       /// コンストラクタ
+                       /// </summary>
+                       /// <param name="id">ジャンプ先のサブタスクID</param>
+                       public JumpTaskException(int id)
+                       {
+                               subTaskId = id;
+                       }
+               }
+               
+               private class ATaskSetForTest : NaGetTaskSet2
+               {
+                       public event Action<object> OnCancelCalled;
+                       
+                       public ATaskSetForTest(IList<string> subTaskMsgs, IList<NaGetSubTask> subTasks)
+                       {
+                               initSubTask();
+                               Assert.IsTrue(subTaskMsgs.Count == subTasks.Count);
+                               
+                               for (int i = 0; i < subTaskMsgs.Count; i++) {
+                                       registSubTask(subTaskMsgs[i], subTasks[i]);
+                               }
+                               
+                               this.onCancelCalled += new Action<object>(delegate (object arg) {
+                                                                               if (OnCancelCalled != null) {
+                                                                                                                               OnCancelCalled(arg);
+                                                                                                                       }
+                                                                         });
+                       }
+                       
+                       public override void Run()
+                       {
+                               NotifyStarted();
+                               RaiseTaskSetEvent(TaskEventType.STARTED, string.Empty);
+                               try {
+                                       while (hasMoreSubTask) {
+                                               try {
+                                                       RaiseTaskSetEvent(TaskEventType.STARTED_SUBTASK, currentSubTaskName);
+                                                       currentSubTask.Run();
+                                                       RaiseTaskSetEvent(TaskEventType.COMPLETED_SUBTASK, currentSubTaskName);
+                                                       
+                                                       NotifyGoToNextSubTask();
+                                               } catch (JumpTaskException ex) {
+                                                       NotifyGoToSubTask(ex.subTaskId);
+                                               }
+                                       }
+                               } finally {
+                                       if (cancelCalled) {
+                                               NotifyCancelled();
+                                               RaiseTaskSetEvent(TaskEventType.CANCELED, string.Empty);
+                                       } else {
+                                               NotifyCompleted();
+                                               RaiseTaskSetEvent(TaskEventType.COMPLETED, string.Empty);
+                                       }
+                               }
+                       }
+                       
+                       private bool cancelable = false;
+                       
+                       public override bool Cancelable {
+                               get { return cancelable && !cancelCalled && !isCancelled; }
+                       }
+                       
+                       public virtual bool _Cancelable {
+                               set { cancelable = value; }
+                       }
+                       
+                       public NaGetTaskQueryResult RaiseTaskSetQueryEventExt(string message, NaGetTaskQueryResult selection)
+                       {
+                               return RaiseTaskSetQueryEvent(message, selection);
+                       }
+               }
+               
+               private class ASubTaskForEventTest : NaGetSubTask
+               {
+                       private Action<ASubTaskForEventTest> func = null;
+                       
+                       public ASubTaskForEventTest(Action<ASubTaskForEventTest> func)
+                       {
+                               this.func = func;
+                       }
+                       
+                       public void RaiseTaskSetEventExt(TaskEventType type, string message, float percent)
+                       {
+                               RaiseTaskSetEvent(type, message, percent);
+                       }
+                       
+                       public override void Run()
+                       {
+                               NotifyStarted();
+                               try {
+                                       this.func(this);
+                               } finally {
+                                       if (cancelCalled) {
+                                               NotifyCancelled();
+                                       } else {
+                                               NotifyCompleted();
+                                       }
+                               }
+                       }
+                       
+                       private bool cancelable = false;
+                       
+                       public override bool Cancelable {
+                               get { return cancelable && !cancelCalled && !Cancelled; }
+                       }
+                       
+                       public virtual bool _Cancelable {
+                               set { cancelable = value; }
+                       }
+                       
+                       private bool cancelCalled = true;
+                       
+                       public override bool Cancel()
+                       {
+                               if (Cancelable) {
+                                       cancelCalled = true;
+                                       return true;
+                               } else {
+                                       return base.Cancel();
+                               }
+                       }
+               }
+               
+               #endregion
+               
+       }
+}
diff --git a/test-na-get-lib/TaskTest.cs b/test-na-get-lib/TaskTest.cs
new file mode 100644 (file)
index 0000000..f76d477
--- /dev/null
@@ -0,0 +1,117 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using NUnit.Framework;
+
+using NaGet.Tasks;
+
+namespace test_na_get_lib
+{
+       [TestFixture]
+       public class TaskTest
+       {
+               [Test]
+               public void Running()
+               {
+                       ATaskForTest task = new ATaskForTest();
+                       task.isRunning = true;
+                       Assert.AreEqual(true, task.Running);
+                       task.isRunning = false;
+                       Assert.AreEqual(false, task.Running);
+               }
+               
+               [Test]
+               public void Done()
+               {
+                       ATaskForTest task = new ATaskForTest();
+                       task.isDone = true;
+                       Assert.AreEqual(true, task.Done);
+                       task.isDone = false;
+                       Assert.AreEqual(false, task.Done);
+               }
+               
+               [Test]
+               public void Cancelable()
+               {
+                       ATaskForTest task = new ATaskForTest();
+                       Assert.AreEqual(false, task.Cancelable);
+               }
+               
+               [Test]
+               public void Cancel()
+               {
+                       ATaskForTest task = new ATaskForTest();
+                       Assert.AreEqual(false, task.Cancel());
+               }
+               
+               [Test]
+               public void Run()
+               {
+                       List<TaskEventArgs> eventlist = new List<TaskEventArgs>();
+                       ATaskForTest task = new ATaskForTest();
+                       task.TaskEventRaised += delegate (object sender, TaskEventArgs e) {
+                               Assert.AreEqual(task, sender);
+                               eventlist.Add(e);
+                       };
+
+                       bool threadChecked = false;
+                       (new Thread(
+                               delegate() {
+                                       Thread.Sleep(10);
+                                       Assert.AreEqual(true, task.isRunning);
+                                       threadChecked = true;
+                               })
+                       ).Start();
+                       task.Run();
+                       Assert.AreEqual(true, threadChecked); // スレッド内のパス確認
+                       Assert.AreEqual(false, task.isRunning);
+                       Assert.AreEqual(true, task.isDone);
+                       
+                       Assert.AreEqual(TaskEventType.STARTED,          eventlist[0].Type);
+                       Assert.AreEqual(TaskEventType.PING,             eventlist[1].Type);
+                       Assert.AreEqual(TaskEventType.COMPLETED,        eventlist[2].Type);
+                       Assert.AreEqual("STARTED",              eventlist[0].TaskMessage);
+                       Assert.AreEqual("PING",         eventlist[1].TaskMessage);
+                       Assert.AreEqual("COMPLETED",    eventlist[2].TaskMessage);
+               }
+               
+               #region テスト用派生クラス
+               
+               private class ATaskForTest : Task
+               {
+                       internal bool isRunning = false;
+                       
+                       internal bool isDone = false;
+                       
+                       public override bool Running {
+                               get {
+                                       return isRunning;
+                               }
+                       }
+                       
+                       public override bool Done {
+                               get {
+                                       return isDone;
+                               }
+                       }
+                       
+                       public override void Run()
+                       {
+                               isRunning = true;
+                               RaiseTaskSetEvent(TaskEventType.STARTED, TaskEventType.STARTED.ToString(), 0);
+                               
+                               Thread.Sleep(10);
+                               RaiseTaskSetEvent(TaskEventType.PING, TaskEventType.PING.ToString(), 50);
+                               Thread.Sleep(10);
+                               
+                               RaiseTaskSetEvent(TaskEventType.COMPLETED, TaskEventType.COMPLETED.ToString(), 100);
+                               isRunning = false;
+                               isDone = true;
+                       }
+                       
+               }
+               
+               #endregion
+               
+       }
+}
diff --git a/test-na-get-lib/test-na-get-lib.csproj b/test-na-get-lib/test-na-get-lib.csproj
new file mode 100644 (file)
index 0000000..aedd2ca
--- /dev/null
@@ -0,0 +1,58 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <ProjectGuid>{C87091F6-1265-43E4-A9F9-AF593626FDB8}</ProjectGuid>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <OutputType>Library</OutputType>
+    <RootNamespace>test_na_get_lib</RootNamespace>
+    <AssemblyName>test-na-get-lib</AssemblyName>
+    <BaseIntermediateOutputPath>bin\</BaseIntermediateOutputPath>
+    <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
+    <NoStdLib>False</NoStdLib>
+    <WarningLevel>4</WarningLevel>
+    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+    <OutputPath>bin\Debug\</OutputPath>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>Full</DebugType>
+    <Optimize>False</Optimize>
+    <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+    <OutputPath>bin\Release\</OutputPath>
+    <DebugSymbols>False</DebugSymbols>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+    <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
+    <DefineConstants>TRACE</DefineConstants>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
+    <RegisterForComInterop>False</RegisterForComInterop>
+    <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
+    <BaseAddress>4194304</BaseAddress>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <FileAlignment>4096</FileAlignment>
+  </PropertyGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
+  <ItemGroup>
+    <Reference Include="nunit.core" />
+    <Reference Include="nunit.framework" />
+    <Reference Include="System" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="AssemblyInfo.cs" />
+    <Compile Include="FunctionalSubTaskTest.cs" />
+    <Compile Include="NaGetSubTaskTest.cs" />
+    <Compile Include="NaGetTaskSet2Test.cs" />
+    <Compile Include="TaskTest.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\na-get-lib\na-get-lib.csproj">
+      <Project>{058E953D-3986-4F74-8516-5A50D267D36A}</Project>
+      <Name>na-get-lib</Name>
+    </ProjectReference>
+  </ItemGroup>
+</Project>
\ No newline at end of file