Ejemplo n.º 1
0
        public async Task TestGitRecursiveCloneFailsAndDoesntCrash()
        {
            var toCheckout = new GitRepository {
                Url = "git://github.com/xamarin/xamarin-android.git",
            };
            var monitor = new ProgressMonitor();

            var directory = FileService.CreateTempDirectory();

            try {
                await Task.Run(async() => await toCheckout.CheckoutAsync(directory, true, monitor));
            } catch (Exception e) {
                var exception = e.InnerException;
                // libgit2 < 0.26 will throw NotFoundException (result -3)
                // libgit2 >= 0.26 will throw generic LibGit2SharpException (result -1), assert the expected message
                Assert.That(exception, Is.InstanceOf <LibGit2Sharp.NotFoundException> ().Or.Message.EqualTo("reference 'refs/heads/master' not found"));
                return;
            } finally {
                toCheckout.Dispose();
                Directory.Delete(directory, true);
            }

            Assert.Fail("Repository is not reporting loose object cannot be found. Consider removing test.");
        }