当前位置: 首页>>代码示例>>C#>>正文


C# Repository.Remove方法代码示例

本文整理汇总了C#中Repository.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.Remove方法的具体用法?C# Repository.Remove怎么用?C# Repository.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Repository的用法示例。


在下文中一共展示了Repository.Remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CanRemoveAnUnalteredFileFromTheIndexWithoutRemovingItFromTheWorkingDirectory

        public void CanRemoveAnUnalteredFileFromTheIndexWithoutRemovingItFromTheWorkingDirectory(
            bool removeFromWorkdir, string filename, bool throws, FileStatus initialStatus, bool existsBeforeRemove, bool existsAfterRemove, FileStatus lastStatus)
        {
            string path = SandboxStandardTestRepo();
            using (var repo = new Repository(path))
            {
                int count = repo.Index.Count;

                string fullpath = Path.Combine(repo.Info.WorkingDirectory, filename);

                Assert.Equal(initialStatus, repo.RetrieveStatus(filename));
                Assert.Equal(existsBeforeRemove, File.Exists(fullpath));

                if (throws)
                {
                    Assert.Throws<RemoveFromIndexException>(() => repo.Remove(filename, removeFromWorkdir));
                    Assert.Equal(count, repo.Index.Count);
                }
                else
                {
                    repo.Remove(filename, removeFromWorkdir);

                    Assert.Equal(count - 1, repo.Index.Count);
                    Assert.Equal(existsAfterRemove, File.Exists(fullpath));
                    Assert.Equal(lastStatus, repo.RetrieveStatus(filename));
                }
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:28,代码来源:RemoveFixture.cs

示例2: Delete

        public void Delete()
        {
            using (var context = new MainContext())
            {
                var myRepo = new Repository<Core.Customer>(context);
                TotalCustomersBeforeTestRuns = myRepo.GetAll().Count();

                var allEntities = myRepo.GetAll().ToList();
                if (allEntities.Count > 0)
                {
                    //Find an entity to be removed.
                    var firstClientInTheDb = allEntities.FirstOrDefault();

                    //Check if there is an entity to be removed
                    if (firstClientInTheDb != null)
                    {
                        myRepo.Remove(firstClientInTheDb.Id);
                        myRepo.Save();

                        TotalOfClientsAfterTheTestRuns = myRepo.GetAll().Count();

                        // Check if the total number of entites was reduced by one.
                        Assert.AreEqual(TotalCustomersBeforeTestRuns - 1, TotalOfClientsAfterTheTestRuns);
                    }

                }
            }
        }
开发者ID:rafaelfernandesnet,项目名称:HotelClub,代码行数:28,代码来源:ClientRepositoryCanDelete.cs

示例3: CanResolveConflictsByRemovingFromTheIndex

        public void CanResolveConflictsByRemovingFromTheIndex(
            bool removeFromWorkdir, string filename, bool existsBeforeRemove, bool existsAfterRemove, FileStatus lastStatus, int removedIndexEntries)
        {
            var path = SandboxMergedTestRepo();
            using (var repo = new Repository(path))
            {
                int count = repo.Index.Count;

                string fullpath = Path.Combine(repo.Info.WorkingDirectory, filename);

                Assert.Equal(existsBeforeRemove, File.Exists(fullpath));
                Assert.NotNull(repo.Index.Conflicts[filename]);
                Assert.Equal(0, repo.Index.Conflicts.ResolvedConflicts.Count());

                repo.Remove(filename, removeFromWorkdir);

                Assert.Null(repo.Index.Conflicts[filename]);
                Assert.Equal(count - removedIndexEntries, repo.Index.Count);
                Assert.Equal(existsAfterRemove, File.Exists(fullpath));
                Assert.Equal(lastStatus, repo.RetrieveStatus(filename));

                Assert.Equal(1, repo.Index.Conflicts.ResolvedConflicts.Count());
                Assert.NotNull(repo.Index.Conflicts.ResolvedConflicts[filename]);
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:25,代码来源:ConflictFixture.cs

示例4: Remove

 public void Remove()
 {
     Repository repository = new Repository();
     UserModel user = new UserModel();
     user.Id = 4;
     repository.Remove<UserModel>(user);
 }
开发者ID:eduardohdzc,项目名称:pmsys_sim,代码行数:7,代码来源:RepositoryTests.cs

示例5: CanRemoveAFolderThroughUsageOfPathspecsForFilesAlreadyInTheIndexAndInTheHEAD

        public void CanRemoveAFolderThroughUsageOfPathspecsForFilesAlreadyInTheIndexAndInTheHEAD()
        {
            string path = CloneStandardTestRepo();
            using (var repo = new Repository(path))
            {
                int count = repo.Index.Count;

                Assert.True(Directory.Exists(Path.Combine(repo.Info.WorkingDirectory, "1")));
                repo.Remove("1");

                Assert.False(Directory.Exists(Path.Combine(repo.Info.WorkingDirectory, "1")));
                Assert.Equal(count - 1, repo.Index.Count);
            }
        }
开发者ID:nulltoken,项目名称:libgit2sharp,代码行数:14,代码来源:RemoveFixture.cs

示例6: DeleteTest

 public void DeleteTest()
 {
     IRepository<Pacient> rep = new Repository<Pacient>(path);
     int i = rep.GetAll().Count();
     rep.Remove(10);
     if (i > 0)
     {
         i--;
     }
     else
     {
         i = 0;
     }
     Assert.AreEqual(rep.GetAll().Count(), i);
 }
开发者ID:WilliamRobertMontgomery,项目名称:asp-dot-net-training-project,代码行数:15,代码来源:RepositoryTest.cs

示例7: Dispose

        public virtual void Dispose()
        {
            //Clean the database
            using (var context = new MainContext())
            {
                var myRepo = new Repository<Address>(context);

                //Get the Address to be removed.
                MyNewAddress = myRepo.Query(s => s.AddressLine1 == MyNewAddress.AddressLine1).FirstOrDefault();

                if (myRepo.GetAll().Any())
                {
                    myRepo.Remove(MyNewAddress);
                    myRepo.Save();
                }
            }
        }
开发者ID:rafaelfernandesnet,项目名称:HotelClub,代码行数:17,代码来源:AdressRepositoryBase.cs

示例8: RemoveInstanceTest

        public void RemoveInstanceTest()
        {
            var p = new Person
            {
                Name = "John Doe",
                Age = 24,
                Email = "[email protected]",
            };

            var crate = new Repository("Crate");

            crate.Remove(p);

            var actual = crate.Data.First(c => c.Name == "Person").Type;

            const OperationType expected = OperationType.Removing;

            Assert.AreEqual(expected, actual);
        }
开发者ID:v-lukyanenko,项目名称:Crate.DataStorage,代码行数:19,代码来源:RepositoryTest.cs

示例9: CanRemoveAFolderThroughUsageOfPathspecsForNewlyAddedFiles

        public void CanRemoveAFolderThroughUsageOfPathspecsForNewlyAddedFiles()
        {
            string path = CloneStandardTestRepo();
            using (var repo = new Repository(path))
            {
                repo.Stage(Touch(repo.Info.WorkingDirectory, "2/subdir1/2.txt", "whone"));
                repo.Stage(Touch(repo.Info.WorkingDirectory, "2/subdir1/3.txt", "too"));
                repo.Stage(Touch(repo.Info.WorkingDirectory, "2/subdir2/4.txt", "tree"));
                repo.Stage(Touch(repo.Info.WorkingDirectory, "2/5.txt", "for"));
                repo.Stage(Touch(repo.Info.WorkingDirectory, "2/6.txt", "fyve"));

                int count = repo.Index.Count;

                Assert.True(Directory.Exists(Path.Combine(repo.Info.WorkingDirectory, "2")));
                repo.Remove("2", false);

                Assert.Equal(count - 5, repo.Index.Count);
            }
        }
开发者ID:nulltoken,项目名称:libgit2sharp,代码行数:19,代码来源:RemoveFixture.cs

示例10: Main

        static void Main(string[] args)
        {
            IRepository repo = new Repository();
            Product product = new Product(5, 55.5m, "kalipso", "djolan");
            Product product2 = new Product(6, 55.6m, "kalipso", "djolan");
            Product product3 = new Product(7, 55.5m, "kalipso", "djolan");
            Product product4 = new Product(8, 55.5m, "kalipso", "djolan");

            repo.Add(product);
            repo.Add(product2);
            repo.Add(product3);
            repo.Add(product4);

            var productsByTitle = repo.FindByTitle("kalipso");
            var productsBySupplierAndPriceRange = repo.FindBySupplierAndPriceRange("djolan", 55.5m, 55.6m);
            var productByTitleAndPriceRange = repo.FindByTitleAndPriceRange("kalipso", 55.5m, 55.6m);
            var productByPriceRange = repo.FindByPriceRange(55.5m, 55.6m);
            var productsByTitleAndPrice = repo.FindByTitleAndPrice("kalipso", 55.5m);
            var productsBySupplierAndPrice = repo.FindBySupplierAndPrice("djolan", 55.5m);

            bool isSuccessfullyRemoved = repo.Remove(product.Id);
        }
开发者ID:simooo93,项目名称:SoftUni-Homeworks,代码行数:22,代码来源:Program.cs

示例11: CanDetectABinaryDeletion

        public void CanDetectABinaryDeletion()
        {
            using (var repo = new Repository(SandboxStandardTestRepo()))
            {
                const string filename = "binfile.foo";
                var filepath = Path.Combine(repo.Info.WorkingDirectory, filename);

                CreateBinaryFile(filepath);

                repo.Stage(filename);
                var commit = repo.Commit("Add binary file", Constants.Signature, Constants.Signature);

                File.Delete(filepath);

                var patch = repo.Diff.Compare<Patch>(commit.Tree, DiffTargets.WorkingDirectory, new [] {filename});
                Assert.True(patch[filename].IsBinaryComparison);

                repo.Remove(filename);
                var commit2 = repo.Commit("Delete binary file", Constants.Signature, Constants.Signature);

                var patch2 = repo.Diff.Compare<Patch>(commit.Tree, commit2.Tree, new[] { filename });
                Assert.True(patch2[filename].IsBinaryComparison);
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:24,代码来源:DiffTreeToTreeFixture.cs

示例12: using

 public int 仓库信息_Delete(string 仓库信息编码)
 {
     using (var context = new BDKRContext())
     {
         var r = new Repository<仓库信息>(context);
         var e = r.GetSingle(t => t.编码 == 仓库信息编码);
         if (null == e)
             throw new Exception("仓库信息并不存在");
         if (e.实时库存明细List != null && e.实时库存明细List.Count > 0)
             throw new Exception("实时库存中含有此仓库信息,无法删除!");
         if (e.采购进货单明细List != null && e.采购进货单明细List.Count > 0)
             throw new Exception("采购进货单明细中含有此仓库信息,无法删除!");
         return r.Remove(e);
     }
 }
开发者ID:FicerLee,项目名称:BDKR,代码行数:15,代码来源:BDKRWS.svc.cs

示例13: InsertAndRemove

        //===============================================================
        public static void InsertAndRemove(Repository<TestClass> testObjects)
        {
            var testObj = new TestClass("myKey", "myValue");

            testObjects.Insert(testObj);
            testObjects.SaveChanges();

            var storedObj = testObjects.Find(testObj.ID);
            Assert.NotNull(storedObj.Object);
            Assert.AreEqual(testObj.ID, storedObj.Object.ID);
            Assert.AreEqual(testObj.ID, storedObj.Object.ID);

            testObjects.Remove(testObj);
            testObjects.SaveChanges();

            storedObj = testObjects.Find(testObj.ID);
            Assert.Null(storedObj);

            testObjects.RemoveAll();
            testObjects.SaveChanges();
        }
开发者ID:racingslab,项目名称:Repository,代码行数:22,代码来源:StandardTests.cs

示例14: CanMergeIntoOrphanedBranch

        public void CanMergeIntoOrphanedBranch()
        {
            string path = SandboxMergeTestRepo();
            using (var repo = new Repository(path))
            {
                repo.Refs.Add("HEAD", "refs/heads/orphan", true);

                // Remove entries from the working directory
                foreach(var entry in repo.RetrieveStatus())
                {
                    repo.Unstage(entry.FilePath);
                    repo.Remove(entry.FilePath, true);
                }

                // Assert that we have an empty working directory.
                Assert.False(repo.RetrieveStatus().Any());

                MergeResult result = repo.Merge("master", Constants.Signature);

                Assert.Equal(MergeStatus.FastForward, result.Status);
                Assert.Equal(masterBranchInitialId, result.Commit.Id.Sha);
                Assert.False(repo.RetrieveStatus().Any());
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:24,代码来源:MergeFixture.cs

示例15: RemoveEntryFromRepositoryTest

        public void RemoveEntryFromRepositoryTest()
        {
            const string connectionString = @"Data Source=VLADIMIR5D4B\SQLSERVER;Initial Catalog=Crate;Integrated Security=true;";
            var dc = new SqlServerContext(connectionString, "");

            var p = new Person
            {
                Name = "John Doe",
                Age = 24,
                Email = "[email protected]"
            };

            var repository = new Repository("ConsoleApp");

            dc.Clear<Person>(repository);

            repository.Add(p);
            dc.SubmitChanges(repository);

            repository.Remove(p);
            dc.SubmitChanges(repository);

            var people = dc.Select<Person>(repository);

            Assert.AreEqual(0, people.Count());
        }
开发者ID:v-lukyanenko,项目名称:Crate.DataStorage,代码行数:26,代码来源:SqlServerContextTest.cs


注:本文中的Repository.Remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。