本文整理汇总了C#中NUnit.Framework.List.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# List.Contains方法的具体用法?C# List.Contains怎么用?C# List.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Framework.List
的用法示例。
在下文中一共展示了List.Contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ManyHouseCats
public async Task ManyHouseCats()
{
var tom = Literal.NewAtom();
var heathcliff = Literal.NewAtom();
var sylvester = Literal.NewAtom();
var houseCat = Literal.NewFunctor(1);
var any = Literal.NewVariable();
var knowledge = KnowledgeBase.New()
.Assert(Clause.Always(houseCat.With(tom)))
.Assert(Clause.Always(houseCat.With(heathcliff)))
.Assert(Clause.Always(houseCat.With(sylvester)));
// Get all the cats
var solver = new SimpleDispatchingSolver();
await solver.LoadFromKnowledgeBase(knowledge);
var allResults = new List<ILiteral>();
for (var result = solver.Query(houseCat.With(any)); result != null && result.Success; result = await result.Next())
{
allResults.Add(result.Bindings.GetValueForVariable(any));
}
Assert.IsTrue(allResults.Contains(tom));
Assert.IsTrue(allResults.Contains(heathcliff));
Assert.IsTrue(allResults.Contains(sylvester));
Assert.AreEqual(3, allResults.Count);
}
示例2: DefaultValues
[Ignore ("not up to date")] // X509Chain
public void DefaultValues ()
{
X509Chain chain = new X509Chain ();
chain.Build (cert);
Assert.IsTrue (chain.ChainElements.Count > 1, "#0");
ClaimSet cs = new X509CertificateClaimSet (cert);
ClaimSet ident = cs.Issuer;
X509CertificateClaimSet x509is = ident as X509CertificateClaimSet;
Assert.IsNotNull (x509is, "#0-2");
Assert.AreEqual (chain.ChainElements [1].Certificate, x509is.X509Certificate, "#0-3");
Assert.AreEqual (6, cs.Count, "#1");
Assert.AreEqual (6, ident.Issuer.Count, "#2");
Assert.IsFalse (cs.ContainsClaim (Claim.System), "#3");
List<string> d = new List<string> ();
foreach (Claim c in cs) {
if (c.ClaimType != ClaimTypes.Thumbprint)
Assert.AreEqual (Rights.PossessProperty, c.Right, "#4");
d.Add (c.ClaimType);
}
Assert.IsTrue (d.Contains (ClaimTypes.X500DistinguishedName), "#5");
Assert.IsTrue (d.Contains (ClaimTypes.Thumbprint), "#6");
Assert.IsTrue (d.Contains (ClaimTypes.Dns), "#7");
Assert.IsTrue (d.Contains (ClaimTypes.Rsa), "#8");
Assert.IsTrue (d.Contains (ClaimTypes.Name), "#9");
}
示例3: DcAwareNeverHitsRemoteDc
public void DcAwareNeverHitsRemoteDc()
{
var builder = Cluster.Builder().WithLoadBalancingPolicy(new DCAwareRoundRobinPolicy("dc1"));
//create a cluster with 2 nodes on dc1 and another 2 nodes on dc2
var clusterInfo = TestUtils.CcmSetup(2, builder, null, 2);
try
{
var session = clusterInfo.Session;
var hosts = new List<IPAddress>();
for (var i = 0; i < 50; i++)
{
var rs = session.Execute("SELECT * FROM system.schema_columnfamilies");
hosts.Add(rs.Info.QueriedHost);
}
//Only the ones in the local
Assert.True(hosts.Contains(IPAddress.Parse(IpPrefix + "1")), "Only hosts from the local DC should be queried 1");
Assert.True(hosts.Contains(IPAddress.Parse(IpPrefix + "2")), "Only hosts from the local DC should be queried 2");
Assert.False(hosts.Contains(IPAddress.Parse(IpPrefix + "3")), "Only hosts from the local DC should be queried 3");
Assert.False(hosts.Contains(IPAddress.Parse(IpPrefix + "4")), "Only hosts from the local DC should be queried 4");
}
finally
{
TestUtils.CcmRemove(clusterInfo);
}
}
示例4: TestRandomness
public void TestRandomness()
{
IPAddress[] ips = new IPAddress[4];
for (byte i = 0; i < ips.Length; ++i)
{
ips[i] = new IPAddress(new byte[] {192, 168, 0, i});
}
IEndpointStrategy endpointStrategy = ServiceActivator<Factory>.Create<IEndpointStrategy>("Random", ips.AsEnumerable());
List<IPAddress> alls = new List<IPAddress>();
for (int i = 0; i < 10000; ++i)
{
IPAddress nextEndpoint = endpointStrategy.Pick(null);
if (! alls.Contains(nextEndpoint))
{
alls.Add(nextEndpoint);
}
}
foreach (IPAddress ip in alls)
{
Assert.IsTrue(alls.Contains(ip));
}
}
示例5: ShouldReturnCorrectWinnerCombo
public void ShouldReturnCorrectWinnerCombo()
{
var checker = new VerticalWinnerChecker();
var winningCombo = new List<DiscPosition>();
var playerDiscs = new List<DiscPosition>()
{
new DiscPosition(){ PlayerInitialLetter = 'T', X = 1, Y = 1},
new DiscPosition(){ PlayerInitialLetter = 'T', X = 1, Y = 4},
new DiscPosition(){ PlayerInitialLetter = 'T', X = 1, Y = 5},
new DiscPosition(){ PlayerInitialLetter = 'T', X = 1, Y = 6},
new DiscPosition(){ PlayerInitialLetter = 'T', X = 1, Y = 7},
new DiscPosition(){ PlayerInitialLetter = 'T', X = 1, Y = 8},
new DiscPosition(){ PlayerInitialLetter = 'T', X = 10, Y = 10}
};
var result = checker.IsWinner(playerDiscs, out winningCombo);
Assert.IsTrue(winningCombo.Contains(playerDiscs[1]));
Assert.IsTrue(winningCombo.Contains(playerDiscs[2]));
Assert.IsTrue(winningCombo.Contains(playerDiscs[3]));
Assert.IsTrue(winningCombo.Contains(playerDiscs[4]));
Assert.IsTrue(winningCombo.Contains(playerDiscs[5]));
Assert.IsTrue(winningCombo.Count == 5);
}
示例6: UserInfo_add_remove_resources
public void UserInfo_add_remove_resources() {
UserInfo userInfo = new UserInfo(1, "wicked");
int resourcesChanged = 0;
userInfo.ResourcesChanged += delegate { resourcesChanged++; };
userInfo.AddResource(1, "0");
Assert.AreEqual(1, resourcesChanged);
Assert.AreEqual(1, userInfo.Resources.Length);
Assert.AreEqual(1, userInfo.Resources[0].Item1);
userInfo.AddResource(2, "0");
userInfo.AddResource(3, "0");
userInfo.AddResource(4, "0");
Assert.AreEqual(4, resourcesChanged);
Assert.AreEqual(4, userInfo.Resources.Length);
List<uint> resources = new List<uint>();
foreach(Tuplet<uint, string> tuple in userInfo.Resources) {
resources.Add(tuple.Item1);
}
Assert.IsTrue(resources.Contains(2));
userInfo.RemoveResource(2);
Assert.AreEqual(5, resourcesChanged);
Assert.AreEqual(3, userInfo.Resources.Length);
resources.Clear();
foreach(Tuplet<uint, string> tuple in userInfo.Resources) {
resources.Add(tuple.Item1);
}
Assert.IsFalse(resources.Contains(2));
}
示例7: FindAmicableNumbersUnderTenThousand
public void FindAmicableNumbersUnderTenThousand()
{
const long limit = 10000;
var list = new List<long>();
for (long l = 1; l < limit; ++l)
{
if (list.Contains(l)) continue;
var amicable = GetAmicablePair(l);
if (amicable != 0 && amicable < limit)
{
list.Add(l);
if (!list.Contains(amicable)) list.Add(amicable);
}
}
foreach (var l in list)
{
Console.WriteLine(l);
}
var result = list.Sum();
Console.WriteLine("Sum of amicable numbers is: {0}", result);
result.Should().Be(31626);
}
示例8: SqliteInitializationTest
public void SqliteInitializationTest()
{
string dbPath = Path.Combine(PCLStorage.FileSystem.Current.LocalStorage.Path, DB_FILE_NAME);
using (SQLiteLocalStorage storage = new SQLiteLocalStorage())
{ }
using (SQLiteConnection connection = new SQLiteConnection(dbPath))
{
var query = "SELECT name FROM sqlite_master WHERE type='table'";
var tableName = new List<string>();
using (var sqliteStatement = connection.Prepare(query))
{
while(sqliteStatement.Step() == SQLiteResult.ROW)
{
tableName.Add(sqliteStatement.GetText(0));
}
}
Assert.IsTrue(tableName.Count == 2);
Assert.IsTrue(tableName.Contains("datasets"));
Assert.IsTrue(tableName.Contains("records"));
}
}
示例9: States
public static void States(Accessible accessible, params StateType [] expected)
{
List <StateType> expectedStates = new List <StateType> (expected);
List <StateType> missingStates = new List <StateType> ();
List <StateType> superfluousStates = new List <StateType> ();
StateSet stateSet = accessible.StateSet;
foreach (StateType state in Enum.GetValues (typeof (StateType))) {
if (expectedStates.Contains (state) &&
(!(stateSet.Contains (state))))
missingStates.Add (state);
else if ((!expectedStates.Contains (state)) &&
(stateSet.Contains (state)))
superfluousStates.Add (state);
}
string missingStatesMsg = string.Empty;
string superfluousStatesMsg = string.Empty;
if (missingStates.Count != 0) {
missingStatesMsg = "Missing states: ";
foreach (StateType state in missingStates)
missingStatesMsg += state.ToString () + ",";
}
if (superfluousStates.Count != 0) {
superfluousStatesMsg = "Superfluous states: ";
foreach (StateType state in superfluousStates)
superfluousStatesMsg += state.ToString () + ",";
}
Assert.IsTrue ((missingStates.Count == 0) && (superfluousStates.Count == 0),
missingStatesMsg + " .. " + superfluousStatesMsg);
}
示例10: TestGetAll
public void TestGetAll()
{
List<TestObj> testObjs = new List<TestObj>();
for (int i = 0; i < 10; i++)
{
testObjs.Add(new TestObj(i.ToString(), i));
}
var records = database.SaveAll(testObjs);
foreach (var record in records)
{
Assert.IsTrue(testObjs.Contains(record.Value), "IObjectDatabase.SaveAll failed");
}
records = database.GetAll<TestObj>();
foreach (var record in records)
{
Assert.IsTrue(testObjs.Contains(record.Value), "IObjectDatabase.GetAll failed to return an object from memory");
}
database.Dispose();
database = new SQLiteObjectDatabase(databaseFile);
var newRecords = database.GetAll<TestObj>();
foreach (var record in records)
{
Assert.IsTrue(records.FirstOrDefault(i => newRecords.Select(g => g.UniqueId).Contains(i.UniqueId)) != null, "IObjectDatabase.GetAll failed to return an object from storage");
}
}
示例11: GetLargestGroups
public void GetLargestGroups()
{
var d = new Dictionary<string, int>();
for (int i = 0; i < _strings.Length; i++)
{
int old;
d.TryGetValue(_strings[i], out old);
d[_strings[i]] = old + _values[i];
}
for (int i = 0; i < _strings.Length; i++)
{
Assert.AreEqual(_values[i], d[_strings[i]]);
}
var largest = new List<KeyValuePair<string, int>> {new KeyValuePair<string, int>("None", 0)};
int max = 0;
// Iterate and find maximum values.
foreach (var kvp in d)
{
if (kvp.Value > max)
{
largest.Clear();
max = kvp.Value;
}
if (kvp.Value == max)
largest.Add(kvp);
}
Assert.AreEqual(2, largest.Count);
Assert.IsTrue(largest.Contains(new KeyValuePair<string, int>("b", 42)));
Assert.IsTrue(largest.Contains(new KeyValuePair<string, int>("d", 42)));
}
示例12: ShouldReturnCorrectWinnerCombo
public void ShouldReturnCorrectWinnerCombo()
{
var checker = new RightToLeftDiagonalChecker();
var winningCombo = new List<DiscPosition>();
var playerDiscs = new List<DiscPosition>
{
new DiscPosition(){ PlayerInitialLetter = 'T', X = 4, Y = 2},
new DiscPosition(){ PlayerInitialLetter = 'T', X = 8, Y = 10},
new DiscPosition(){ PlayerInitialLetter = 'T', X = 9, Y = 9},
new DiscPosition(){ PlayerInitialLetter = 'T', X = 10, Y = 8},
new DiscPosition(){ PlayerInitialLetter = 'T', X = 11, Y = 7},
new DiscPosition(){ PlayerInitialLetter = 'T', X = 12, Y = 6},
new DiscPosition(){ PlayerInitialLetter = 'T', X = 15, Y = 15}
};
var result = checker.IsWinner(playerDiscs, out winningCombo);
Assert.IsTrue(winningCombo.Contains(playerDiscs[1]));
Assert.IsTrue(winningCombo.Contains(playerDiscs[2]));
Assert.IsTrue(winningCombo.Contains(playerDiscs[3]));
Assert.IsTrue(winningCombo.Contains(playerDiscs[4]));
Assert.IsTrue(winningCombo.Contains(playerDiscs[5]));
Assert.IsTrue(winningCombo.Count == 5);
}
示例13: Simple
public void Simple()
{
var hashList = new HashList<int, string> {{2, "a"}};
Assert.AreEqual(hashList.ValueCount, 1);
Assert.AreEqual(hashList.KeyCount, 1);
hashList.Add(4, new List<string>(new[] { "2", "3", "4", "5" }));
Assert.AreEqual(hashList.ValueCount, 5);
Assert.AreEqual(hashList.KeyCount, 2);
var enumerator = hashList.GetValueEnumerator();
var list = new List<string>();
while (enumerator.MoveNext())
{
list.Add(enumerator.Current);
}
Assert.AreEqual(list.Count, 5);
Assert.IsTrue(list.Contains("a"));
Assert.IsTrue(list.Contains("2"));
Assert.IsTrue(list.Contains("3"));
Assert.IsTrue(list.Contains("4"));
Assert.IsTrue(list.Contains("5"));
}
示例14: MaxSize
public void MaxSize()
{
IKernel kernel = new DefaultKernel();
kernel.Register(Component.For(typeof(PoolableComponent1)).Named("a"));
var instances = new List<PoolableComponent1>
{
kernel.Resolve<PoolableComponent1>("a"),
kernel.Resolve<PoolableComponent1>("a"),
kernel.Resolve<PoolableComponent1>("a"),
kernel.Resolve<PoolableComponent1>("a"),
kernel.Resolve<PoolableComponent1>("a")
};
PoolableComponent1 other1 = kernel.Resolve<PoolableComponent1>("a");
Assert.IsNotNull(other1);
Assert.IsTrue(!instances.Contains(other1));
foreach (PoolableComponent1 inst in instances)
{
kernel.ReleaseComponent(inst);
}
kernel.ReleaseComponent(other1);
PoolableComponent1 other2 = kernel.Resolve<PoolableComponent1>("a");
Assert.IsNotNull(other2);
Assert.IsTrue(other1 != other2);
Assert.IsTrue(instances.Contains(other2));
kernel.ReleaseComponent(other2);
}
示例15: Contains_WithPredicate
public void Contains_WithPredicate()
{
var testList = new List<string> { "One", "Two", "Three" };
Assert.That(testList.Contains(s => s.StartsWith("T")), Is.True);
Assert.That(testList.Contains(s => s.StartsWith("Z")), Is.False);
}