本文整理汇总了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());
}
示例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());
}
示例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 }));
}
示例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 }));
}
示例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 }));
}
示例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);
}
示例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);
}
}
示例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;
}
示例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]);
}
示例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));
}
}
示例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();
}
示例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.");
}
示例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);
}
示例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);
}
示例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)));
}