OSDN Git Service

na-get-lib,all-getについてアップデート処理を新方式(NaGetUpdate2)に変更。
[applistation/AppliStation.git] / test-na-get-lib / NaGetSubTaskTest.cs
1 using System;
2 using System.Threading;
3 using NUnit.Framework;
4
5 using NaGet.SubCommands.SubTask;
6
7 namespace test_na_get_lib
8 {
9         [TestFixture]
10         public class NaGetSubTaskTest
11         {
12                 [Test]
13                 public void Running()
14                 {
15                         ASubTaskForTest subtask = new ASubTaskForTest();
16                         Assert.IsFalse(subtask.Running);
17                         subtask.CallNotifyStarted();
18                         Assert.IsTrue(subtask.Running);
19                         subtask.CallNotifyCompleted();
20                         Assert.IsFalse(subtask.Running);
21                         
22                         subtask = new ASubTaskForTest();
23                         Assert.IsFalse(subtask.Running);
24                         subtask.CallNotifyStarted();
25                         Assert.IsTrue(subtask.Running);
26                         subtask.CallNotifyCancelled();
27                         Assert.IsFalse(subtask.Running);
28                 }
29                 
30                 [Test]
31                 public void Cancelled()
32                 {
33                         ASubTaskForTest subtask = new ASubTaskForTest();
34                         Assert.IsFalse(subtask.Cancelled);
35                         subtask.CallNotifyStarted();
36                         Assert.IsFalse(subtask.Cancelled);
37                         subtask.CallNotifyCancelled();
38                         Assert.IsTrue(subtask.Cancelled);
39                 }
40                 
41                 [Test]
42                 public void Done()
43                 {
44                         ASubTaskForTest subtask = new ASubTaskForTest();
45                         subtask.CallNotifyStarted();
46                         Assert.IsFalse(subtask.Done);
47                         subtask.CallNotifyCompleted();
48                         Assert.IsTrue(subtask.Done);
49                 }
50                 
51                 [Test]
52                 public void UseProgress()
53                 {
54                         ASubTaskForTest subtask = new ASubTaskForTest();
55                         Assert.IsTrue(subtask.UseProgress);
56                 }
57                 
58                 [Test]
59                 public void Run()
60                 {
61                         ASubTaskForTest subtask = new ASubTaskForTest();
62                         Assert.IsFalse(subtask.Running);
63                         Assert.IsFalse(subtask.Done);
64                         subtask.Run();
65                         Assert.IsFalse(subtask.Running);
66                         Assert.IsTrue(subtask.Done);
67                 }
68                 
69                 #region テスト用派生クラス
70                 
71                 private class ASubTaskForTest : NaGetSubTask
72                 {
73                         public override void Run()
74                         {
75                                 NotifyStarted();
76                                 Thread.Sleep(1);
77                                 NotifyCompleted();
78                         }
79                         
80                         public void CallNotifyStarted()
81                         {
82                                 NotifyStarted();
83                         }
84                         
85                         public void CallNotifyCompleted()
86                         {
87                                 NotifyCompleted();
88                         }
89                         
90                         public void CallNotifyCancelled()
91                         {
92                                 NotifyCancelled();
93                         }
94                 }
95                 
96                 #endregion
97                 
98         }
99         
100 }