本文整理汇总了C#中Microsoft.VisualStudio.TestTools.UnitTesting.List.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# List.Contains方法的具体用法?C# List.Contains怎么用?C# List.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudio.TestTools.UnitTesting.List
的用法示例。
在下文中一共展示了List.Contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CollectionPropertyDependencyTest
public void CollectionPropertyDependencyTest()
{
List<string> property_notifications = new List<string>();
Model m = new Model();
m.Items.Add(new Item() { Prop = 42 });
m.Items.Add(new Item() { Prop = 23 });
m.Items.Add(new Item() { Prop = 17 });
ViewModel vm = new ViewModel(m);
m.PropertyChanged += (sender, args) => property_notifications.Add("Model:" + args.PropertyName);
vm.PropertyChanged += (sender, args) => property_notifications.Add("ViewModel:" + args.PropertyName);
var item = new Item() { Prop = 1 };
item.PropertyChanged += (sender, args) => property_notifications.Add("Item:" + args.PropertyName);
m.Items.Add(item);
Assert.AreEqual(1, property_notifications.Count);
Assert.IsTrue(property_notifications.Contains("ViewModel:Items"));
property_notifications.Clear();
item.Prop = 42;
Assert.AreEqual(3, property_notifications.Count);
Assert.IsTrue(property_notifications.Contains("Item:Prop"));
Assert.IsTrue(property_notifications.Contains("ViewModel:Items")); // Called by Item.Prop changed
Assert.IsTrue(property_notifications.Contains("ViewModel:Items")); // Called by ItemViewModel.PropSquared
property_notifications.Clear();
m.Items.Remove(item);
Assert.AreEqual(1, property_notifications.Count);
Assert.IsTrue(property_notifications.Contains("ViewModel:Items"));
}
示例2: MultipleModelsDependenciesTest
public void MultipleModelsDependenciesTest()
{
List<string> property_notifications = new List<string>();
ModelA ma = new ModelA() { PropA = 1 };
ModelB mb = new ModelB() { PropB = 2 };
ViewModel vm = new ViewModel(ma, mb);
int current_total;
ma.PropertyChanged += (sender, args) => property_notifications.Add("ModelA:" + args.PropertyName);
mb.PropertyChanged += (sender, args) => property_notifications.Add("ModelB:" + args.PropertyName);
vm.PropertyChanged += (sender, args) => property_notifications.Add("ViewModel:" + args.PropertyName);
ma.PropA = 2;
Assert.AreEqual(2, property_notifications.Count);
Assert.IsTrue(property_notifications.Contains("ModelA:PropA"));
Assert.IsTrue(property_notifications.Contains("ViewModel:Total"));
property_notifications.Clear();
mb.PropB = 40;
Assert.AreEqual(2, property_notifications.Count);
Assert.IsTrue(property_notifications.Contains("ModelB:PropB"));
Assert.IsTrue(property_notifications.Contains("ViewModel:Total"));
var total_property = TypeDescriptor.GetProperties(vm)["Total"];
var total = total_property.GetValue(vm);
Assert.AreEqual(42, total);
}
示例3: EqualsOneTest
public void EqualsOneTest()
{
var res = new List<OnePrimary>
{
new OnePrimary
{
Id = 1,
Name = "awdwd"
},
new OnePrimary
{
Id = 2,
Name = "aegaga"
}
};
var contains = new OnePrimary
{
Id = 1,
Name = "akljegselgj",
};
var notContains = new OnePrimary
{
Id = 120,
Name = "aegaga"
};
Assert.IsTrue(res.Contains(contains, new MapperComparer<OnePrimary>()));
Assert.IsFalse(res.Contains(notContains, new MapperComparer<OnePrimary>()));
}
示例4: TestApiKeyQueryAll
public void TestApiKeyQueryAll()
{
ApiKey key = new ApiKey();
key.Save();
Balanced.Balanced.configure(key.secret);
Marketplace marketplace = new Marketplace();
marketplace.Save();
ApiKey key1 = new ApiKey();
key1.SaveToMarketplace();
ApiKey key2 = new ApiKey();
key2.SaveToMarketplace();
ApiKey key3 = new ApiKey();
key3.SaveToMarketplace();
List<ApiKey> keys = ApiKey.Query().All();
Assert.AreEqual(4, keys.Count);
List<String> key_guids = new List<String>();
foreach (ApiKey k in keys) {
key_guids.Add(k.id);
}
Assert.IsTrue(key_guids.Contains(key1.id));
Assert.IsTrue(key_guids.Contains(key2.id));
Assert.IsTrue(key_guids.Contains(key3.id));
}
示例5: ExternalCollectionDependencyTest
public void ExternalCollectionDependencyTest()
{
var changed_properties = new List<string>();
var base_obj = new ExternalCollectionDependencyBaseObject();
var obj = new ExternalCollectionDependencyObject(base_obj);
obj.PropertyChanged += (sender, args) => changed_properties.Add(args.PropertyName);
base_obj.BaseProp1.Add(42);
Assert.AreEqual(1, changed_properties.Count, "1 property changed event expected");
Assert.IsTrue(changed_properties.Contains("Prop1"), "Prop1 property changed event expected");
changed_properties.Clear();
base_obj = new ExternalCollectionDependencyBaseObject();
obj.BaseObject = base_obj;
base_obj.BaseProp1.Add(42);
Assert.AreEqual(2, changed_properties.Count, "2 property changed events expected");
Assert.IsTrue(changed_properties.Contains("BaseObject"), "BaseObject property changed event expected");
Assert.IsTrue(changed_properties.Contains("Prop1"), "Prop1 property changed event expected");
changed_properties.Clear();
base_obj.BaseProp1 = new ObservableCollection<int>();
base_obj.BaseProp1.Add(42);
Assert.AreEqual(1, changed_properties.Count, "1 property changed event expected");
Assert.IsTrue(changed_properties.Contains("Prop1"), "Prop1 property changed event expected");
}
示例6: InvokeWebActionListAction
public void InvokeWebActionListAction()
{
using (var scope = new PSTestScope(true))
{
List<string> listNames = new List<string>();
Action<List> listAction = list =>
{
listNames.Add(list.Title);
};
var results = scope.ExecuteCommand("Invoke-SPOWebAction",
new CommandParameter("ListAction", listAction),
new CommandParameter("ListProperties", new[] { "Title" })
);
Assert.IsTrue(listNames.Count > 3, "Wrong count on lists");
Assert.IsTrue(listNames.Contains("PnPTestList1"), "PnPTestList1 is missing");
Assert.IsTrue(listNames.Contains("PnPTestList2"), "PnPTestList2 is missing");
Assert.IsTrue(listNames.Contains("PnPTestList3"), "PnPTestList3 is missing");
InvokeWebActionResult result = results.Last().BaseObject as InvokeWebActionResult;
AssertInvokeActionResult(result,
processedWebCount: 1
);
Assert.IsTrue(result.ProcessedListCount > 3, "Wrong count on proccessed list");
}
}
示例7: TestTemplateOneOf
public void TestTemplateOneOf()
{
Random random = new Random();
var document = new SimpleDocument("The letter is {OneOf(\"a\", \"b\", \"c\", \"d\", null)}.");
var store = new BuiltinStore();
store["OneOf"] = new NativeFunction((values) =>
{
return values[random.Next(values.Count)];
});
store["system"] = "Alrai";
List<string> results = new List<string>();
for (int i = 0; i < 1000; i++)
{
results.Add(document.Render(store));
}
Assert.IsTrue(results.Contains(@"The letter is a."));
results.RemoveAll(result => result == @"The letter is a.");
Assert.IsTrue(results.Contains(@"The letter is b."));
results.RemoveAll(result => result == @"The letter is b.");
Assert.IsTrue(results.Contains(@"The letter is c."));
results.RemoveAll(result => result == @"The letter is c.");
Assert.IsTrue(results.Contains(@"The letter is d."));
results.RemoveAll(result => result == @"The letter is d.");
Assert.IsTrue(results.Contains(@"The letter is ."));
results.RemoveAll(result => result == @"The letter is .");
Assert.IsTrue(results.Count == 0);
}
示例8: SqliteInitializationTest
public void SqliteInitializationTest()
{
using (SQLiteLocalStorage storage = new SQLiteLocalStorage())
{ }
using (SQLiteConnection connection = new SQLiteConnection(string.Format("Data Source={0};Version=3;", DB_FILE_PATH)))
{
connection.Open();
var cmd = connection.CreateCommand();
cmd.CommandText = "SELECT name FROM sqlite_master WHERE type='table'";
var reader = cmd.ExecuteReader();
var tableName = new List<string>();
while (reader.Read())
{
tableName.Add(reader.GetString(0));
}
Assert.IsTrue(tableName.Count == 3);
Assert.IsTrue(tableName.Contains("datasets"));
Assert.IsTrue(tableName.Contains("records"));
Assert.IsTrue(tableName.Contains("kvstore"));
connection.Close();
}
}
示例9: ListContainsTest
public void ListContainsTest()
{
var list = new List<char>();
list.Add('o');
Assert.IsTrue(list.Contains('o'));
Assert.IsFalse(list.Contains('l'));
}
示例10: TestGenerateBool
public void TestGenerateBool() {
var result = new List<bool>();
for( int i = 0; i < 100; i++ ) {
result.Add( _builder.GenerateBool() );
}
Assert.IsTrue( result.Contains( true ), "true" );
Assert.IsTrue( result.Contains( false ), "false" );
}
示例11: AddRange
public void AddRange()
{
List<int> stuff = new List<int>();
stuff.AddRange(5, 6, 7, 8);
Assert.IsTrue(stuff.Contains(5));
Assert.IsTrue(stuff.Contains(6));
Assert.IsTrue(stuff.Contains(7));
Assert.IsTrue(stuff.Contains(8));
}
示例12: GivenTwoAnagramsAndOneOther_ShouldPrintOnlyAnagrams
public void GivenTwoAnagramsAndOneOther_ShouldPrintOnlyAnagrams()
{
var word = new[] { "word", "drow", "crow" };
var printedLines = new List<string>();
RunFinder(word, printedLines);
Assert.IsTrue(printedLines.Contains("word drow"), "Should have printed the words in same line");
Assert.IsFalse(printedLines.Contains("crow"), "Should skip word not anagram");
}
示例13: CreateRandomBoolTest
public void CreateRandomBoolTest()
{
RandomValue target = new RandomValue(); // TODO: 初始化為適當值
List<bool> temp = new List<bool>();
for (int i = 0; i < 200; i++)
{
temp.Add(target.CreateRandomBool());
}
Assert.AreEqual(true, temp.Contains(true)&&temp.Contains(false));
}
示例14: GivenTwoAnagrams_ShouldPrintBothInTwoLines
public void GivenTwoAnagrams_ShouldPrintBothInTwoLines()
{
var word = new[] { "word", "drow", "blue", "lueb" };
var printedLines = new List<string>();
RunFinder(word, printedLines);
Assert.AreEqual(2, printedLines.Count);
Assert.IsTrue(printedLines.Contains("word drow"), "Should have printed the words in same line");
Assert.IsTrue(printedLines.Contains("blue lueb"), "Should have printed the words in same line");
}
示例15: DerivedSimpleDependencyTest
public void DerivedSimpleDependencyTest()
{
var changed_properties = new List<string>();
var obj = new DerivedSimpleDependencyObject();
obj.PropertyChanged += (sender, args) => changed_properties.Add(args.PropertyName);
obj.BaseProp1 = 42;
Assert.AreEqual(2, changed_properties.Count, "2 property changed events expected");
Assert.IsTrue(changed_properties.Contains("BaseProp1"), "BaseProp1 property changed event expected");
Assert.IsTrue(changed_properties.Contains("Prop1"), "Prop1 property changed event expected");
}