本文整理汇总了C#中NUnit.Framework.List.RemoveAll方法的典型用法代码示例。如果您正苦于以下问题:C# List.RemoveAll方法的具体用法?C# List.RemoveAll怎么用?C# List.RemoveAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Framework.List
的用法示例。
在下文中一共展示了List.RemoveAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PickRemaining
public void PickRemaining()
{
other.BitField.SetAll(true);
other.IsChoking = false;
List<Block> allBlocks = new List<Block>();
pieces.ForEach(delegate(Piece p) { allBlocks.AddRange(p.Blocks); });
allBlocks.RemoveAll(delegate(Block b){ return alreadyGot.Contains(b);});
RequestMessage m;
while ((m = picker.PickPiece(other, new List<PeerId>())) != null)
{
if(alreadyGot.Exists(delegate(Block b){
return b.PieceIndex == m.PieceIndex &&
b.StartOffset == m.StartOffset &&
b.RequestLength == m.RequestLength;}))
{
Assert.AreEqual(0, allBlocks.Count, "#1");
break;
}
int ret = allBlocks.RemoveAll(delegate (Block b) {
return b.PieceIndex == m.PieceIndex &&
b.StartOffset == m.StartOffset &&
b.RequestLength == m.RequestLength;
});
Assert.AreEqual(1, ret, "#2");
}
}
示例2: CalculatePopulateWithHiddenObject
/// <summary>
/// Calculates the nodes that should be visible in the main window tree view when the specified xen object is hidden.
/// </summary>
/// <param name="hiddenObject">The hidden object.</param>
private ComparableList<IXenObject> CalculatePopulateWithHiddenObject(IXenObject hiddenObject)
{
VirtualTreeNode rootNode = MW(() => new MainWindowTreeBuilder(new FlickerFreeTreeView()).CreateNewRootNode(new NavigationPane().Search, NavigationPane.NavigationMode.Infrastructure));
List<VirtualTreeNode> nodes = new List<VirtualTreeNode>(rootNode.Descendants);
nodes.RemoveAll(n => hiddenObject.Equals(n.Tag));
nodes.RemoveAll(n => new List<VirtualTreeNode>(n.Ancestors).Find(nn => hiddenObject.Equals(nn.Tag)) != null);
return new ComparableList<IXenObject>(nodes.ConvertAll(n => (IXenObject)n.Tag));
}
示例3: RemoveAll
public void RemoveAll()
{
ICollection<int> col = new List<int> { 1, 2, 3, 4, 5 };
col.RemoveAll(x => x % 2 == 0);
Assert.IsTrue(col.SequenceEqual(new [] { 1, 3, 5 }));
}
示例4: AttributeStatement_Element
public void AttributeStatement_Element()
{
Predicate<StatementAbstract> findAttributeStatement =
delegate(StatementAbstract stmnt) { return stmnt is AttributeStatement; };
Assertion saml20Assertion = AssertionUtil.GetBasicAssertion();
AttributeStatement attributeStatement =
(AttributeStatement) Array.Find(saml20Assertion.Items, findAttributeStatement);
// Add an encrypted attribute.
EncryptedElement encAtt = new EncryptedElement();
encAtt.encryptedData = new EncryptedData();
encAtt.encryptedData.CipherData = new CipherData();
encAtt.encryptedData.CipherData.Item = string.Empty;
encAtt.encryptedKey = new EncryptedKey[0];
attributeStatement.Items = new object[] { encAtt };
TestAssertion(saml20Assertion, "The DK-SAML 2.0 profile does not allow encrypted attributes.");
// Add an attribute with the wrong nameformat.
// Attribute att = DKSaml20EmailAttribute.create("[email protected]");
// att.NameFormat = "http://example.com";
// attributeStatement.Items = new object[] { att };
// testAssertion(saml20Assertion, "The DK-SAML 2.0 profile requires that an attribute's \"NameFormat\" element is urn:oasis:names:tc:SAML:2.0:attrname-format:uri.");
// Clear all the attributes.
attributeStatement.Items = new object[0];
TestAssertion(saml20Assertion, "AttributeStatement MUST contain at least one Attribute or EncryptedAttribute");
// Remove it.
saml20Assertion = AssertionUtil.GetBasicAssertion();
List<StatementAbstract> statements = new List<StatementAbstract>(saml20Assertion.Items);
statements.RemoveAll(findAttributeStatement);
saml20Assertion.Items = statements.ToArray();
TestAssertion(saml20Assertion, "The DK-SAML 2.0 profile requires exactly one \"AuthnStatement\" element and one \"AttributeStatement\" element.");
}
示例5: ShowLogosAndWait
public void ShowLogosAndWait()
{
var screen = Resolve<ScreenSpace>();
var factory = new LogoFactory(screen);
var logos = new List<Logo>();
var n = 10; // randomizer.Get(10, 100);
for (int i = 0; i < n; i++)
{
var logo = factory.Create();
if (logo != null)
logos.Add(logo);
}
Assert.IsTrue(logos.Count == n);
if (!IsMockResolver)
return;
while (GlobalTime.Current.Milliseconds < 10000)
{
var mouse = Resolve<MockMouse>();
mouse.SetButtonState(MouseButton.Left, State.Releasing);
AdvanceTimeAndUpdateEntities(1);
if (Time.CheckEvery(1))
{
Resolve<Window>().Title = "Logo count: " + logos.Count;
logos.RemoveAll(x => x.IsOutside(screen.Viewport));
}
}
Assert.IsTrue(logos.Count == 0);
}
示例6: RemoveAll_List_NotFound
public void RemoveAll_List_NotFound()
{
IList<int> list = new List<int> { 1, 3 };
Assert.IsFalse (list.RemoveAll (i => i == 2));
Assert.AreEqual (2, list.Count);
}
示例7: RemoveAll_MultipleList
public void RemoveAll_MultipleList()
{
IList<int> list = new List<int> { 1, 2, 3, 4, 1, 2, 5 };
list.RemoveAll (i => i == 2);
Assert.AreEqual (5, list.Count);
Assert.IsFalse (list.Contains (2), "List still contains removed items");
}
示例8: remove_all
public void remove_all()
{
var list = new List<string> { "a", "c", "b" };
list.ShouldHaveCount(3);
Func<string, bool> whereEvaluator = item => item.CompareTo("c") < 0;
list.RemoveAll(whereEvaluator);
list.ShouldHaveCount(1).ShouldContain("c");
}
示例9: RemoveAll
public void RemoveAll()
{
IList<int> iList = new List<int> { 3, 3, 3, 3 };
var iListRemovedCount = iList.RemoveAll(Match3);
Assert.AreEqual(4, iListRemovedCount);
Assert.AreEqual(0, iList.Count);
}
示例10: RemoveFirst
public void RemoveFirst()
{
IList<int> iList = new List<int> { 3, 2, 4, 2 };
var iListRemovedCount = iList.RemoveAll(Match3);
Assert.AreEqual(1, iListRemovedCount);
EnsureListsAreTheSame(new List<int> { 2, 4, 2 }, iList);
}
示例11: RemoveMultiple
public void RemoveMultiple()
{
IList<int> iList = new List<int> { 1, 2, 3, 4, 3 };
var iListRemovedCount = iList.RemoveAll(Match3);
Assert.AreEqual(2, iListRemovedCount);
EnsureListsAreTheSame(new List<int> { 1, 2, 4 }, iList);
}
示例12: RemoveNone
public void RemoveNone()
{
IList<int> iList = new List<int> { 1, 1, 1, 1 };
var iListRemovedCount = iList.RemoveAll(Match3);
Assert.AreEqual(0, iListRemovedCount);
EnsureListsAreTheSame(new List<int> { 1, 1, 1, 1 }, iList);
}
示例13: RemoveAll
public void RemoveAll()
{
var list = new List<string>
{
"a1", "z1", "a2", "z2", "a3", "z3"
};
list.RemoveAll(x => x.StartsWith("a"));
Assert.AreEqual(3, list.Count);
Assert.IsTrue(list.TrueForAll(x => x.StartsWith("z")));
}
示例14: NUGetProductListTestFailure
public void NUGetProductListTestFailure()
{
//Arrange
List<Products> productList = new List<Products>();
//Act
productList = Products.getGenericProductList(true);
productList.RemoveAll(null);
//Assert
Assert.AreNotEqual(0, productList.Count);
}
示例15: ShouldSomethingWithLambdasssss
public void ShouldSomethingWithLambdasssss()
{
//User user = new User(new UserPrinciple());
//System.Console.WriteLine( (User user) => user.EmailAddress.Length > 0 );
List<string> strings = new List<string>();
strings.Add("fuck you microsoft");
strings.Add("fuck again");
strings.RemoveAll((string s) => s.Contains("again"));
Console.WriteLine(strings.Count);
}