~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/Misc/PackageManagement/Test/Src/PackageActionsToRunTests.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using ICSharpCode.PackageManagement;
 
6
using ICSharpCode.PackageManagement.Design;
 
7
using ICSharpCode.PackageManagement.Scripting;
 
8
using NUnit.Framework;
 
9
using PackageManagement.Tests.Helpers;
 
10
 
 
11
namespace PackageManagement.Tests
 
12
{
 
13
        [TestFixture]
 
14
        public class PackageActionsToRunTests
 
15
        {
 
16
                PackageActionsToRun actions;
 
17
                
 
18
                void CreateActions()
 
19
                {
 
20
                        actions = new PackageActionsToRun();
 
21
                }
 
22
                
 
23
                InstallPackageAction AddAction()
 
24
                {
 
25
                        var project = new FakePackageManagementProject();
 
26
                        var events = new FakePackageManagementEvents();
 
27
                        var action = new InstallPackageAction(project, events);
 
28
                        actions.AddAction(action);
 
29
                        return action;
 
30
                }
 
31
                
 
32
                [Test]
 
33
                public void GetNextAction_NewInstance_ReturnsFalse()
 
34
                {
 
35
                        CreateActions();
 
36
                        ProcessPackageAction action = null;
 
37
                        bool result = actions.GetNextAction(out action);
 
38
                        
 
39
                        Assert.IsFalse(result);
 
40
                }
 
41
                
 
42
                [Test]
 
43
                public void GetNextAction_OneActionAdded_ReturnsActionInOutParameter()
 
44
                {
 
45
                        CreateActions();
 
46
                        ProcessPackageAction expectedAction = AddAction();
 
47
                        
 
48
                        ProcessPackageAction action = null;
 
49
                        actions.GetNextAction(out action);
 
50
                        
 
51
                        Assert.AreEqual(expectedAction, action);
 
52
                }
 
53
                
 
54
                [Test]
 
55
                public void GetNextAction_OneActionAdded_ReturnsTrue()
 
56
                {
 
57
                        CreateActions();
 
58
                        ProcessPackageAction expectedAction = AddAction();
 
59
                        
 
60
                        ProcessPackageAction action = null;
 
61
                        bool result = actions.GetNextAction(out action);
 
62
                        
 
63
                        Assert.IsTrue(result);
 
64
                }
 
65
                
 
66
                [Test]
 
67
                public void GetNextAction_CalledTwiceWithOneActionAdded_ReturnsNullActionInOutParameterOnSecondCall()
 
68
                {
 
69
                        CreateActions();
 
70
                        ProcessPackageAction expectedAction = AddAction();
 
71
                        ProcessPackageAction action = null;
 
72
                        actions.GetNextAction(out action);
 
73
                        actions.GetNextAction(out action);
 
74
                        
 
75
                        Assert.IsNull(action);
 
76
                }
 
77
                
 
78
                [Test]
 
79
                public void GetNextAction_CalledTwiceWithOneActionAdded_ReturnsFalseOnSecondCall()
 
80
                {
 
81
                        CreateActions();
 
82
                        ProcessPackageAction expectedAction = AddAction();
 
83
                        
 
84
                        ProcessPackageAction action = null;
 
85
                        actions.GetNextAction(out action);
 
86
                        bool result = actions.GetNextAction(out action);
 
87
                        
 
88
                        Assert.IsFalse(result);
 
89
                }
 
90
                
 
91
                [Test]
 
92
                public void GetNextAction_CalledTwiceWithTwoActionsAdded_ReturnsSecondActionAddedInOutParameter()
 
93
                {
 
94
                        CreateActions();
 
95
                        AddAction();
 
96
                        ProcessPackageAction expectedAction = AddAction();
 
97
                        ProcessPackageAction action = null;
 
98
                        actions.GetNextAction(out action);
 
99
                        actions.GetNextAction(out action);
 
100
                        
 
101
                        Assert.AreEqual(expectedAction, action);
 
102
                }
 
103
                
 
104
                [Test]
 
105
                public void GetNextAction_CalledTwiceWithTwoActionsAdded_ReturnsTrueOnSecondCall()
 
106
                {
 
107
                        CreateActions();
 
108
                        AddAction();
 
109
                        ProcessPackageAction expectedAction = AddAction();
 
110
                        ProcessPackageAction action = null;
 
111
                        actions.GetNextAction(out action);
 
112
                        bool result = actions.GetNextAction(out action);
 
113
                        
 
114
                        Assert.IsTrue(result);
 
115
                }
 
116
        }
 
117
}