OSDN Git Service

AppliStation-All, アセンブリバージョンを1.4.5に
[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                         Assert.IsTrue(subtask.Done);
40                 }
41                 
42                 [Test]
43                 public void Done()
44                 {
45                         ASubTaskForTest subtask = new ASubTaskForTest();
46                         subtask.CallNotifyStarted();
47                         Assert.IsFalse(subtask.Done);
48                         subtask.CallNotifyCompleted();
49                         Assert.IsTrue(subtask.Done);
50                 }
51                 
52                 [Test]
53                 public void UseProgress()
54                 {
55                         ASubTaskForTest subtask = new ASubTaskForTest();
56                         Assert.IsTrue(subtask.UseProgress);
57                 }
58                 
59                 [Test]
60                 public void Run()
61                 {
62                         ASubTaskForTest subtask = new ASubTaskForTest();
63                         Assert.IsFalse(subtask.Running);
64                         Assert.IsFalse(subtask.Done);
65                         subtask.Run();
66                         Assert.IsFalse(subtask.Running);
67                         Assert.IsTrue(subtask.Done);
68                 }
69                 
70                 #region テスト用派生クラス
71                 
72                 private class ASubTaskForTest : NaGetSubTask
73                 {
74                         public override void Run()
75                         {
76                                 NotifyStarted();
77                                 Thread.Sleep(1);
78                                 NotifyCompleted();
79                         }
80                         
81                         public void CallNotifyStarted()
82                         {
83                                 NotifyStarted();
84                         }
85                         
86                         public void CallNotifyCompleted()
87                         {
88                                 NotifyCompleted();
89                         }
90                         
91                         public void CallNotifyCancelled()
92                         {
93                                 NotifyCancelled();
94                         }
95                 }
96                 
97                 #endregion
98                 
99         }
100         
101 }