~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/ngit/NGit.Test/NGit.Submodule/SubmoduleAddTest.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
        [NUnit.Framework.TestFixture]
62
62
        public class SubmoduleAddTest : RepositoryTestCase
63
63
        {
 
64
                /// <exception cref="NGit.Api.Errors.GitAPIException"></exception>
64
65
                [NUnit.Framework.Test]
65
66
                public virtual void CommandWithNullPath()
66
67
                {
67
68
                        try
68
69
                        {
69
 
                                new SubmoduleAddCommand(db).SetURI("uri").Call();
 
70
                                new SubmoduleAddCommand(db).SetURI("uri").Call().Close();
70
71
                                NUnit.Framework.Assert.Fail("Exception not thrown");
71
72
                        }
72
73
                        catch (ArgumentException e)
75
76
                        }
76
77
                }
77
78
 
 
79
                /// <exception cref="NGit.Api.Errors.GitAPIException"></exception>
78
80
                [NUnit.Framework.Test]
79
81
                public virtual void CommandWithEmptyPath()
80
82
                {
81
83
                        try
82
84
                        {
83
 
                                new SubmoduleAddCommand(db).SetPath(string.Empty).SetURI("uri").Call();
 
85
                                new SubmoduleAddCommand(db).SetPath(string.Empty).SetURI("uri").Call().Close();
84
86
                                NUnit.Framework.Assert.Fail("Exception not thrown");
85
87
                        }
86
88
                        catch (ArgumentException e)
89
91
                        }
90
92
                }
91
93
 
 
94
                /// <exception cref="NGit.Api.Errors.GitAPIException"></exception>
92
95
                [NUnit.Framework.Test]
93
96
                public virtual void CommandWithNullUri()
94
97
                {
95
98
                        try
96
99
                        {
97
 
                                new SubmoduleAddCommand(db).SetPath("sub").Call();
 
100
                                new SubmoduleAddCommand(db).SetPath("sub").Call().Close();
98
101
                                NUnit.Framework.Assert.Fail("Exception not thrown");
99
102
                        }
100
103
                        catch (ArgumentException e)
103
106
                        }
104
107
                }
105
108
 
 
109
                /// <exception cref="NGit.Api.Errors.GitAPIException"></exception>
106
110
                [NUnit.Framework.Test]
107
111
                public virtual void CommandWithEmptyUri()
108
112
                {
109
113
                        try
110
114
                        {
111
 
                                new SubmoduleAddCommand(db).SetPath("sub").SetURI(string.Empty).Call();
 
115
                                new SubmoduleAddCommand(db).SetPath("sub").SetURI(string.Empty).Call().Close();
112
116
                                NUnit.Framework.Assert.Fail("Exception not thrown");
113
117
                        }
114
118
                        catch (ArgumentException e)
132
136
                        command.SetURI(uri);
133
137
                        Repository repo = command.Call();
134
138
                        NUnit.Framework.Assert.IsNotNull(repo);
 
139
                        AddRepoToClose(repo);
135
140
                        SubmoduleWalk generator = SubmoduleWalk.ForIndex(db);
136
141
                        NUnit.Framework.Assert.IsTrue(generator.Next());
137
142
                        NUnit.Framework.Assert.AreEqual(path, generator.GetPath());
139
144
                        NUnit.Framework.Assert.AreEqual(uri, generator.GetModulesUrl());
140
145
                        NUnit.Framework.Assert.AreEqual(path, generator.GetModulesPath());
141
146
                        NUnit.Framework.Assert.AreEqual(uri, generator.GetConfigUrl());
142
 
                        NUnit.Framework.Assert.IsNotNull(generator.GetRepository());
 
147
                        Repository subModRepo = generator.GetRepository();
 
148
                        AddRepoToClose(subModRepo);
 
149
                        NUnit.Framework.Assert.IsNotNull(subModRepo);
143
150
                        NUnit.Framework.Assert.AreEqual(commit, repo.Resolve(Constants.HEAD));
144
151
                        Status status = Git.Wrap(db).Status().Call();
145
152
                        NUnit.Framework.Assert.IsTrue(status.GetAdded().Contains(Constants.DOT_GIT_MODULES
155
162
                        string path = "sub";
156
163
                        DirCache cache = db.LockDirCache();
157
164
                        DirCacheEditor editor = cache.Editor();
158
 
                        editor.Add(new _PathEdit_154(id, path));
 
165
                        editor.Add(new _PathEdit_160(id, path));
159
166
                        editor.Commit();
160
167
                        SubmoduleAddCommand command = new SubmoduleAddCommand(db);
161
168
                        command.SetPath(path);
162
169
                        command.SetURI("git://server/repo.git");
163
170
                        try
164
171
                        {
165
 
                                command.Call();
 
172
                                command.Call().Close();
166
173
                                NUnit.Framework.Assert.Fail("Exception not thrown");
167
174
                        }
168
175
                        catch (JGitInternalException e)
172
179
                        }
173
180
                }
174
181
 
175
 
                private sealed class _PathEdit_154 : DirCacheEditor.PathEdit
 
182
                private sealed class _PathEdit_160 : DirCacheEditor.PathEdit
176
183
                {
177
 
                        public _PathEdit_154(ObjectId id, string baseArg1) : base(baseArg1)
 
184
                        public _PathEdit_160(ObjectId id, string baseArg1) : base(baseArg1)
178
185
                        {
179
186
                                this.id = id;
180
187
                        }
203
210
                        command.SetURI(uri);
204
211
                        Repository repo = command.Call();
205
212
                        NUnit.Framework.Assert.IsNotNull(repo);
 
213
                        AddRepoToClose(repo);
206
214
                        SubmoduleWalk generator = SubmoduleWalk.ForIndex(db);
207
215
                        NUnit.Framework.Assert.IsTrue(generator.Next());
208
216
                        NUnit.Framework.Assert.AreEqual(path, generator.GetPath());
215
223
                                fullUri = fullUri.Replace('\\', '/');
216
224
                        }
217
225
                        NUnit.Framework.Assert.AreEqual(fullUri, generator.GetConfigUrl());
218
 
                        NUnit.Framework.Assert.IsNotNull(generator.GetRepository());
219
 
                        NUnit.Framework.Assert.AreEqual(fullUri, generator.GetRepository().GetConfig().GetString
220
 
                                (ConfigConstants.CONFIG_REMOTE_SECTION, Constants.DEFAULT_REMOTE_NAME, ConfigConstants
221
 
                                .CONFIG_KEY_URL));
 
226
                        Repository subModRepo = generator.GetRepository();
 
227
                        AddRepoToClose(subModRepo);
 
228
                        NUnit.Framework.Assert.IsNotNull(subModRepo);
 
229
                        NUnit.Framework.Assert.AreEqual(fullUri, subModRepo.GetConfig().GetString(ConfigConstants
 
230
                                .CONFIG_REMOTE_SECTION, Constants.DEFAULT_REMOTE_NAME, ConfigConstants.CONFIG_KEY_URL
 
231
                                ));
222
232
                        NUnit.Framework.Assert.AreEqual(commit, repo.Resolve(Constants.HEAD));
223
233
                        Status status = Git.Wrap(db).Status().Call();
224
234
                        NUnit.Framework.Assert.IsTrue(status.GetAdded().Contains(Constants.DOT_GIT_MODULES
248
258
                        command.SetPath(path2);
249
259
                        string url2 = db.Directory.ToURI().ToString();
250
260
                        command.SetURI(url2);
251
 
                        NUnit.Framework.Assert.IsNotNull(command.Call());
 
261
                        Repository r = command.Call();
 
262
                        NUnit.Framework.Assert.IsNotNull(r);
 
263
                        AddRepoToClose(r);
252
264
                        modulesConfig.Load();
253
265
                        NUnit.Framework.Assert.AreEqual(path1, modulesConfig.GetString(ConfigConstants.CONFIG_SUBMODULE_SECTION
254
266
                                , path1, ConfigConstants.CONFIG_KEY_PATH));