本文整理汇总了C#中NUnit.Framework.List.Exists方法的典型用法代码示例。如果您正苦于以下问题:C# List.Exists方法的具体用法?C# List.Exists怎么用?C# List.Exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Framework.List
的用法示例。
在下文中一共展示了List.Exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add
public void Add()
{
var criteria = new List<IIterationStopCriterium>
{
new FailureStopCriterium(),
new DivergenceStopCriterium(),
new IterationCountStopCriterium(),
new ResidualStopCriterium()
};
var iterator = new Iterator();
Assert.AreEqual(0, iterator.NumberOfCriteria, "Incorrect criterium count");
foreach (var criterium in criteria)
{
iterator.Add(criterium);
Assert.IsTrue(iterator.Contains(criterium), "Missing criterium");
}
// Check that we have all the criteria
Assert.AreEqual(criteria.Count, iterator.NumberOfCriteria, "Incorrect criterium count");
var enumerator = iterator.StoredStopCriteria;
while (enumerator.MoveNext())
{
var criterium = enumerator.Current;
Assert.IsTrue(criteria.Exists(c => ReferenceEquals(c, criterium)), "Criterium missing");
}
}
示例2: AfterAPostIsAdded_ItsTagsShouldBeRetrievable
public void AfterAPostIsAdded_ItsTagsShouldBeRetrievable()
{
var post = GetTestPost();
Metaweblog.AddPost(string.Empty, string.Empty, string.Empty, post, true);
var tags = new List<CategoryInfo>(Metaweblog.GetCategories(string.Empty, string.Empty, string.Empty));
foreach (string c in post.categories)
{
Assert.IsTrue(tags.Exists(t => t.title == c));
}
}
示例3: Deal_FromStart_All52CardsDifferent
public void Deal_FromStart_All52CardsDifferent()
{
Deck deck = new Deck();
List<Card> cards = new List<Card>();
for (int i = 0; i < 52; i++)
{
Card next = deck.Deal();
Assert.IsFalse(cards.Exists(c => next == c));
cards.Add(next);
}
}
示例4: CheckRelationshipData
public void CheckRelationshipData ()
{
AddThreeRelationShips ();
PackagePart part = package.GetPart (new Uri ("/_rels/.rels", UriKind.Relative));
Assert.IsNotNull (package.GetPart (new Uri ("/_RELS/.RELS", UriKind.Relative)), "#0");
package.Flush ();
Assert.IsNotNull (part, "#1");
Stream stream = part.GetStream ();
Assert.IsTrue (stream.Length > 0, "#2a");
XmlDocument doc = new XmlDocument ();
XmlNamespaceManager manager = new XmlNamespaceManager (doc.NameTable);
manager.AddNamespace("rel", "http://schemas.openxmlformats.org/package/2006/relationships");
doc.Load (new StreamReader (stream));
Assert.IsNotNull (doc.SelectSingleNode ("/rel:Relationships", manager), "#2b");
XmlNodeList list = doc.SelectNodes ("/rel:Relationships/*", manager);
Assert.AreEqual (3, list.Count);
List<PackageRelationship> relationships = new List<PackageRelationship>(package.GetRelationships ());
foreach (XmlNode node in list) {
Assert.AreEqual (3, node.Attributes.Count, "#3");
Assert.IsNotNull (node.Attributes ["Id"], "#4");
Assert.IsNotNull (node.Attributes ["Target"], "#5");
Assert.IsNotNull (node.Attributes ["Type"], "#6");
Assert.IsTrue(relationships.Exists(d => d.Id == node.Attributes["Id"].InnerText &&
d.TargetUri == new Uri (node.Attributes["Target"].InnerText, UriKind.Relative) &&
d.RelationshipType == node.Attributes["Type"].InnerText));
}
}
示例5: GetNotificationMessagesValidBusinessIsSuccessful
public void GetNotificationMessagesValidBusinessIsSuccessful()
{
// Arrange
var notificationManagerMock = MockRepository.GenerateMock<INotificationManager>();
PropertyManagementSystemService.NotificationManager = notificationManagerMock;
//Make sure business is present
CacheHelper.StubBusinessCacheSingleBusiness(BUSINESS_ID);
// invalidate the cache so we make sure our business is loaded into the cache
Cache.Business.Invalidate();
var stubMessages = new List<Message>
{
MessageBuilder.BuildSimple(),
MessageBuilder.BuildSimple(messageId: 2),
MessageBuilder.BuildSimple(messageId: 3,
messageStatusEnum: MessageStatusEnum.Read)
};
notificationManagerMock.Expect(manager => manager.GetNotificationMessages(BUSINESS_ID))
.Return(stubMessages);
// Act
List<MessageDto> messagesFound = PropertyManagementSystemService.GetNotificationMessages(BUSINESS_ID);
// Assert
notificationManagerMock.VerifyAllExpectations();
Assert.AreEqual(stubMessages.Count, messagesFound.Count, "Number of messages returned wasn't correct");
Assert.IsTrue(stubMessages.Exists(msg => msg.Id == 2) && messagesFound.Exists(msg => msg.Id == 2),
"Message with Id was not returned correctly");
CacheHelper.ReAssignBusinessDaoToBusinessCache();
}
示例6: TestReturnedPeers
public void TestReturnedPeers()
{
rig.Tracker.AllowNonCompact = true;
rig.Tracker.Add(rig.Trackables[0]);
List<PeerDetails> peers = new List<PeerDetails>();
for (int i = 0; i < 25; i++)
peers.Add(rig.Peers[i]);
for (int i = 0; i < peers.Count; i++)
rig.Listener.Handle(peers[i], rig.Trackables[0]);
BEncodedDictionary dict = (BEncodedDictionary)rig.Listener.Handle(rig.Peers[24], rig.Trackables[0]);
BEncodedList list = (BEncodedList)dict["peers"];
Assert.AreEqual(25, list.Count, "#1");
foreach (BEncodedDictionary d in list)
{
IPAddress up = IPAddress.Parse(d["ip"].ToString());
int port = (int)((BEncodedNumber)d["port"]).Number;
string peerId = ((BEncodedString)d["peer id"]).Text;
Assert.IsTrue(peers.Exists(delegate(PeerDetails pd) {
return pd.ClientAddress.Equals(up) && pd.Port == port && pd.PeerId == peerId;
}), "#2");
}
}
示例7: story_log_is_observed_during_invocation
public void story_log_is_observed_during_invocation()
{
var log = new List<KeyValuePair<LogSeverity, string>>
{
new KeyValuePair<LogSeverity, string>( LogSeverity.Info, "test_info"),
new KeyValuePair<LogSeverity, string>( LogSeverity.Warning, "test_warning"),
new KeyValuePair<LogSeverity, string>( LogSeverity.Error, "test_error"),
};
var handlerRules = new Ruleset<IStory, IStoryHandler>()
{
Rules = {
new PredicateRule(
_ => true, // always run for story
_ => new ActionHandler(
(story) => Assert.AreEqual(0, story.Log.Count()), // make sure OnStart() is invoked with zero log items.
(story, task) => Assert.IsTrue(story.Log.All(
entry => log.Exists(
l => l.Key == entry.Severity &&
l.Value == entry.Text))))
),
},
};
new Story("testStory", handlerRules).Run(story =>
{
foreach (var kvp in log)
{
story.Log.Add(kvp.Key, kvp.Value);
}
});
}
示例8: contains
private void contains(List<HistoryItem> items, HistoryItem item)
{
Assert.That(items.Exists(h => h.Id == item.Id));
}
示例9: Clone
public void Clone()
{
var criteria = new List<IIterationStopCriterium>
{
new FailureStopCriterium(),
new DivergenceStopCriterium(),
new IterationCountStopCriterium(),
new ResidualStopCriterium()
};
var iterator = new Iterator(criteria);
var clonedIterator = iterator.Clone();
Assert.IsInstanceOf(typeof (Iterator), clonedIterator, "Incorrect type");
var clone = clonedIterator as Iterator;
Assert.IsNotNull(clone);
// ReSharper disable PossibleNullReferenceException
Assert.AreEqual(iterator.NumberOfCriteria, clone.NumberOfCriteria, "Incorrect criterium count");
// ReSharper restore PossibleNullReferenceException
foreach (var criterium in clone.StoredStopCriteria)
{
Assert.IsTrue(criteria.Exists(c => c.GetType() == criterium.GetType()), "Criterium missing");
}
}
示例10: SearchTest
public void SearchTest()
{
DynamicRTree<int> rTree = new DynamicRTree<int>(new GuttmanQuadraticInsert<int>(),
new GuttmanQuadraticSplit<int>(), new DynamicRTreeBalanceHeuristic());
addEntries(rTree);
List<RTreeIndexEntry<int>> resultsList = new List<RTreeIndexEntry<int>>();
resultsList.AddRange(rTree.Search(new BoundingBox(-100, -100, 5928.57523425, 3252.50803582)));
Assert.AreEqual(8, resultsList.Count);
resultsList.Clear();
resultsList.AddRange(rTree.Search(new BoundingBox(0, 0, 100, 100)));
Assert.AreEqual(6, resultsList.Count);
Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 1; }));
Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 2; }));
Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 3; }));
Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 6; }));
Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 7; }));
Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 8; }));
resultsList.Clear();
resultsList.AddRange(rTree.Search(new BoundingBox(1500, 1500, 1500, 1500)));
Assert.AreEqual(2, resultsList.Count);
Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 4; }));
Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 5; }));
resultsList.Clear();
resultsList.AddRange(rTree.Search(new BoundingBox(100, 100, 100, 100)));
Assert.AreEqual(4, resultsList.Count);
Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 1; }));
Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 2; }));
Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 7; }));
Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 8; }));
resultsList.Clear();
addRandomEntries(rTree);
resultsList.AddRange(rTree.Search(new BoundingBox(100, 100, 100, 100)));
Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 1; }));
Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 2; }));
Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 7; }));
Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 8; }));
resultsList.Clear();
rTree.Dispose();
}
示例11: AssertPhrasesEqual
private void AssertPhrasesEqual(List<List<string>> expected, List<List<string>> actual)
{
foreach (var phrase in expected)
{
Assert.IsTrue(actual.Exists(x => AreEquivalent(phrase, x)));
}
}
示例12: Main
private static int Main(string[] args)
{
AppArguments parsedArgs = new AppArguments();
if (!Parser.ParseArgumentsWithUsage(args, parsedArgs))
{
return 1;
}
List<string> referencedAssemblies = new List<string>(parsedArgs.ReferencedAssemblies);
if (
!referencedAssemblies.Exists(
delegate(string asm) { return asm.Contains("ProtocolGenerator.exe"); }))
{
referencedAssemblies.Add("ProtocolGenerator.exe");
}
Assembly templateAssembly;
if (!CompileLibraryInMemory(parsedArgs.EventTemplatePath, referencedAssemblies.ToArray(), out templateAssembly))
{
Console.WriteLine("ERROR: TemplateFile compile error.");
return 2;
}
uint minorVersion = GetMinorVersion(parsedArgs.EventTemplatePath);
IGenerator rootGenerator;
try
{
// TODO - Ctor throws exception. Is it OK?
rootGenerator = new RootGenerator(templateAssembly.GetTypes(), minorVersion);
}
catch (SyntaxErrorException e)
{
Console.WriteLine(e);
return 3;
}
string generatedFilePath = GetGeneratedFilePath(parsedArgs.EventTemplatePath);
using (StreamWriter sw = File.CreateText(generatedFilePath))
{
rootGenerator.Write(new CodeWriter(sw));
}
return 0;
}
示例13: TestBoxF2DLineEnumeration
public void TestBoxF2DLineEnumeration()
{
var rect1 = new BoxF2D(0, 0, 2, 2);
List<LineF2D> lines = new List<LineF2D>(rect1 as IEnumerable<LineF2D>);
Assert.AreEqual(4, lines.Count);
Assert.IsTrue(lines[0].IsSegment);
Assert.IsTrue(lines[1].IsSegment);
Assert.IsTrue(lines[2].IsSegment);
Assert.IsTrue(lines[3].IsSegment);
Assert.IsTrue(lines.Exists(x => (x.Point1 == rect1.Corners[0] && x.Point2 == rect1.Corners[1]) ||
(x.Point2 == rect1.Corners[0] && x.Point1 == rect1.Corners[1])));
Assert.IsTrue(lines.Exists(x => (x.Point1 == rect1.Corners[1] && x.Point2 == rect1.Corners[2]) ||
(x.Point2 == rect1.Corners[2] && x.Point1 == rect1.Corners[1])));
Assert.IsTrue(lines.Exists(x => (x.Point1 == rect1.Corners[2] && x.Point2 == rect1.Corners[3]) ||
(x.Point2 == rect1.Corners[3] && x.Point1 == rect1.Corners[2])));
Assert.IsTrue(lines.Exists(x => (x.Point1 == rect1.Corners[3] && x.Point2 == rect1.Corners[0]) ||
(x.Point2 == rect1.Corners[0] && x.Point1 == rect1.Corners[3])));
}
示例14: CleanUpFoldersOrig
private static void CleanUpFoldersOrig(List<string> uniqueFolders)
{
uniqueFolders.RemoveAll(
delegate(string curFolder)
{
// remove empty
if (string.IsNullOrEmpty(curFolder))
{
return true;
}
// remove sub paths
if (uniqueFolders.Exists(
delegate(string s)
{
if (!string.IsNullOrEmpty(s) &&
curFolder.StartsWith(s) &&
string.Compare(s, curFolder) != 0)
{
return true;
}
return false;
}))
{
return true;
}
return false;
}
);
}
示例15: VerifyAttachments
void VerifyAttachments(List<Attachment> before, List<Attachment> after)
{
Assert.AreEqual(before.Count, after.Count);
foreach (Attachment x in before)
{
Assert.IsTrue(after.Exists(delegate(Attachment inAfter)
{
return inAfter.Id == x.Id &&
inAfter.Name == x.Name &&
inAfter.Content.Length == x.Content.Length &&
!string.IsNullOrEmpty(inAfter.Id);
}),
"Attachment name {0} and id {1} doesnt exist in modified list", x.Name, x.Id);
}
}