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


C# List.Remove方法代码示例

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


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

示例1: ReceiveBeforeSendWithOverflow

        public void ReceiveBeforeSendWithOverflow()
        {
            var c = new BufferedChannel<int>(2);

            var hits = new List<int>();
            var tasks = new List<Task>(5);
            for (int i = 0; i < 5; i++) {
                tasks.Add(Task.Run(() => hits.Add(c.Receive().Result)));
            }

            Assert.AreEqual(0, hits.Count);
            c.Send(1).Wait();
            // the first task to call Receive will complete first, but we can't control
            // the task launch order so we don't know which task that might be
            tasks.Remove(Task.WhenAny(tasks).Result);
            CollectionAssert.AreEqual(new[] { 1 }, hits);

            c.Send(2).Wait();
            tasks.Remove(Task.WhenAny(tasks).Result);
            CollectionAssert.AreEqual(new[] { 1, 2 }, hits);

            c.Send(3).Wait();
            tasks.Remove(Task.WhenAny(tasks).Result);
            CollectionAssert.AreEqual(new[] { 1, 2, 3 }, hits);

            c.Send(4).Wait();
            tasks.Remove(Task.WhenAny(tasks).Result);
            CollectionAssert.AreEqual(new[] { 1, 2, 3, 4 }, hits);

            c.Send(5).Wait();
            tasks.Remove(Task.WhenAny(tasks).Result);
            CollectionAssert.AreEqual(new[] { 1, 2, 3, 4, 5 }, hits);

            Assert.AreEqual(0, tasks.Count);
        }
开发者ID:Porges,项目名称:Ignite2015,代码行数:35,代码来源:BufferedChannelTest.cs

示例2: AssertEmptyWorkspace

 public void AssertEmptyWorkspace(string repodir)
 {
     var entries = new List<string>(Directory.GetFileSystemEntries(Path.Combine(Workdir, repodir)));
     entries.Remove(".");
     entries.Remove("..");
     entries.Remove(".git");
     Assert.AreEqual("", String.Join(", ", entries.ToArray()), "other entries in " + repodir);
 }
开发者ID:dipeshc,项目名称:git-tfs,代码行数:8,代码来源:IntegrationHelper.cs

示例3: CalculateTotalNumberOfVotes

        public List<Candidate> CalculateTotalNumberOfVotes(List<List<Candidate>> listPerSection)
        {
            List<Candidate> finalList = new List<Candidate>();
            bool found = false;

            for (int i = 0; i < listPerSection.Count; i++)
            {
                List<Candidate> currentSection = listPerSection[i];
                for (int j = 0; j < currentSection.Count; j++)
                {
                    found = false;
                    Candidate currentCandidate = currentSection[j];
                    for (int k = 0; k < finalList.Count; k++)
                    {
                        if (finalList.ElementAt(k).name == currentCandidate.name)
                        {
                            found = true;
                            currentCandidate.numberOfVotes += finalList.ElementAt(k).numberOfVotes;
                            finalList.Remove(finalList.ElementAt(k));
                            finalList.Add(currentCandidate);
                            break;
                        }
                    }
                    if (found == false)
                    {
                        finalList.Add(currentCandidate);
                    }
                }
            }

            return finalList;
        }
开发者ID:paulcicio,项目名称:Training,代码行数:32,代码来源:Elections.cs

示例4: Distinct_ObservableSource_NoUpdateWhenDetached

        public void Distinct_ObservableSource_NoUpdateWhenDetached()
        {
            var update = false;
            var coll = new List<int>() { 1, 2, 2, 3 };

            var test = coll.WithUpdates().Distinct();

            test.CollectionChanged += (o, e) => update = true;

            Assert.AreEqual(3, test.Count());
            Assert.IsFalse(update);

            test.Detach();
            update = false;

            coll.Add(4);

            Assert.IsFalse(update);

            test.Attach();

            Assert.IsTrue(update);
            Assert.AreEqual(4, test.Count());
            update = true;

            coll.Remove(4);

            Assert.IsTrue(update);
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:29,代码来源:DistinctTest.cs

示例5: NodeIteratorJavaScriptKitDivision

        public void NodeIteratorJavaScriptKitDivision()
        {
            var source = @"<div id=contentarea>
            <p>Some <span>text</span></p>
            <b>Bold text</b>
            </div>";
            var doc = DocumentBuilder.Html(source);
            Assert.IsNotNull(doc);

            var rootnode = doc.GetElementById("contentarea");
            Assert.IsNotNull(rootnode);

            var iterator = doc.CreateNodeIterator(rootnode, FilterSettings.Element);
            Assert.IsNotNull(iterator);
            Assert.AreEqual(rootnode, iterator.Root);
            Assert.IsTrue(iterator.IsBeforeReference);

            var results = new List<INode>();

            while (iterator.Next() != null)
                results.Add(iterator.Reference);

            Assert.IsFalse(iterator.IsBeforeReference);
            Assert.AreEqual(3, results.Count);
            Assert.IsInstanceOfType(results[0], typeof(HTMLParagraphElement));
            Assert.IsInstanceOfType(results[1], typeof(HTMLSpanElement));
            Assert.IsInstanceOfType(results[2], typeof(HTMLBoldElement));

            do
                results.Remove(iterator.Reference);
            while (iterator.Previous() != null);

            Assert.IsTrue(iterator.IsBeforeReference);
        }
开发者ID:jogibear9988,项目名称:AngleSharp,代码行数:34,代码来源:NodeIterator.cs

示例6: TestBDD_AjoutSupprJedi

        public void TestBDD_AjoutSupprJedi()
        {
            List<Jedi> lj = new List<Jedi>(data.getAllJedi());
            // Création du jedi
            int id = 42;
            String name = "Sloubi";
            bool isSith = true;
            Caracteristique carac = data.getAllCaracteristic().Find(c => c.Id == 1);

            List<Caracteristique> lc = new List<Caracteristique>();
            lc.Add(carac);

            Jedi jedi = new Jedi(id, name, isSith, lc);

            // Modifications BDD
            Assert.IsFalse(data.getAllJedi().Any(j => j.Id == id), "Ce jedi est déjà présent dans la BDD !");    // On vérifie que le jedi n'est pas déjà présent dans la BDD

            lj.Add(jedi);
            data.updateJedi(lj);

            Assert.IsTrue(data.getAllJedi().Any(j => j.Id == id), "Le jedi n'a pas été ajouté");     // On vérifie que le jedi a bien été rajouté
            Assert.AreEqual(data.getAllJedi().Find(j => j.Id == id).Nom, name, "Le nom du jedi ne correspond pas");
            Assert.AreEqual(data.getAllJedi().Find(j => j.Id == id).IsSith, isSith, "Le côté de la force du jedi ne correspond pas");

            lj.Remove(lj.Find(j => j.Id == id));
            data.updateJedi(lj);

            Assert.IsFalse(data.getAllJedi().Any(j => j.Id == id), "Le jedi n'a pas été supprimé");    // On vérifie que le jedi a bien été supprimé
        }
开发者ID:theCmaker,项目名称:ZZ2_services_reseau,代码行数:29,代码来源:BusinessManagerTests.cs

示例7: CompareRemoveTime

        public void CompareRemoveTime()
        {
            var itemsCount = 10000;

            var list = new List<int>();
            for (int i = 0; i < itemsCount; i++)
            {
                list.Add(i);
            }

            var startTime = DateTime.Now;

            list.Remove(5000);

            var listRemoveTime = DateTime.Now - startTime;

            var avlTree = new AvlTree<int>();

            for (int i = 0; i < itemsCount; i++)
            {
                avlTree.Add(i);
            }

            startTime = DateTime.Now;

            avlTree.Remove(5000);

            var avlRemoveTime = DateTime.Now - startTime;
        }
开发者ID:kament,项目名称:SDA_SU_CollectionsForDummies,代码行数:29,代码来源:AvlTreeSpeedTests.cs

示例8: TestBDD_AjoutSupprCarac

        public void TestBDD_AjoutSupprCarac()
        {
            List<Caracteristique> lc = new List<Caracteristique>(data.getAllCaracteristic());
            // Création de la caractéristique
            int id = 42;
            EDefCaracteristique def = EDefCaracteristique.Chance;
            String text = "Carac ajoutée Jedi";
            ETypeCaracteristique type = ETypeCaracteristique.Jedi;
            int val = 20;
            Caracteristique carac = new Caracteristique(id, def, text, type, val);

            // Modifications BDD
            Assert.IsFalse(data.getAllCaracteristic().Any(c => c.Id == id), "Cette caractéristique est déjà présente dans la BDD !");    // On vérifie que la caractéristique n'est pas déjà présente dans la BDD
            
            lc.Add(carac);
            data.updateCaracteristique(lc);

            Assert.IsTrue(data.getAllCaracteristic().Any(c => c.Id == id), "La caractéristique n'a pas été ajoutée");     // On vérifie que la caractéristique a bien été rajoutée
            Assert.AreEqual(data.getAllCaracteristic().Find(c => c.Id == id).Definition, def);
            Assert.AreEqual(data.getAllCaracteristic().Find(c => c.Id == id).Nom, text);
            Assert.AreEqual(data.getAllCaracteristic().Find(c => c.Id == id).Type, type);
            Assert.AreEqual(data.getAllCaracteristic().Find(c => c.Id == id).Valeur, val);

            lc.Remove(lc.Find(c => c.Id == id));
            data.updateCaracteristique(lc);

            Assert.IsFalse(data.getAllCaracteristic().Any(c => c.Id == id), "La caractéristique n'a pas été supprimée");    // On vérifie que la caractéristique a bien été supprimée
        }
开发者ID:theCmaker,项目名称:ZZ2_services_reseau,代码行数:28,代码来源:BusinessManagerTests.cs

示例9: TestContent

        public void TestContent(int value)
        {
            Assert.AreEqual(5, ff.FindElements(By.ClassName("result-name")).Count);
            Assert.AreEqual(5, ff.FindElements(By.ClassName("result-values")).Count);
            Assert.AreEqual(5, ff.FindElements(By.ClassName("result-div")).Count);

            ICollection<string> names = new List<string> { "normal", "odd", "even", "special", "fibonacci" };

            foreach (IWebElement el in ff.FindElements(By.ClassName("result-div")))
            {
                string nameContent = el.FindElement(By.ClassName("result-name")).GetAttribute("innerHTML");
                string valuesContent = el.FindElement(By.ClassName("result-values")).GetAttribute("innerHTML");
                foreach (string name in names)
                {
                    if (nameContent.Contains(name))
                    {
                        Debug.WriteLine("remove: " + name);
                        names.Remove(name);
                        ICollection<string> expected = GetAPIResult(value, name);
                        ICollection<string> result = TransformContent(valuesContent);
                        Debug.WriteLine("values expected-size: " + expected.Count + " : " + string.Join(",", ((List<string>)expected).ToArray()));
                        Debug.WriteLine("values result-size: " + result.Count + " : " + string.Join(",", ((List<string>)result).ToArray()));
                        CollectionAssert.AreEqual(expected as List<string>, result as List<string>);
                        break;
                    }
                }
            }
            Assert.AreEqual(0, names.Count);
        }
开发者ID:Galardolind,项目名称:NumericSequenceCalculator,代码行数:29,代码来源:UnitTest1.cs

示例10: PersonnelTest1

        public void PersonnelTest1()
        {
            List<IRole> roles = new List<IRole>();
            roles.Add(new XRayRole());
            Personnel p1 = new Personnel(1,roles);
            bool pass1 = roles == p1.get_roles();

            IRole loaderrole = new LoaderRole();
            roles.Add(loaderrole);
            p1.add_role(loaderrole);
            bool pass2 = roles == p1.get_roles();

            roles.Remove(loaderrole);
            p1.remove_role(new LoaderRole());
            p1.add_role(loaderrole);
            bool pass3 = roles == p1.get_roles();

            bool fail1 = false;
            try
            {
                p1.add_role(new LoaderRole());
            }
            catch (Exception e)
            {
                if (e.GetType().FullName == "System.Diagnostics.Contracts.__ContractsRuntime+ContractException")
                    fail1 = true;

            }

            Assert.IsTrue(pass1);
            Assert.IsTrue(pass2);
            Assert.IsTrue(pass3);
            Assert.IsTrue(fail1);
        }
开发者ID:skulifh,项目名称:conveyor_belt_simulator,代码行数:34,代码来源:PersonnelTest.cs

示例11: CrossProcessBarrierTest

        public void CrossProcessBarrierTest()
        {
            IEnumerable<string> allNames = new List<string>
                                {
                                    "deployment(400).GenericWorkerRole.Cloud.WebRole.0_Web",
                                    "deployment(400).GenericWorkerRole.Cloud.WebRole.1_Web",
                                    "deployment(400).GenericWorkerRole.Cloud.WebRole.2_Web",
                                    "deployment(400).GenericWorkerRole.Cloud.WebRole.3_Web",
                                    "deployment(400).GenericWorkerRole.Cloud.WebRole.4_Web"
                                };

            Func<string, string> escapeMutexName = instanceId => instanceId.Replace("(", ".").Replace(")", ".").Replace(".", "");
            allNames = allNames.Select(escapeMutexName);
            
            var tasks = new List<Task>();
            foreach (var currentName in allNames)
            {
                var peerNames = new List<string>(allNames);
                peerNames.Remove(currentName);

                var c = CrossProcessBarrier.GetInstance(currentName, peerNames, TimeSpan.Zero);
                tasks.Add(Task.Factory.StartNew(c.Wait));
                Trace.TraceInformation("Launched task {0}", currentName);
            }

            Trace.TraceInformation("Waiting for all tasks to reach the barrier");
            Task.WaitAll(tasks.ToArray());
            Trace.TraceInformation("All tasks reached the barrier");
        }
开发者ID:nobitagamer,项目名称:azureiisconfiguratorsync,代码行数:29,代码来源:UnitTest1.cs

示例12: GalleriesEditComplexTest

        public void GalleriesEditComplexTest()
        {
            Flickr.FlushCache();
            Flickr.CacheDisabled = true;

            string primaryPhotoId = "486875512";
            string comment = "You don't get much better than this for the best Entrance to Hell.\n\n" + DateTime.Now.ToString();
            string galleryId = "78188-72157622589312064";

            Flickr f = TestData.GetAuthInstance();

            // Get photos
            var photos = f.GalleriesGetPhotos(galleryId);

            List<string> photoIds = new List<string>();
            foreach (var p in photos) photoIds.Add(p.PhotoId);

            // Remove the last one.
            GalleryPhoto photo = photos[photos.Count - 1];
            photoIds.Remove(photo.PhotoId);

            // Update the gallery
            f.GalleriesEditPhotos(galleryId, primaryPhotoId, photoIds);

            // Check removed photo no longer returned.
            var photos2 = f.GalleriesGetPhotos(galleryId);

            Assert.AreEqual(photos.Count - 1, photos2.Count, "Should be one less photo.");

            bool found = false;
            foreach (var p in photos2)
            {
                if (p.PhotoId == photo.PhotoId)
                {
                    found = true;
                    break;
                }
            }
            Assert.IsFalse(false, "Should not have found the photo in the gallery.");

            // Add photo back in
            f.GalleriesAddPhoto(galleryId, photo.PhotoId, photo.Comment);

            var photos3 = f.GalleriesGetPhotos(galleryId);
            Assert.AreEqual(photos.Count, photos3.Count, "Count should match now photo added back in.");

            found = false;
            foreach (var p in photos3)
            {
                if (p.PhotoId == photo.PhotoId)
                {
                    Assert.AreEqual(photo.Comment, p.Comment, "Comment should have been updated.");
                    found = true;
                    break;
                }
            }

            Assert.IsTrue(found, "Should have found the photo in the gallery.");
        }
开发者ID:simm0n,项目名称:Synchronizr,代码行数:59,代码来源:GalleriesTests.cs

示例13: ListRemoveTest

 public void ListRemoveTest()
 {
     var list = new List<int>();
     list.Add(1);
     list.Add(2);
     list.Remove(2);
     Assert.IsFalse(list.Contains(2));
 }
开发者ID:Kirill-Andreev,项目名称:University,代码行数:8,代码来源:GenericsTest.cs

示例14: FirstListTest

 public void FirstListTest()
 {
     var list = new List<int>();
     list.Add(10);
     Assert.IsTrue(list.Contains(10));
     list.Remove(10);
     Assert.AreEqual(0, list.GetLength());
 }
开发者ID:Ivan-Nebogatikov,项目名称:Homeworks,代码行数:8,代码来源:ListTests.cs

示例15: testListRemove

 public void testListRemove()
 {
     List<int> one = new List<int>();
     one.Add(1);
     Assert.AreEqual(1, one.Count);
     one.Remove(0);
     Assert.AreEqual(0, one.Count);
 }
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:8,代码来源:ListTest.cs


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