當前位置: 首頁>>代碼示例>>C#>>正文


C# List.Remove方法代碼示例

本文整理匯總了C#中NUnit.Framework.List.Remove方法的典型用法代碼示例。如果您正苦於以下問題:C# List.Remove方法的具體用法?C# List.Remove怎麽用?C# List.Remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NUnit.Framework.List的用法示例。


在下文中一共展示了List.Remove方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Can_get_lots_of_records_with_new_instantiation_every_time_test

        public void Can_get_lots_of_records_with_new_instantiation_every_time_test()
        {
            var times = new List<double>();

            for (int i = 0; i < 40; ++i)
            {
                var sw = Stopwatch.StartNew();
                var dapperDriver = new DapperDriver();
                var rows = dapperDriver.GetLotsOfRecords<TransactionHistory>();

                Assert.That(rows, Is.Not.Null);
                Assert.That(rows.Count(), Is.GreaterThan(0));

                sw.Stop();

                times.Add(sw.ElapsedMilliseconds);
                Console.WriteLine("took {0} ms to get {1} records",
                    sw.ElapsedMilliseconds,
                    rows.Count());
            }

            Console.WriteLine("average: {0}, min: {1}, max: {2}",
                times.Average(),
                times.Min(),
                times.Max());

            var timesSansMinAndMax = new List<double>();
            timesSansMinAndMax.AddRange(times);
            timesSansMinAndMax.Remove(timesSansMinAndMax.Min());
            timesSansMinAndMax.Remove(timesSansMinAndMax.Max());
            Console.WriteLine("average sans min & max: {0}",
                timesSansMinAndMax.Average());
        }
開發者ID:jeff-vera,項目名稱:ef6-vs-dapper,代碼行數:33,代碼來源:DapperDriverTests.cs

示例2: Can_get_few_records_test

        public void Can_get_few_records_test()
        {
            var efDriver = new EFDriver();
            var times = new List<double>();

            for (int i = 0; i < 100; ++i)
            {
                var sw = Stopwatch.StartNew();
                var rows = efDriver.GetAFewRecords();

                Assert.That(rows, Is.Not.Null);
                Assert.That(rows.Count(), Is.GreaterThan(0));

                sw.Stop();

                times.Add(sw.ElapsedMilliseconds);
                Console.WriteLine("took {0} ms to get {1} records",
                    sw.ElapsedMilliseconds,
                    rows.Count());
            }

            Console.WriteLine("average: {0}, min: {1}, max: {2}, std dev: {3}, median: {4}",
                times.Average(),
                times.Min(),
                times.Max(),
                times.StandardDeviation(),
                times.Median());

            var timesSansMinAndMax = new List<double>();
            timesSansMinAndMax.AddRange(times);
            timesSansMinAndMax.Remove(timesSansMinAndMax.Min());
            timesSansMinAndMax.Remove(timesSansMinAndMax.Max());
            Console.WriteLine("average sans min & max: {0}",
                timesSansMinAndMax.Average());
        }
開發者ID:jeff-vera,項目名稱:ef6-vs-dapper,代碼行數:35,代碼來源:EFDriverTests.cs

示例3: RemoveWithNullItems

        public void RemoveWithNullItems()
        {
            ICollection<int> col = new List<int> { 1, 2, 3 };

            col.Remove((int[])null);
            Assert.IsTrue(col.SequenceEqual(new [] { 1, 2, 3 }));
        }
開發者ID:shchimisyaotsel,項目名稱:iSynaptic.Commons,代碼行數:7,代碼來源:CollectionExtensionsTests.cs

示例4: RemoveWithEmptyItems

        public void RemoveWithEmptyItems()
        {
            ICollection<int> col = new List<int> { 1, 2, 3 };

            col.Remove(new int[] { });
            Assert.IsTrue(col.SequenceEqual(new [] { 1, 2, 3 }));
        }
開發者ID:shchimisyaotsel,項目名稱:iSynaptic.Commons,代碼行數:7,代碼來源:CollectionExtensionsTests.cs

示例5: RemoveItems

        public void RemoveItems()
        {
            ICollection<int> col = new List<int> { 1, 2, 3, 4, 5 };

            col.Remove(new int[] { 2, 4 });
            Assert.IsTrue(col.SequenceEqual(new [] { 1, 3, 5 }));
        }
開發者ID:shchimisyaotsel,項目名稱:iSynaptic.Commons,代碼行數:7,代碼來源:CollectionExtensionsTests.cs

示例6: NodeIteratorJavaScriptKitDivision

        public void NodeIteratorJavaScriptKitDivision()
        {
            var source = @"<div id=contentarea>
<p>Some <span>text</span></p>
<b>Bold text</b>
</div>";
            var doc = 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.IsInstanceOf<HtmlParagraphElement>(results[0]);
            Assert.IsInstanceOf<HtmlSpanElement>(results[1]);
            Assert.IsInstanceOf<HtmlBoldElement>(results[2]);

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

            Assert.IsTrue(iterator.IsBeforeReference);
        }
開發者ID:fjwuyongzhi,項目名稱:AngleSharp,代碼行數:34,代碼來源:NodeIterator.cs

示例7: CheckStringsDeclared

        public void CheckStringsDeclared()
        {
            var names = new List<string>();
            checker.GetAllResourceReferences(names);
            Assert.Greater(names.Count, 400, "Должно быть много ресурсных строчек");

            // убрать исключения и повторы
            names = names.Distinct().ToList();
            names.Remove("ResourceManager");

            // проверить, есть ли они в файлах ресурсов
            var errorsInFile = new Dictionary<string, List<string>>();
            var resxFileNames = Directory.GetFiles(codeBase + @"\TradeSharp.AdminSite\App_GlobalResources", "*.resx");

            foreach (var resxFileName in resxFileNames)
            {
                var errors = checker.GetNamesLackInResxFile(resxFileName, names);
                if (errors.Count > 0)
                    errorsInFile.Add(Path.GetFileName(resxFileName), errors);
            }

            if (errorsInFile.Count > 0)
            {
                var errorStr = string.Join("\n", errorsInFile.Select(e => e.Key + ": " + string.Join(", ", e.Value)));
                Assert.Fail(errorStr);
            }
        }
開發者ID:johnmensen,項目名稱:TradeSharp,代碼行數:27,代碼來源:NuCheckAllResourcesExist.cs

示例8: SetUp

        public void SetUp()
        {
            MigrationTestHelper.Clear();
            _versionsFromDatabase = new List<long> { 0 };

            var provider = new Mock<IDataProvider>();
            provider.Setup(x => x.DatabaseKind).Returns(DatabaseKind.Oracle);

            var database = new Mock<IDatabase>();
            database.Setup(x => x.Provider).Returns(provider.Object);

            _dataClient = new Mock<IDataClient>();
            _dataClient.Setup(p => p.TableExists(VersionRepository.VERSION_TABLE_NAME)).Returns(true);
            _dataClient.Setup(x => x.Database).Returns(database.Object);

            _versionRepository = new Mock<IVersionRepository>();
            _versionRepository.Setup(x => x.GetCurrentVersion()).Returns(() => _versionsFromDatabase.Last());
            _versionRepository.Setup(x => x.GetAppliedMigrations()).Returns(() => _versionsFromDatabase);
            _versionRepository.Setup(x => x.InsertVersion(It.IsAny<MigrationInfo>()))
                .Callback<MigrationInfo>(m => _versionsFromDatabase.Add(m.Version));
            _versionRepository.Setup(x => x.RemoveVersion(It.IsAny<MigrationInfo>()))
                .Callback<MigrationInfo>(m => _versionsFromDatabase.Remove(m.Version));

            _runner = new Runner(_dataClient.Object, Assembly.GetExecutingAssembly());
            _runner.VersionRepository = _versionRepository.Object;
        }
開發者ID:sharpmigrations,項目名稱:sharpmigrations,代碼行數:26,代碼來源:RunnerTests.cs

示例9: Copy

        public void Copy()
        {
            var data = new int[][]
            {
                new int[] { 1, 2, 3 },
                new int[] { 4, 5, 6 },
                new int[] { 7, 8, 9 }
            };

            var original = new List<List<int>>();
            foreach (var row in data)
            {
                original.Add(row.ToList());
            }

            var copy = original.Copy();

            // the copy contains the same items as the original
            // so if you modify the items they are modified in both
            Assert.AreEqual(original[1][1], copy[1][1]);
            original[1][1] = 0;
            Assert.AreEqual(original[1][1], copy[1][1]);

            // if you remove an item in the original list the item
            // is not removed in the copy
            original.Remove(original[2]);
            Assert.AreEqual(2, original.Count());
            Assert.AreEqual(3, copy.Count());

            // if you switch out an item in one copy it does not
            // modify the other copy
            Assert.AreEqual(original[0][0], copy[0][0]);
            original[0] = data[2].ToList();
            Assert.IsFalse(original[0][0] == copy[0][0]);
        }
開發者ID:juswaldy,項目名稱:Nvelope,代碼行數:35,代碼來源:ListExtensionTests.cs

示例10: Can_Delete_from_basic_persistence_provider

        public void Can_Delete_from_basic_persistence_provider()
        {
            using (var db = ConnectionString.OpenDbConnection())
            using (var dbCmd = db.CreateCommand())
            {
                dbCmd.CreateTable<ModelWithFieldsOfDifferentTypes>(true);

                var basicProvider = new OrmLitePersistenceProvider(db);

                var rowIds = new List<int> { 1, 2, 3, 4, 5 };

                var rows = rowIds.ConvertAll(x => ModelWithFieldsOfDifferentTypes.Create(x));

                rows.ForEach(x => dbCmd.Insert(x));

                var deleteRowIds = new List<int> { 2, 4 };

                foreach (var row in rows)
                {
                    if (deleteRowIds.Contains(row.Id))
                    {
                        basicProvider.Delete(row);
                    }
                }

                var providerRows = basicProvider.GetByIds<ModelWithFieldsOfDifferentTypes>(rowIds).ToList();
                var providerRowIds = providerRows.ConvertAll(x => x.Id);

                var remainingIds = new List<int>(rowIds);
                deleteRowIds.ForEach(x => remainingIds.Remove(x));

                Assert.That(providerRowIds, Is.EquivalentTo(remainingIds));
            }
        }
開發者ID:EvgeniyProtas,項目名稱:servicestack,代碼行數:34,代碼來源:OrmLiteBasicPersistenceProviderTests.cs

示例11: It_notifies_about_removing_an_entry

        public async Task It_notifies_about_removing_an_entry()
        {
            var fakeSchedule = new FakeSchedule();
            var entries = new List<Entry>();
            var fakeBackplane = new FakeBackplane("A", entries);
            var otherBackplane = new FakeBackplane("B", entries);

            var client = new DataBackplaneClient(fakeBackplane, fakeSchedule);
            await client.Start();
            var readValues = new List<string>();
            var subscription = await client.GetAllAndSubscribeToChanges("T1", entry =>
            {
                readValues.Add(entry.Data);
                return Task.FromResult(0);
            }, entry =>
            {
                readValues.Remove(entry.Data);
                return Task.FromResult(0);
            });

            await otherBackplane.Publish("T1", "B");
            await fakeSchedule.TriggerQuery();
            CollectionAssert.Contains(readValues, "B");

            await otherBackplane.Revoke("T1");
            await fakeSchedule.TriggerQuery();
            CollectionAssert.DoesNotContain(readValues, "B");
            subscription.Unsubscribe();
        }
開發者ID:SzymonPobiega,項目名稱:NServiceBus.DataBackplane,代碼行數:29,代碼來源:DataBackplaneClientTests.cs

示例12: GalleriesEditComplexTest

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

            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:MichaelAzar,項目名稱:flickr-net,代碼行數:59,代碼來源:GalleriesTests.cs

示例13: Remove_with_predicate_empty_list

        public void Remove_with_predicate_empty_list()
        {
            List<int> list = new List<int>();

            list.Remove(i => false);

            Assert.AreEqual(0, list.Count);
        }
開發者ID:muxa,項目名稱:Soyuz5.Extensions,代碼行數:8,代碼來源:CollectionExtensionsTests.cs

示例14: ConstructorGivenAnEnumerableCopiesIt

        public void ConstructorGivenAnEnumerableCopiesIt()
        {
            var list = new List<int> { 1, 2, 3 };
            var observableList = new ObservableList<int>(list.AsEnumerable()) { 4 };
            list.Remove(1);

            Assert.AreEqual(4, observableList.Count);
            Assert.AreEqual(2, list.Count);
        }
開發者ID:renangrativol,項目名稱:DamienGKit,代碼行數:9,代碼來源:ObservableListTests.cs

示例15: DropAItem

 public void DropAItem()
 {
     var weakBlade = new LongSword();
     var it = new List<IItems>();
     
     it.Remove(weakBlade);
     
     Assert.That(!it.Any(x => string.Equals("Longsword", x.Name)));
 }
開發者ID:Kursledare,項目名稱:Mookieraw,代碼行數:9,代碼來源:Inventorytest.cs


注:本文中的NUnit.Framework.List.Remove方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。