当前位置: 首页>>代码示例>>C#>>正文


C# List.Union方法代码示例

本文整理汇总了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);
        }
开发者ID:lance22me,项目名称:BiggResponsive,代码行数:7,代码来源:EnumerableExtensionTests.cs

示例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"));
 }
开发者ID:stevenvolckaert,项目名称:autodesk-inventor-powertools,代码行数:7,代码来源:IEnumerableExtensionsFixture.cs

示例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();
        }
开发者ID:micheledicosmo,项目名称:retrotwitter,代码行数:44,代码来源:CommandTests.cs

示例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());
        }
开发者ID:shiningrise,项目名称:dbschemareader,代码行数:17,代码来源:CanSerializeTest.cs

示例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);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:8,代码来源:UnionCopyTester.cs

示例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);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:UnionCopyTester.cs

示例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);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:UnionCopyTester.cs

示例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);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:6,代码来源:UnionCopyTester.cs

示例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);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:UnionCopyTester.cs

示例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);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:UnionCopyTester.cs

示例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);
            }
        }
开发者ID:jlinqer,项目名称:jLinqer,代码行数:16,代码来源:EnumerableAbnormalTest.cs

示例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]);
        }
开发者ID:jlinqer,项目名称:jLinqer,代码行数:17,代码来源:EnumerableTest.cs

示例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);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:UnionAddTester.cs


注:本文中的Microsoft.VisualStudio.TestTools.UnitTesting.List.Union方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。