本文整理汇总了C#中Microsoft.VisualStudio.TestTools.UnitTesting.List.Union方法的典型用法代码示例。如果您正苦于以下问题:C# List.Union方法的具体用法?C# List.Union怎么用?C# List.Union使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudio.TestTools.UnitTesting.List
的用法示例。
在下文中一共展示了List.Union方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DistinctByLambda_OneListEmpty_ExpectTheOneListValues
public void DistinctByLambda_OneListEmpty_ExpectTheOneListValues()
{
List<Member> emptyList = new List<Member>();
var result = emptyList.Union(this.dozenPeopleList).Distinct((l1, l2) => l1.FirstName == l2.FirstName);
Assert.IsTrue(result.Count() > 1);
}
示例2: UnionTest
public void UnionTest()
{
var src = new List<String> { "foo", "bar" };
var act = src.Union("foo").Union("baz");
Assert.IsTrue(act.Count() == 3);
Assert.IsTrue(act.Contains("baz"));
}
示例3: ShowWallOfUserCommandFollowingTwoUsersOk
public void ShowWallOfUserCommandFollowingTwoUsersOk()
{
const string username = "userA";
const string usernameFollowed1 = "userB";
const string usernameFollowed2 = "userC";
var followedUsernamesList = new List<string> { usernameFollowed1, usernameFollowed2 };
var expectedLookedUpUsersForMessages = followedUsernamesList.Union(new List<string>{username});
const string messageFollowed1 = "Ciao from 1";
const string messageFollowed2 = "Ciao from 2";
var timestampMessage1 = new DateTime(2000, 1, 1, 0, 0, 5);
var timestampMessage2 = new DateTime(2000, 1, 1, 0, 0, 0);
var timestampQueryTime = new DateTime(2000, 1, 1, 0, 0, 10);
var deltaSeconds1 = (timestampQueryTime - timestampMessage1).TotalSeconds;
var deltaSeconds2 = (timestampQueryTime - timestampMessage2).TotalSeconds;
timeProviderMock
.Setup(x => x.Now())
.Returns(timestampQueryTime);
followingRepositoryMock
.Setup(x => x.Get(It.Is<string>(y => username == y)))
.Returns(followedUsernamesList);
messagesRepositoryMock
.Setup(x => x.Get(It.Is<IEnumerable<string>>(y => expectedLookedUpUsersForMessages.SequenceEqual(y))))
.Returns(new List<MessageEnvelope>
{
new MessageEnvelope(usernameFollowed1, messageFollowed1, timestampMessage1),
new MessageEnvelope(usernameFollowed2, messageFollowed2, timestampMessage2)
});
outputManagerMock
.Setup(x => x.WriteLine(
It.Is<string>(y => y == usernameFollowed1 + " - " + messageFollowed1 + " (" + deltaSeconds1 + " seconds ago)")));
outputManagerMock
.Setup(x => x.WriteLine(
It.Is<string>(y => y == usernameFollowed2 + " - " + messageFollowed2 + " (" + deltaSeconds2 + " seconds ago)")));
var command = new ShowWallOfUserCommand(
outputManagerMock.Object,timeProviderMock.Object, messagesRepositoryMock.Object, followingRepositoryMock.Object,
username);
command.Execute();
}
示例4: UseEqualityTest
public void UseEqualityTest()
{
//NamedSchemaObject = has a name and schemaOwner
var schema = new DatabaseSchema(null, null);
schema.Owner = "dbo";
schema.AddTable("A").AddTable("A");
var distinct = schema.Tables.Distinct().Count();
Assert.AreEqual(1, distinct);
//NamedObject = has a name
var cols = new List<DatabaseColumn> {new DatabaseColumn {Name = "Id"}, new DatabaseColumn {Name = "Name"}};
var cols2 = new List<DatabaseColumn> { new DatabaseColumn { Name = "Id" }, new DatabaseColumn { Name = "Name" } };
var union = cols.Union(cols2);
Assert.AreEqual(2, union.Count());
}
示例5: TestUnionCopy_WithComparer_NullDestination_Throws
public void TestUnionCopy_WithComparer_NullDestination_Throws()
{
IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
IExpandableSublist<List<int>, int> list2 = new List<int>().ToSublist();
IExpandableSublist<List<int>, int> destination = null;
IComparer<int> comparer = Comparer<int>.Default;
list1.Union(list2, comparer).CopyTo(destination);
}
示例6: TestUnionCopy_WithComparison_NullList2_Throws
public void TestUnionCopy_WithComparison_NullList2_Throws()
{
IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
IExpandableSublist<List<int>, int> list2 = null;
Func<int, int, int> comparison = Comparer<int>.Default.Compare;
list1.Union(list2, comparison);
}
示例7: TestUnionCopy_NullDestination_Throws
public void TestUnionCopy_NullDestination_Throws()
{
IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
IExpandableSublist<List<int>, int> list2 = new List<int>().ToSublist();
IExpandableSublist<List<int>, int> destination = null;
list1.Union(list2).CopyTo(destination);
}
示例8: TestUnionCopy_NullList2_Throws
public void TestUnionCopy_NullList2_Throws()
{
IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
IExpandableSublist<List<int>, int> list2 = null;
list1.Union(list2);
}
示例9: TestUnionCopy_NullComparison_Throws
public void TestUnionCopy_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.Union(list2, comparison);
}
示例10: TestUnionCopy_NullComparer_Throws
public void TestUnionCopy_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.Union(list2, comparer);
}
示例11: Union_abnormal
public void Union_abnormal()
{
// arrange
List<int> first = new List<int>() { 1, 2, 3 };
// act and assert
try
{
first.Union(null);
Assert.Fail();
}
catch (Exception e)
{
Assert.IsTrue(e is ArgumentNullException);
}
}
示例12: Union
public void Union()
{
// arrange
List<int> first = new List<int>() { 1, 2, 3 };
List<int> second = new List<int>() { 0, 1, 3, 4 };
// act
List<int> actual = first.Union(second).ToList();
// assert
Assert.AreEqual(5, actual.Count());
Assert.AreEqual(1, actual[0]);
Assert.AreEqual(2, actual[1]);
Assert.AreEqual(3, actual[2]);
Assert.AreEqual(0, actual[3]);
Assert.AreEqual(4, actual[4]);
}
示例13: TestUnionAdd_WithComparer_NullList2_Throws
public void TestUnionAdd_WithComparer_NullList2_Throws()
{
IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
IExpandableSublist<List<int>, int> list2 = null;
IComparer<int> comparer = Comparer<int>.Default;
list1.Union(list2, comparer);
}