Esempio n. 1
1
        public void OrderByDescending_BankIdentifierCode_AreEqual()
        {
            var item0 = BankIdentifierCode.Parse("AEGONL2UXXX");
            var item1 = BankIdentifierCode.Parse("CEBUNL2U");
            var item2 = BankIdentifierCode.Parse("DSSBNL22");
            var item3 = BankIdentifierCode.Parse("FTSBNL2R");

            var inp = new List<BankIdentifierCode>() { BankIdentifierCode.Empty, item3, item2, item0, item1, BankIdentifierCode.Empty };
            var exp = new List<BankIdentifierCode>() { item3, item2, item1, item0, BankIdentifierCode.Empty, BankIdentifierCode.Empty };
            var act = inp.OrderByDescending(item => item).ToList();

            CollectionAssert.AreEqual(exp, act);
        }
        private void SetupFakeStatistics()
        {
            allPerformers = (from account in conn.ACCOUNT
                             join ua in conn.PLATFORM_USER_ACCOUNT on account.ID equals ua.Account
                             join srv in conn.SERVICE on ua.PlatformUser equals srv.User
                             where account.Balance > 0
                             select new PerformerStat
                                 {
                                     Account = account.ID,
                                     DepoCurrency = account.Currency,
                                     Service = srv.ID
                                 }).ToList();
            for (var i = 0; i < allPerformers.Count; i++)
                allPerformers[i].Profit = (i - 10) * 5;

            var accountStatistics = ProxyBuilder.Instance.MakeImplementer<IAccountStatistics>(true);
            ((IMockableProxy)accountStatistics).MockMethods.Add(StronglyName.GetMethodName<IAccountStatistics>(s =>
                s.GetAllPerformersWithCriteria(false, "", 0, true, null, 0)),
                new Func<bool, string, int, bool, float?, int, List<PerformerStat>>(
                    (managersOnly, criteria, count, asc, filterValue, serviceTypeMask) =>
                    {
                        return (asc
                            ? allPerformers.OrderBy(p => p.Profit)
                            : allPerformers.OrderByDescending(p => p.Profit)).Take(count).ToList();
                    })
                );

            TradeSharpAccountStatistics.Initialize(accountStatistics);
        }
        private static string GetSearchResult(List<Package> packages)
        {
            Uri uri = new Uri(BaseUrl);
            string baseUri = uri.Scheme + "://" + uri.Host + ":" + uri.Port;
            string apiUri = baseUri + "/api/v2/";

            DateTime updated = packages.Any()
                                   ? packages.OrderByDescending(p => p.DateUpdated).First().DateUpdated
                                   : DateTime.UtcNow;

            SeachFeed.feed feed = new SeachFeed.feed
            {
                @base = apiUri,
                count = packages.Count,
                updated = updated,
                link = new SeachFeed.feedLink(apiUri + "Packages"),
                entry = packages.Select(p => Search.GetPackageEntry(p, uri)).ToArray()
            };

            XmlSerializer serializer = new XmlSerializer(typeof(SeachFeed.feed));
            MemoryStream ms = new MemoryStream();
            serializer.Serialize(ms, feed);
            ms.Position = 0;
            return new StreamReader(ms).ReadToEnd();
        }
        private static string GetFindPackageResult(string url, List<Package> packages, bool latestVersion)
        {
            string apiUri = url.Replace("&", "&amp;");
            Uri uri = new Uri(apiUri);

            DateTime updated = packages.Any()
                                   ? packages.OrderByDescending(p => p.DateUpdated).First().DateUpdated
                                   : DateTime.UtcNow;

            entry[] entries = latestVersion
                ? new[] { PackageDetails.GetPackageEntry(packages.FirstOrDefault(p => p.LatestVersion), uri) }
                : packages.Select(p => PackageDetails.GetPackageEntry(p, uri)).ToArray();

            feed feed = new feed
            {
                @base = InvokeUrl + "/",
                id = WebUtility.HtmlDecode(uri.ToString()),
                title = new feedTitle("FindPackagesById"),
                updated = updated,
                link = new feedLink("FindPackagesById", "FindPackagesById"),
                entry = entries
            };

            XmlSerializer serializer = new XmlSerializer(typeof(feed));
            MemoryStream ms = new MemoryStream();
            serializer.Serialize(ms, feed);
            ms.Position = 0;
            return new StreamReader(ms).ReadToEnd();
        }
        public void XX()
        {
            var x = new List<int> {1, 2, 3};

            x.OrderByDescending(xa => xa == 2)
                .ToList()
                .ForEach(a => Console.WriteLine(a.ToString()));
        }
Esempio n. 6
0
        private List<JsonPost> SortPosts(DateTime now, List<JsonPost> posts)
        {
            foreach (var post in posts)
            {
                post.EffectiveScore = Sorting.Hot(post.Score, post.Created.ToUnixTime());
            }

            return posts.OrderByDescending(x => x.EffectiveScore).ToList();
        }
Esempio n. 7
0
        public void CanSortAListOfPlayerScores()
        {
            List<PlayerScore> list = new List<PlayerScore>() { second_worst, best, second_best, worst };

            var sortedList = list.OrderByDescending((p) => p).ToList();

            Assert.AreEqual(best, sortedList[0]);
            Assert.AreEqual(second_best, sortedList[1]);
            Assert.AreEqual(second_worst, sortedList[2]);
            Assert.AreEqual(worst, sortedList[3]);
        }
Esempio n. 8
0
        public void PrefixesShouldBeSortedCorrectly()
        {
            var usortedPrefixesList = new List<Prefix>
            {
                Prefix.Kb, Prefix.Mb, Prefix.Gb, Prefix.Gb, Prefix.Kb, Prefix.Tb, Prefix.Gb, Prefix.Mb,Prefix.Tb, Prefix.Gb, Prefix.Mb, Prefix.Kb
            };

            usortedPrefixesList.OrderBy(it => it).Should().BeInAscendingOrder();

            usortedPrefixesList.OrderByDescending(it => it).Should().BeInDescendingOrder();
        }
Esempio n. 9
0
        public void only_highest_scores_are_stored_in_highscores()
        {
            var highScores = new HighScores();
            var randomGenerator = new Random();
            var generatedNumbers = new List<int>();
            for (int i = 0; i < 20; i++)
            {
                var number = randomGenerator.Next();
                highScores.Add(new Score(number));
                generatedNumbers.Add(number);
            }

            Assert.AreEqual(generatedNumbers.OrderByDescending(x => x).Take(10).Min(), highScores.Min().Points);
        }
 public void assure_changesets_are_ordered_by_revision()
 {
     IEnumerable<Changeset> result = new List<Changeset>();
     Scenario.StartNew(this, scenario =>
     {
         scenario.Given(a_ChangesetDatabaseRepository_is_created).
             And(there_are_changesets_in_the_database);
         scenario.When("all chagesets are requested", () =>
             result = repository.Get(new AllChangesetsSpecification()));
         scenario.Then("assure changesets are ordered by revision", () =>
         {
             var expectedResult = result.OrderByDescending(c => c.Revision);
             for (int i = 0; i < result.Count(); i++)
             {
                 result.ElementAt(i).Revision.ShouldBe(expectedResult.ElementAt(i).Revision);
             }
         });
     });
 }
Esempio n. 11
0
            public static List<SlugRoute> GetOrderedMatchingRules(string withVerb, string forPath)
            {
                var matchingRoutes = new List<SlugRoute>();

                foreach (var definition in Definitions)
                {
                    var pathComponents = RestPath.GetPathPartsForMatching(forPath);
                    definition.Score = definition.RestPath.MatchScore(withVerb, pathComponents);
                    if (definition.Score > 0)
                    {
                        matchingRoutes.Add(definition);
                    }
                }

                var orderedRoutes = matchingRoutes.OrderByDescending(x => x.Score).ToList();
                return orderedRoutes;
            }
Esempio n. 12
0
        public void OrderByDescending_EmailAddress_AreEqual()
        {
            var item0 = EmailAddress.Parse("*****@*****.**");
            var item1 = EmailAddress.Parse("*****@*****.**");
            var item2 = EmailAddress.Parse("*****@*****.**");
            var item3 = EmailAddress.Parse("*****@*****.**");

            var inp = new List<EmailAddress>() { EmailAddress.Empty, item3, item2, item0, item1, EmailAddress.Empty };
            var exp = new List<EmailAddress>() { item3, item2, item1, item0, EmailAddress.Empty, EmailAddress.Empty };
            var act = inp.OrderByDescending(item => item).ToList();

            CollectionAssert.AreEqual(exp, act);
        }
Esempio n. 13
0
        public void OrderByDescending_StreamSize_AreEqual()
        {
            StreamSize item0 = 13465;
            StreamSize item1 = 83465;
            StreamSize item2 = 113465;
            StreamSize item3 = 773465;

            var inp = new List<StreamSize>() { StreamSize.Zero, item3, item2, item0, item1, StreamSize.Zero };
            var exp = new List<StreamSize>() { item3, item2, item1, item0, StreamSize.Zero, StreamSize.Zero };
            var act = inp.OrderByDescending(item => item).ToList();

            CollectionAssert.AreEqual(exp, act);
        }
Esempio n. 14
0
        public void OrderByDescending_WeekDate_AreEqual()
        {
            var item0 = WeekDate.Parse("2000-W01-3");
            var item1 = WeekDate.Parse("2000-W11-2");
            var item2 = WeekDate.Parse("2000-W21-1");
            var item3 = WeekDate.Parse("2000-W31-7");

            var inp = new List<WeekDate>() { WeekDate.MinValue, item3, item2, item0, item1, WeekDate.MinValue };
            var exp = new List<WeekDate>() { item3, item2, item1, item0, WeekDate.MinValue, WeekDate.MinValue };
            var act = inp.OrderByDescending(item => item).ToList();

            CollectionAssert.AreEqual(exp, act);
        }
Esempio n. 15
0
        public void OrderByDescending_Month_AreEqual()
        {
            var item0 = Month.January;
            var item1 = Month.March;
            var item2 = Month.April;
            var item3 = Month.December;

            var inp = new List<Month>() { Month.Empty, item3, item2, item0, item1, Month.Empty };
            var exp = new List<Month>() { item3, item2, item1, item0, Month.Empty, Month.Empty };
            var act = inp.OrderByDescending(item => item).ToList();

            CollectionAssert.AreEqual(exp, act);
        }
		public void OrderByDescending_Distance_AreEqual()
		{
			Distance item0 = 13245d;
			Distance item1 = 23245d;
			Distance item2 = 43245d;
			Distance item3 = 73245d;

			var inp = new List<Distance>() { Distance.Zero, item3, item2, item0, item1, Distance.Zero };
			var exp = new List<Distance>() { item3, item2, item1, item0, Distance.Zero, Distance.Zero };
			var act = inp.OrderByDescending(item => item).ToList();

			CollectionAssert.AreEqual(exp, act);
		}
		public void OrderByDescending_Angle_AreEqual()
		{
			Angle item0 = 0.12;
			Angle item1 = 0.32;
			Angle item2 = 0.80;
			Angle item3 = 1.12;

			var inp = new List<Angle>() { Angle.Zero, item3, item2, item0, item1, Angle.Zero };
			var exp = new List<Angle>() { item3, item2, item1, item0, Angle.Zero, Angle.Zero };
			var act = inp.OrderByDescending(item => item).ToList();

			CollectionAssert.AreEqual(exp, act);
		}
Esempio n. 18
0
        public void OrderByDescending_LocalDateTime_AreEqual()
        {
            var item0 = new LocalDateTime(1900, 10, 01, 22, 10, 16);
            var item1 = new LocalDateTime(1963, 08, 23, 23, 59, 15);
            var item2 = new LocalDateTime(1999, 12, 05, 04, 13, 14);
            var item3 = new LocalDateTime(2010, 07, 13, 00, 44, 13);

            var inp = new List<LocalDateTime>() { LocalDateTime.MinValue, item3, item2, item0, item1, LocalDateTime.MinValue };
            var exp = new List<LocalDateTime>() { item3, item2, item1, item0, LocalDateTime.MinValue, LocalDateTime.MinValue };
            var act = inp.OrderByDescending(item => item).ToList();

            CollectionAssert.AreEqual(exp, act);
        }
Esempio n. 19
0
        public void OrderByDescending_Amount_AreEqual()
        {
            Amount item0 = 0.23;
            Amount item1 = 1.24;
            Amount item2 = 2.27;
            Amount item3 = 1300;

            var inp = new List<Amount>() { Amount.Zero, item3, item2, item0, item1, Amount.Zero };
            var exp = new List<Amount>() { item3, item2, item1, item0, Amount.Zero, Amount.Zero };
            var act = inp.OrderByDescending(item => item).ToList();

            CollectionAssert.AreEqual(exp, act);
        }
Esempio n. 20
0
        public void OrderByDescending_Percentage_AreEqual()
        {
            Percentage item0 = 0.0185m;
            Percentage item1 = 0.1230m;
            Percentage item2 = 0.2083m;
            Percentage item3 = 0.3333m;

            var inp = new List<Percentage>() { item3, item2, item0, item1 };
            var exp = new List<Percentage>() { item3, item2, item1, item0 };
            var act = inp.OrderByDescending(item => item).ToList();

            CollectionAssert.AreEqual(exp, act);
        }
        public void FindLargestPandigitalNumberThatIsAConcatenatedProduct()
        {
            var products = new List<PandigitalMultiple>();

            for (var number = 1; number < 100000; ++number)
            {
                var result = CheckIfCanGeneratePandigital(number);
                if (result > 0)
                {
                    products.Add(new PandigitalMultiple(result, number, 0));
                }
            }

            foreach (var result in products.OrderByDescending(p => p.Product))
            {
                Console.WriteLine(result);
            }
        }
Esempio n. 22
0
        public void Get_all_persons_orderd_by_age_descending()
        {
            var ages = new List<int>();
            using (var db = new PragmaticDbContext())
            {
                Person[] persons =
                {
                    new Person { Name = "Han Solo", Age = 30 },
                    new Person { Name = "Peter Pan", Age = 40 },
                    new Person { Name = "Tom Sawyer", Age = 50 }
                };

                ages.AddRange(persons.Select(person => person.Age));

                // Let's create persons in some random order.
                foreach (var person in persons.Randomize())
                {
                    db.Persons.Add(person);
                }
                db.SaveChanges();
            }

            var result = new GetAllQueryHandler<Person>(new PragmaticDbContext())
                             .Execute(new GetAllQuery<Person>
                             {
                                 OrderBy = new OrderBy<Person>(x => x.Age, OrderByDirection.Descending)
                             });

            Assert.That(result.CurrentPage, Is.EqualTo(Paging.None.Page));
            Assert.That(result.PageSize, Is.EqualTo(Paging.None.PageSize));
            Assert.That(result.TotalCount, Is.EqualTo(ages.Count));
            CollectionAssert.AreEqual(ages.OrderByDescending(x => x), result.Select(x => x.Age));
        }
Esempio n. 23
0
        public void OrderByDescending_Timestamp_AreEqual()
        {
            Timestamp item0 = 3245;
            Timestamp item1 = 13245;
            Timestamp item2 =132456;
            Timestamp item3 = 1324589;

            var inp = new List<Timestamp>() { Timestamp.MinValue, item3, item2, item0, item1, Timestamp.MinValue };
            var exp = new List<Timestamp>() { item3, item2, item1, item0, Timestamp.MinValue, Timestamp.MinValue };
            var act = inp.OrderByDescending(item => item).ToList();

            CollectionAssert.AreEqual(exp, act);
        }
        public void BruteForceFindPentagonalPairsWithSumDifferencePentagonal()
        {
            var list = new List<PentagonalPair>();

            foreach (var a in pentagonalNumbers)
            {
                var aValue = a;
                foreach (var b in pentagonalNumbers.Where(n => n > aValue))
                {
                    if (a == b) continue;

                    var sum = a + b;
                    if (!pentagonalNumbers.Contains(sum)) continue;
                    var diff = b - a;
                    if (!pentagonalNumbers.Contains(diff)) continue;

                    var pair = new PentagonalPair(a, b);
                    list.Add(pair);
                }
            }

            foreach (var pentagonalPair in list.OrderByDescending(pair => Math.Abs(pair.difference)))
            {
                Console.WriteLine(pentagonalPair);
            }
        }
Esempio n. 25
0
        public void OrderByDescending_Year_AreEqual()
        {
            Year item0 = 1980;
            Year item1 = 1981;
            Year item2 = 1982;
            Year item3 = 1983;

            var inp = new List<Year>() { Year.Empty, item3, item2, item0, item1, Year.Empty };
            var exp = new List<Year>() { item3, item2, item1, item0, Year.Empty, Year.Empty };
            var act = inp.OrderByDescending(item => item).ToList();

            CollectionAssert.AreEqual(exp, act);
        }
Esempio n. 26
0
        public void OrderByDescending_CryptographicSeed_AreEqual()
        {
            var item0 = CryptographicSeed.Create(new byte[] { 1 });
            var item1 = CryptographicSeed.Create(new byte[] { 2 });
            var item2 = CryptographicSeed.Create(new byte[] { 3, 6 });
            var item3 = CryptographicSeed.Create(new byte[] { 4, 2 });

            var inp = new List<CryptographicSeed>() { CryptographicSeed.Empty, item3, item2, item0, item1, CryptographicSeed.Empty };
            var exp = new List<CryptographicSeed>() { item3, item2, item1, item0, CryptographicSeed.Empty, CryptographicSeed.Empty };
            var act = inp.OrderByDescending(item => item).ToList();

            CollectionAssert.AreEqual(exp, act);
        }
        public void OrderByDescending_InternationalBankAccountNumber_AreEqual()
        {
            var item0 = InternationalBankAccountNumber.Parse("AE950210000000693123456");
            var item1 = InternationalBankAccountNumber.Parse("BH29BMAG1299123456BH00");
            var item2 = InternationalBankAccountNumber.Parse("CY17002001280000001200527600");
            var item3 = InternationalBankAccountNumber.Parse("DK5000400440116243");

            var inp = new List<InternationalBankAccountNumber>() { InternationalBankAccountNumber.Empty, item3, item2, item0, item1, InternationalBankAccountNumber.Empty };
            var exp = new List<InternationalBankAccountNumber>() { item3, item2, item1, item0, InternationalBankAccountNumber.Empty, InternationalBankAccountNumber.Empty };
            var act = inp.OrderByDescending(item => item).ToList();

            CollectionAssert.AreEqual(exp, act);
        }
Esempio n. 28
0
        public void GetChecklistsShouldSortResultsIfGivenValidSortKey()
        {
            // Arrange
            var repositoryChecklists = new List<ChecklistDto>()
            {
                new ChecklistDto
                {
                    Title = "C",
                    FileNumber = 3,
                    CreatedAt = new DateTime(2015, 3, 1),
                    LastModified = new DateTime(2015, 3, 1)
                },
                new ChecklistDto
                {
                    Title = "B",
                    FileNumber = 2,
                    CreatedAt = new DateTime(2015, 2, 1),
                    LastModified = new DateTime(2015, 2, 1)
                },
                new ChecklistDto
                {
                    Title = "A",
                    FileNumber = 1,
                    CreatedAt = new DateTime(2015, 1, 1),
                    LastModified = new DateTime(2015, 1, 1)
                }
            };

            var sortedByTitleAsc = repositoryChecklists.OrderBy(c => c.Title);
            var sortedByTitleDesc = repositoryChecklists.OrderByDescending(c => c.Title);
            var sortedByFileNumAsc = repositoryChecklists.OrderBy(c => c.FileNumber);
            var sortedByFileNumDesc = repositoryChecklists.OrderByDescending(c => c.FileNumber);
            var sortedByCreatedAtAsc = repositoryChecklists.OrderBy(c => c.CreatedAt);
            var sortedByCreatedAtDesc = repositoryChecklists.OrderByDescending(c => c.CreatedAt);
            var sortedByLastModifiedAsc = repositoryChecklists.OrderBy(c => c.LastModified);
            var sortedByLastModifiedDesc = repositoryChecklists.OrderByDescending(c => c.LastModified);

            var fakeRepository = A.Fake<IChecklistRepository>();
            A.CallTo(() => fakeRepository.GetChecklists()).Returns(repositoryChecklists.AsQueryable());

            var startup = new Startup
            {
                ControllerConfiguration = new ControllerConfiguration { PageSizeLimit = 100 },
                ChecklistRepository = fakeRepository
            };

            using (WebApp.Start(BaseApiUriString, startup.Configuration))
            {
                var client = new HttpClient();

                // Act
                var sortedByTitleAscResponse = client.GetAsync(new Uri(BaseApiUriString + "/api/checklists?sortField=Title&sortDirection=asc")).Result;
                var returnedSortedByTitleAsc = JsonConvert.DeserializeObject<List<ChecklistDto>>(sortedByTitleAscResponse.Content.ReadAsStringAsync().Result);

                var sortedByTitleDescResponse = client.GetAsync(new Uri(BaseApiUriString + "/api/checklists?sortField=Title&sortDirection=desc")).Result;
                var returnedSortedByTitleDesc = JsonConvert.DeserializeObject<List<ChecklistDto>>(sortedByTitleDescResponse.Content.ReadAsStringAsync().Result);

                var sortedByFileNumAscResponse = client.GetAsync(new Uri(BaseApiUriString + "/api/checklists?sortField=FileNumber&sortDirection=a")).Result;
                var returnedSortedByFileNumAsc = JsonConvert.DeserializeObject<List<ChecklistDto>>(sortedByFileNumAscResponse.Content.ReadAsStringAsync().Result);

                var sortedByFileNumDescResponse = client.GetAsync(new Uri(BaseApiUriString + "/api/checklists?sortField=FileNumber&sortDirection=d")).Result;
                var returnedSortedByFileNumDesc = JsonConvert.DeserializeObject<List<ChecklistDto>>(sortedByFileNumDescResponse.Content.ReadAsStringAsync().Result);

                var sortedByCreatedAtAscResponse = client.GetAsync(new Uri(BaseApiUriString + "/api/checklists?sortField=CreatedAt&sortDirection=ascending")).Result;
                var returnedSortedByCreatedAtAsc = JsonConvert.DeserializeObject<List<ChecklistDto>>(sortedByCreatedAtAscResponse.Content.ReadAsStringAsync().Result);

                var sortedByCreatedAtDescResponse = client.GetAsync(new Uri(BaseApiUriString + "/api/checklists?sortField=CreatedAt&sortDirection=descending")).Result;
                var returnedSortedByCreatedAtDesc = JsonConvert.DeserializeObject<List<ChecklistDto>>(sortedByCreatedAtDescResponse.Content.ReadAsStringAsync().Result);

                var sortedByLastModifiedAscResponse = client.GetAsync(new Uri(BaseApiUriString + "/api/checklists?sortField=LastModified&sortDirection=Ascending")).Result;
                var returnedSortedByLastModifiedAsc = JsonConvert.DeserializeObject<List<ChecklistDto>>(sortedByLastModifiedAscResponse.Content.ReadAsStringAsync().Result);

                var sortedByLastModifiedDescResponse = client.GetAsync(new Uri(BaseApiUriString + "/api/checklists?sortField=LastModified&sortDirection=Descending")).Result;
                var returnedSortedByLastModifiedDesc= JsonConvert.DeserializeObject<List<ChecklistDto>>(sortedByLastModifiedDescResponse.Content.ReadAsStringAsync().Result);

                // Assert
                Assert.That(sortedByTitleAscResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                Assert.True(sortedByTitleAsc.SequenceEqual(returnedSortedByTitleAsc));

                Assert.That(sortedByTitleDescResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                Assert.True(sortedByTitleDesc.SequenceEqual(returnedSortedByTitleDesc));

                Assert.That(sortedByFileNumAscResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                Assert.True(sortedByFileNumAsc.SequenceEqual(returnedSortedByFileNumAsc));

                Assert.That(sortedByFileNumDescResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                Assert.True(sortedByFileNumDesc.SequenceEqual(returnedSortedByFileNumDesc));

                Assert.That(sortedByCreatedAtAscResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                Assert.True(sortedByCreatedAtAsc.SequenceEqual(returnedSortedByCreatedAtAsc));

                Assert.That(sortedByCreatedAtDescResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                Assert.True(sortedByCreatedAtDesc.SequenceEqual(returnedSortedByCreatedAtDesc));

                Assert.That(sortedByLastModifiedAscResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                Assert.True(sortedByLastModifiedAsc.SequenceEqual(returnedSortedByLastModifiedAsc));

                Assert.That(sortedByLastModifiedDescResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                Assert.True(sortedByLastModifiedDesc.SequenceEqual(returnedSortedByLastModifiedDesc));
            }
        }
Esempio n. 29
0
        public void OrderByDescending_QGuid_AreEqual()
        {
            var item0 = Uuid.Parse("3BE968F7-AAEA-422C-BA74-72A4D045FD74");
            var item1 = Uuid.Parse("59ED7F38-8E6A-45A9-B3A2-6D32FDF4DD10");
            var item2 = Uuid.Parse("5BD0EF29-C625-4B8D-A063-E474B28E8653");
            var item3 = Uuid.Parse("77185219-193C-4D39-B4B1-9ED05B0FC4C8");

            var inp = new List<Uuid>() { Uuid.Empty, item3, item2, item0, item1, Uuid.Empty };
            var exp = new List<Uuid>() { item3, item2, item1, item0, Uuid.Empty, Uuid.Empty };
            var act = inp.OrderByDescending(item => item).ToList();

            CollectionAssert.AreEqual(exp, act);
        }
Esempio n. 30
0
        private List<Comment> CreateTreeComments()
        {
            var comments = new List<Comment>();
            for (var x = 0; x < 10; x++)
            {
                var comment = new Comment();
                comment.Id = GuidUtil.NewSequentialId();
                comment.VoteUpCount = x % 10;
                comment.VoteDownCount = x % 5;
                comment.DateCreated = Common.CurrentTime();
                comments.Add(comment);
                for (var y = 0; y < 10; y++)
                {
                    var child = new Comment();
                    child.Id = GuidUtil.NewSequentialId();
                    child.VoteUpCount = y % 10;
                    child.VoteDownCount = y % 5;
                    child.ParentId = comment.Id;
                    child.DateCreated = Common.CurrentTime();
                    comments.Add(child);

                    for (var z = 0; z < 10; z++)
                    {
                        var grandChild = new Comment();
                        grandChild.Id = GuidUtil.NewSequentialId();
                        grandChild.VoteUpCount = z % 10;
                        grandChild.VoteDownCount = z % 5;
                        grandChild.ParentId = child.Id;
                        grandChild.DateCreated = Common.CurrentTime();
                        comments.Add(grandChild);
                    }
                }
            }

            comments = comments.OrderByDescending(x => Sorting.Confidence(x.VoteUpCount, x.VoteDownCount)).ThenByDescending(x => x.DateCreated).ToList();

            SetupComments(comments);

            return comments;
        }