コード例 #1
0
        public virtual void TestCheckoutWithNonDeletedFiles()
        {
            FilePath        testFile = WriteTrashFile("temp", string.Empty);
            FileInputStream fis      = new FileInputStream(testFile);

            try
            {
                FileUtils.Delete(testFile);
                return;
            }
            catch (IOException)
            {
            }
            finally
            {
                // the test makes only sense if deletion of
                // a file with open stream fails
                fis.Close();
            }
            FileUtils.Delete(testFile);
            CheckoutCommand co = git.Checkout();

            // delete Test.txt in branch test
            testFile = new FilePath(db.WorkTree, "Test.txt");
            NUnit.Framework.Assert.IsTrue(testFile.Exists());
            FileUtils.Delete(testFile);
            NUnit.Framework.Assert.IsFalse(testFile.Exists());
            git.Add().AddFilepattern("Test.txt");
            git.Commit().SetMessage("Delete Test.txt").SetAll(true).Call();
            git.Checkout().SetName("master").Call();
            NUnit.Framework.Assert.IsTrue(testFile.Exists());
            // lock the file so it can't be deleted (in Windows, that is)
            fis = new FileInputStream(testFile);
            try
            {
                NUnit.Framework.Assert.AreEqual(CheckoutResult.Status.NOT_TRIED, co.GetResult().GetStatus
                                                    ());
                co.SetName("test").Call();
                NUnit.Framework.Assert.IsTrue(testFile.Exists());
                NUnit.Framework.Assert.AreEqual(CheckoutResult.Status.NONDELETED, co.GetResult().
                                                GetStatus());
                NUnit.Framework.Assert.IsTrue(co.GetResult().GetUndeletedList().Contains("Test.txt"
                                                                                         ));
            }
            finally
            {
                fis.Close();
            }
        }
コード例 #2
0
ファイル: CheckoutCommandTest.cs プロジェクト: shoff/ngit
        public virtual void TestCheckoutWithConflict()
        {
            CheckoutCommand co = git.Checkout();

            try
            {
                WriteTrashFile("Test.txt", "Another change");
                NUnit.Framework.Assert.AreEqual(CheckoutResult.Status.NOT_TRIED, co.GetResult().GetStatus
                                                    ());
                co.SetName("master").Call();
                NUnit.Framework.Assert.Fail("Should have failed");
            }
            catch (Exception)
            {
                NUnit.Framework.Assert.AreEqual(CheckoutResult.Status.CONFLICTS, co.GetResult().GetStatus
                                                    ());
                NUnit.Framework.Assert.IsTrue(co.GetResult().GetConflictList().Contains("Test.txt"
                                                                                        ));
            }
        }