本文整理汇总了C#中Microsoft.VisualStudio.TestTools.UnitTesting.List.Except方法的典型用法代码示例。如果您正苦于以下问题:C# List.Except方法的具体用法?C# List.Except怎么用?C# List.Except使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudio.TestTools.UnitTesting.List
的用法示例。
在下文中一共展示了List.Except方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestExceptAdd_NullComparer_Throws
public void TestExceptAdd_NullComparer_Throws()
{
IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
IExpandableSublist<List<int>, int> list2 = new List<int>().ToSublist();
IComparer<int> comparer = null;
list1.Except(list2, comparer);
}
示例2: GetFactorsTest
public void GetFactorsTest()
{
double number = 18;
List<double> expectedFactors = new List<double>() { 1, 2, 3, 6, 9, 18 };
Assert.IsTrue(expectedFactors.Except(Calculate.GetFactors(number)).ToArray().Length == 0);
}
示例3: TestExceptAdd_NullComparison_Throws
public void TestExceptAdd_NullComparison_Throws()
{
IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
IExpandableSublist<List<int>, int> list2 = new List<int>().ToSublist();
Func<int, int, int> comparison = null;
list1.Except(list2, comparison);
}
示例4: ShouldReturnPrimesUnder30
public void ShouldReturnPrimesUnder30()
{
// Arrange
var primeNumbers = new PrimeNumbers();
var primesReturned = false;
var primesGenerated = new List<int>();
// Primes taken from https://oeis.org/A000040
var primesUnder30 = new List<int>
{
2,
3,
5,
7,
11,
13,
17,
19,
23,
29
};
// Act
foreach (var prime in primeNumbers.Generate(30))
{
Assert.IsTrue(primesUnder30.Contains(prime), $"Unexpected prime: {prime}");
primesGenerated.Add(prime);
primesReturned = true;
}
// Assert
Assert.IsTrue(primesReturned, "Expected the on prime action to be called.");
Assert.IsFalse(primesUnder30.Except(primesGenerated).Any(), "Expected all primes under 30 to be generated.");
}
示例5: LinqExcept_ShouldReturnEMotyCollection
public void LinqExcept_ShouldReturnEMotyCollection()
{
var playlistItem1 = new List<PlaylistItem> { new PlaylistItem { Snippet = new PlaylistItemSnippet { Title = "Title 1", ResourceId = new ResourceId { VideoId = "dsfhahdfh" } } } };
var playlistItem2 = new List<PlaylistItem> { new PlaylistItem { Snippet = new PlaylistItemSnippet { Title = "Title 1", ResourceId = new ResourceId { VideoId = "dsfhahdfh" } } } };
var comparer = new PlaylistItemEqualityComparer();
var result = playlistItem1.Except(playlistItem2, comparer);
Assert.IsFalse(result.Any());
}
示例6: LinqExcept_ShouldReturnEMotyCollection
public void LinqExcept_ShouldReturnEMotyCollection()
{
var channel1 = new List<Channel> { new Channel { Id = "dsfhahdfh", Snippet = new ChannelSnippet { Title = "Title 1" } } };
var channel2 = new List<Channel> { new Channel { Id = "dsfhahdfh", Snippet = new ChannelSnippet { Title = "Title 1" } } };
var comparer = new ChannelEqualityComparer();
var result = channel1.Except(channel2, comparer);
Assert.IsFalse(result.Any());
}
示例7: QueryDocIdsWithParameterDocIds
public void QueryDocIdsWithParameterDocIds()
{
var expectedDocIds = new List<string>
{
$"M:{ValidDocId}0",
$"T:{ValidDocId}0",
};
var result = _OfflineApiPortService.QueryDocIdsAsync(expectedDocIds).Result.Response;
Assert.AreEqual(expectedDocIds.Count(), result.Count());
Assert.AreEqual(0, expectedDocIds.Except(result.Select(r => r.Definition.DocId)).Count());
}
示例8: GetFilePaths_return_correct_paths
public void GetFilePaths_return_correct_paths()
{
var _checkList = new List<string>
{
@"C:\Users\DarkS\Source\Repos\ElQuecus\ElQuecus\ElQuecus.Test\TestMusic\Hollywood Undead- Does Everybody In the World Have To Die.mp3",
@"C:\Users\DarkS\Source\Repos\ElQuecus\ElQuecus\ElQuecus.Test\TestMusic\Hollywood Undead - Disease.mp3",
@"C:\Users\DarkS\Source\Repos\ElQuecus\ElQuecus\ElQuecus.Test\TestMusic\Hollywood Undead- Party By Myself.mp3"
};
const string checkedPath = @"C:\Users\DarkS\Source\Repos\ElQuecus\ElQuecus\ElQuecus.Test\TestMusic";
var test = FileSearch.GetFilePaths(checkedPath).Result;
Assert.AreEqual(_checkList.Except(test).Count(), 0);
}
示例9: ExceptTest
public void ExceptTest()
{
var src = new List<String> { "foo", "bar", "baz" };
var act = src.Except("bar");
Assert.IsTrue(act.Count() == 2);
Assert.IsFalse(act.Contains("bar"));
src = new List<String> { "foo", "bar", "baz" };
act = src.Except("xxx");
Assert.IsTrue(act.Count() == 3);
Assert.IsFalse(act.Contains("xxx"));
}
开发者ID:stevenvolckaert,项目名称:autodesk-inventor-powertools,代码行数:13,代码来源:IEnumerableExtensionsFixture.cs
示例10: TestBatchableViewModel_ChangeModelProperty_AllPropertyChangedFired
public void TestBatchableViewModel_ChangeModelProperty_AllPropertyChangedFired()
{
var listOfPropertyNames = new List<string>();
var vm = new TestBatchableViewModel();
vm.PropertyChanged += (sender, args) => { listOfPropertyNames.Add(args?.PropertyName); };
vm.SetBackingModel(new TestModel(name: "Test", id: 1));
var expectedListOfNames = new List<string>() { "Model", nameof(vm.Name), nameof(vm.ID) };
Assert.IsTrue(expectedListOfNames.Except(listOfPropertyNames).Count() == 0, $"All property names expected are NOT in the fired list: expected:[{HelperMethods.GetStringFromCollection(expectedListOfNames)}], fired:[{HelperMethods.GetStringFromCollection(listOfPropertyNames)}].");
Assert.IsTrue(listOfPropertyNames.Except(expectedListOfNames).Count() == 0, $"All property names fired are NOT in the expected list: expected:[{HelperMethods.GetStringFromCollection(expectedListOfNames)}], fired:[{HelperMethods.GetStringFromCollection(listOfPropertyNames)}].");
CollectionAssert.AreEqual(expectedListOfNames, listOfPropertyNames, $"The expected properties of the TestViewModel: expected:[{HelperMethods.GetStringFromCollection(expectedListOfNames)}], fired:[{HelperMethods.GetStringFromCollection(listOfPropertyNames)}]. They fired in an incorrect order...");
}
示例11: TestDecode
public void TestDecode()
{
var hFuncs = new List<IHashFunc>
{
new MurmurHash3_x86_32() {Seed = 0},
new MurmurHash3_x86_32() {Seed = 1},
new MurmurHash3_x86_32() {Seed = 2},
new MurmurHash3_x86_32() {Seed = 3},
new MurmurHash3_x86_32() {Seed = 4}
};
var l1 = new List<long>();
var l2 = new List<long>();
for (var i = 0; i < 1000; ++i)
{
l1.Add((long)i);
}
for (var i = 0; i < 1010; ++i)
{
l2.Add((long)i);
}
var ibf1 = new IBF(30, hFuncs);
var ibf2 = new IBF(30, hFuncs);
foreach (var i in l1)
{
ibf1.Add(i);
}
foreach (var i in l2)
{
ibf2.Add(i);
}
var sub = ibf1 - ibf2;
var l1ml2 = new List<long>();
var l2ml1 = new List<long>();
var ret = sub.Decode(l1ml2, l2ml1);
var expected = l2.Except(l1).ToList();
expected.Sort();
var actual = l2ml1;
actual.Sort();
CollectionAssert.AreEqual(expected, actual);
Assert.IsTrue(ret);
}
示例12: TrieTests_EnumerateInOrder
public void TrieTests_EnumerateInOrder()
{
Trie<char> trie = new Trie<char>();
List<string> items = new List<string>() { "abcd", "abc" };
foreach (string item in items)
{
trie.Insert(item);
}
items.Sort();
var actualOrder = trie.EnumerateInOrder().Select(sequence => new string(sequence.ToArray())).ToList();
Assert.IsTrue(items.Except(actualOrder).Count() == 0);
Assert.IsTrue(actualOrder.Except(items).Count() == 0);
}
示例13: AddShouldStoreKeysPersistently
public void AddShouldStoreKeysPersistently()
{
var keys = new List<decimal>();
var hashtable = new HashTable<decimal, string>();
for (int i = 0; i < 1000; i++)
{
var nextKey = rng.NextDecimal();
hashtable.Add(nextKey, "dinozavyr");
keys.Add(nextKey);
}
keys.ForEach(x => Assert.IsTrue(hashtable.Keys.Contains(x)));
Assert.AreEqual(0, keys.Except(hashtable.Keys).Count());
Assert.AreEqual(0, hashtable.Keys.Except(keys).Count());
}
示例14: ChangeExports
private void ChangeExports(List<Export> newExports)
{
using (var atomicComposition = new AtomicComposition())
{
atomicComposition.AddCompleteAction(() => this._exports = newExports);
atomicComposition.SetValue(this, newExports);
var addedExports = newExports.Except(this._exports).Select(export => export.Definition);
var removedExports = this._exports.Except(newExports).Select(export => export.Definition);
this.OnExportsChanging(new ExportsChangeEventArgs(addedExports, removedExports, atomicComposition));
atomicComposition.AddCompleteAction(() => this.OnExportsChanged(
new ExportsChangeEventArgs(addedExports, removedExports, null)));
atomicComposition.Complete();
}
}
示例15: AddRemoveItems
public void AddRemoveItems()
{
// Arrange
IList<int> newList = new List<int>() { 1, 2, 3 };
IList<int> currentList = new List<int>() {1, 3, 4, 5};
IList<int> finalList = currentList;
// Act
var addedList = newList.Except(currentList).ToList();
var deletedList = currentList.Except(newList).ToList();
addedList.ForEach(x => finalList.Add(x));
deletedList.ForEach(x => finalList.Remove(x));
// Assert
Assert.AreEqual(1, addedList.Count());
Assert.AreEqual(2, deletedList.Count());
Assert.AreEqual(3, finalList.Count());
}