private static IEnumerable <BacklogPost> GetSortedBacklogPosts() { // 1 in 3 chance of coincidental ordering being correct, yielding a false positive when implementation fails to order explicitly. const int Days = 3; const int ChannelCount = 3; const int CollectionsPerChannel = 3; const int Posts = 6; var result = new List <BacklogPost>(); for (var day = 0; day < Days; day++) { var liveDate = new SqlDateTime(Now.AddDays(1 + day)).Value; for (var channelIndex = 0; channelIndex < ChannelCount; channelIndex++) { var channelId = new ChannelId(Guid.NewGuid()); for (var queueIndex = 0; queueIndex < CollectionsPerChannel; queueIndex++) { var queueId = queueIndex == 0 ? null : new QueueId(Guid.NewGuid()); for (var i = 0; i < Posts; i++) { var creationDate = new SqlDateTime(liveDate.AddMinutes(i)).Value; result.Add( new BacklogPost( new PostId(Guid.NewGuid()), channelId, i % 2 == 0 ? queueId : null, i % 2 == 0 ? PreviewText : null, i % 3 == 2 ? new FileId(Guid.NewGuid()) : null, i % 2 == 0 ? PreviewText.Value.Length : 0, i % 2 == 0 ? PreviewText.Value.Length : 0, i % 3 == 2 ? 1 : 0, i % 3 == 1 ? 1 : 0, i, liveDate, i % 3 == 2 ? FileName : null, i % 3 == 2 ? FileExtension : null, i % 3 == 2 ? FileSize : (long?)null, i % 3 == 2 ? FileWidth : (int?)null, i % 3 == 2 ? FileHeight : (int?)null, creationDate)); } } } } return(result.OrderBy(_ => _.LiveDate).ThenBy(_ => _.CreationDate)); }
private static IEnumerable <NewsfeedPost> GetSortedNewsfeedPosts() { // Half the posts will be in the future relative to Now. Days move one day every two posts. var day = 0; var result = new List <NewsfeedPost>(); for (var channelIndex = 0; channelIndex < ChannelsPerCreator; channelIndex++) { var channelId = ChannelIds[channelIndex]; for (var collectionIndex = 0; collectionIndex < CollectionsPerChannel; collectionIndex++) { var collectionId = CollectionIds[channelIndex][collectionIndex]; for (var i = 0; i < Posts; i++) { for (var isFuture = 0; isFuture < 2; ++isFuture) { var liveDate = new SqlDateTime(Now.AddDays((isFuture == 0 ? -1 : 1) * day)).Value; DateTime creationDate; if (i % 2 == 0) { // Ensure we have one post that is `now` (i.e. AddDays(0)). creationDate = liveDate; day++; } else { creationDate = new SqlDateTime(liveDate.AddMinutes(-1)).Value; } result.Add( new NewsfeedPost( CreatorId, new PostId(Guid.NewGuid()), BlogId, channelId, i % 2 == 0 ? PreviewText : null, i % 3 == 2 ? new FileId(Guid.NewGuid()) : null, i % 2 == 0 ? PreviewText.Value.Length : 0, i % 2 == 0 ? PreviewText.Value.Length : 0, i % 3 == 2 ? 1 : 0, i % 3 == 1 ? 1 : 0, i, liveDate, i % 3 == 2 ? FileName : null, i % 3 == 2 ? FileExtension : null, i % 3 == 2 ? FileSize : (long?)null, i % 3 == 2 ? FileWidth : (int?)null, i % 3 == 2 ? FileHeight : (int?)null, i % (UserIds.Count / 2), i % UserIds.Count, false, creationDate)); } } } } return(result.OrderByDescending(_ => _.LiveDate).ThenByDescending(_ => _.CreationDate)); }