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); }
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")); }
public void ShowWallOfUserCommandFollowingTwoUsersOk() { const string username = "******"; 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(); }
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()); }
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); }
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); }
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); }
public void TestUnionCopy_NullList2_Throws() { IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist(); IExpandableSublist<List<int>, int> list2 = null; list1.Union(list2); }
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); }
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); }
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); } }
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]); }
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); }