public void AssignData(DiskUsage data, SortingOption initialSorting) { DataStore = data; Sorting = initialSorting; SetChartOptions(Mode, Sorting); }
public void GetSortingCategoryTest_InvalidOption(SortingOption sortingOption) { //Arrange //Act //Assert Assert.Throws <NotSupportedException>(() => MobileSortingService.GetSortingCategory(sortingOption)); }
public Task SetSortingOption(SortingOption sortingOption) { if (App.Query(_androidContextMenuOverflowButton).Any()) { App.Tap(_androidContextMenuOverflowButton); App.Screenshot("Tapped Android Search Bar Button"); } App.Tap(_sortButton); App.Screenshot("Sort Button Tapped"); var sortingOptionDescription = SortingConstants.SortingOptionsDictionary[sortingOption]; if (App is iOSApp) { var trendingOptionsRect = App.Query(sortingOptionDescription).Last().Rect; App.TapCoordinates(trendingOptionsRect.CenterX, trendingOptionsRect.CenterY); } else { App.Tap(sortingOptionDescription); } App.Screenshot($"{sortingOptionDescription} Tapped"); return(WaitForRepositoriesToFinishSorting()); }
public PwrSortedList(IEnumerable <T> coll, IComparer <T> sortComparer, SortingOption sortingOption = SortingOption.None, bool readOnly = false) : this(coll != null ? coll .ToSortedPwrList((sortComparer ?? Comparer <T> .Default).Compare, sortingOption) .WithIf(list => readOnly, list => list.Restrict(CollectionRestrictions.ReadOnly)) : new PwrList <T>(), (sortComparer != null ? sortComparer : Comparer <T> .Default).Compare, sortingOption) { }
/// <summary> /// This parameter allows you to sort the response data on one or more /// fields in the desired order. Define one or more sorting options. /// </summary> /// <param name="field">The fields which should be sorted.</param> /// <param name="sortingOptions">The sorting options.</param> /// <returns>The request builder.</returns> public RequestBuilder <ModelType> Sort(string field, SortingOption sortingOptions) { if (sortingOptions.HasFlag(SortingOption.Descending) == true) { field = $"-{field}"; } this.requestHandler.AddQueryParameter(name: "sort[]", value: field); return(this); }
protected IQueryable <TSource> SortQuery <TSource, TKey>(IQueryable <TSource> query, string[] options, Expression <Func <TSource, TKey> > defaultOrder) where TSource : class { var sortingOptions = SortingOption.Parse(options); if (sortingOptions.Length > 0) { return(query.OrderBy(sortingOptions)); } return(query.OrderBy(defaultOrder)); }
public void GetSortingCategoryTest_ValidOption(SortingOption sortingOption, SortingCategory expectedSortingCategory) { //Arrange SortingCategory actualSortingCategory; //Act actualSortingCategory = MobileSortingService.GetSortingCategory(sortingOption); //Assert Assert.AreEqual(expectedSortingCategory, actualSortingCategory); }
public void SetSortingOption(SortingOption sortingOption) { if (App.Query(_androidContextMenuOverflowButton).Any()) { App.Tap(_androidContextMenuOverflowButton); App.Screenshot("Tapped Android Search Bar Button"); } App.Tap(_sortButton); App.Screenshot("Sort Button Tapped"); App.Tap(SortingConstants.SortingOptionsDictionary[sortingOption]); }
public async Task SortRepositoriesCommandTest_InvalidSortingOption(SortingOption sortingOption) { //Arrange var gitHubAuthenticationService = ServiceCollection.ServiceProvider.GetRequiredService <GitHubAuthenticationService>(); //Act await gitHubAuthenticationService.ActivateDemoUser().ConfigureAwait(false); await RepositoryViewModel.PullToRefreshCommand.ExecuteAsync().ConfigureAwait(false); //Assert Assert.Throws <InvalidEnumArgumentException>(() => RepositoryViewModel.SortRepositoriesCommand.Execute(sortingOption)); }
public ChartDialogForm(DiskUsage dataStore, SortingOption initialSort) { InitializeComponent(); if (dataStore != null) { diskChart.AssignData(dataStore, initialSort); sortingCombo.AddEnumDescriptionItems(new SortingOption(), (int)initialSort); } displayModeCombo.SelectedIndex = 0; }
protected PwrSortedList(IList <T> innerList, Comparison <T> sortComparison, SortingOption sortingOption = SortingOption.None) { if (innerList == null) { throw new ArgumentNullException("innerList"); } if (sortComparison == null) { throw new ArgumentNullException("sortComparison"); } _innerList = innerList; _sortComparison = sortComparison; _sortingOption = sortingOption; }
public async Task <IList <Product> > SortProductsByOptionAsync(SortingOption sortingOption) { //TODO caching var products = await _apiClient.GetProductsAsync(_configuration["Token"]); var sortingService = _sortingOptionServices.FirstOrDefault(service => service.SortingOption == sortingOption); if (sortingService == null) { //TODO Logging / Monitoring throw new InternalServerException($"The sorting option {sortingOption} is not available"); } return(await sortingService.SortAsync(products)); }
/// <summary> /// Returns the names of files (including their paths) that match the specified search pattern in the specified directory, using a value to determine whether to search subdirectories and a value to determine how to sort. /// </summary> /// <param name="path"> The directory to search. </param> /// <param name="searchPattern"> The search string to match against the names of files in path. The parameter cannot end in two periods ("..") or contain two periods ("..") followed by DirectorySeparatorChar or AltDirectorySeparatorChar, nor can it contain any of the characters in InvalidPathChars. </param> /// <param name="searchOption"> One of the SearchOption values that specifies whether the search operation should include all subdirectories or only the current directory. </param> /// <param name="sortingOption"> One of the SortingOption values that specifies how to sort string arrays to return. </param> /// <returns> A String array containing the names of files which is sorted with the specified sorting option in the specified directory that match the specified search pattern. File names include the full path. </returns> public static string[] GetFiles( string path, string searchPattern, SearchOption searchOption, SortingOption sortingOption) { var paths = Directory.GetFiles(path, searchPattern, searchOption); switch (sortingOption) { case SortingOption.None: break; case SortingOption.Name: Array.Sort(paths); break; default: throw new ArgumentOutOfRangeException("sortingOption"); } return paths; }
public void CurrentOptionTest_ValidOption(SortingOption sortingOption) { //Arrange SortingOption currentOption_Initial, currentOption_Final; var sortingService = ServiceCollection.ServiceProvider.GetService <SortingService>(); //Act currentOption_Initial = sortingService.CurrentOption; sortingService.CurrentOption = sortingOption; currentOption_Final = sortingService.CurrentOption; //Assert Assert.AreEqual(SortingConstants.DefaultSortingOption, currentOption_Initial); Assert.AreEqual(sortingOption, currentOption_Final); }
public async Task SortRepositoriesCommandTest_ValidSortingOption(SortingOption sortingOption) { //Arrange var gitHubAuthenticationService = ServiceCollection.ServiceProvider.GetRequiredService <GitHubAuthenticationService>(); //Act await gitHubAuthenticationService.ActivateDemoUser().ConfigureAwait(false); await RepositoryViewModel.PullToRefreshCommand.ExecuteAsync().ConfigureAwait(false); RepositoryViewModel.SortRepositoriesCommand.Execute(sortingOption); //Assert AssertRepositoriesSorted(RepositoryViewModel.VisibleRepositoryList, sortingOption); //Act RepositoryViewModel.SortRepositoriesCommand.Execute(sortingOption); //Assert AssertRepositoriesReversedSorted(RepositoryViewModel.VisibleRepositoryList, sortingOption); }
public async Task <ActionResult <IList <Product> > > SortProductsAsync(SortingOption sortOption) { try { var sortedProducts = await _productSortingService.SortProductsByOptionAsync(sortOption); return(Ok(sortedProducts)); } catch (InternalServerException exception) { //TODO Monitoring _logger.LogError("Could not sort the products", exception); return(StatusCode((int)HttpStatusCode.InternalServerError)); } catch (Exception exception) { //TODO Monitoring _logger.LogError("An unexpected error happened", exception); return(StatusCode((int)HttpStatusCode.InternalServerError)); } }
/// <summary> /// Returns the names of files (including their paths) that match the specified search pattern in the specified directory, using a value to determine whether to search subdirectories and a value to determine how to sort. /// </summary> /// <param name="path"> The directory to search. </param> /// <param name="searchPattern"> The search string to match against the names of files in path. The parameter cannot end in two periods ("..") or contain two periods ("..") followed by DirectorySeparatorChar or AltDirectorySeparatorChar, nor can it contain any of the characters in InvalidPathChars. </param> /// <param name="searchOption"> One of the SearchOption values that specifies whether the search operation should include all subdirectories or only the current directory. </param> /// <param name="sortingOption"> One of the SortingOption values that specifies how to sort string arrays to return. </param> /// <returns> A String array containing the names of files which is sorted with the specified sorting option in the specified directory that match the specified search pattern. File names include the full path. </returns> public static string[] GetFiles( string path, string searchPattern, SearchOption searchOption, SortingOption sortingOption) { var paths = Directory.GetFiles(path, searchPattern, searchOption); switch (sortingOption) { case SortingOption.None: break; case SortingOption.Name: Array.Sort(paths); break; default: throw new ArgumentOutOfRangeException("sortingOption"); } return(paths); }
public IEnumerable <PathRecord> Sorted(SortingOption sorting) { switch (sorting) { case SortingOption.Alphabetical: return(Paths.OrderBy(o => o.FriendlyName.Replace("\\", ""))); case SortingOption.AlphabeticalDescending: return(Paths.OrderByDescending(o => o.FriendlyName.Replace("\\", ""))); case SortingOption.FreeSpace: return(Paths.OrderBy(o => o.FreeSpace.Bytes)); case SortingOption.FreeSpaceDescending: return(Paths.OrderByDescending(o => o.FreeSpace.Bytes)); case SortingOption.FillPercentage: return(Paths.OrderBy(o => o.FillLevel)); case SortingOption.FillPercentageDescending: return(Paths.OrderByDescending(o => o.FillLevel)); case SortingOption.Capacity: return(Paths.OrderBy(o => o.Capacity.Bytes)); case SortingOption.CapacityDescending: return(Paths.OrderByDescending(o => o.Capacity.Bytes)); case SortingOption.UsedSpace: return(Paths.OrderBy(o => o.UsedSpace.Bytes)); case SortingOption.UsedSpaceDescending: return(Paths.OrderByDescending(o => o.UsedSpace.Bytes)); default: Debug.Print("sorting not recognised"); return(Paths.AsEnumerable()); } }
public async Task VerifySortingOptions(SortingOption sortingOption) { //Fail all tests if the DefaultSortingOption has changed Assert.AreEqual(MobileSortingService.DefaultSortingOption, SortingOption.Views); //Arrange string floatingActionTextButtonStatistic1Text, floatingActionTextButtonStatistic2Text, floatingActionTextButtonStatistic3Text; Repository finalFirstRepository, finalSecondTopRepository, finalLastRepository; Repository initialFirstRepository = RepositoryPage.VisibleCollection.First(); Repository initialSecondTopRepository = RepositoryPage.VisibleCollection.Skip(1).First(); Repository initialLastRepository = RepositoryPage.VisibleCollection.Last(); //Act await RepositoryPage.SetSortingOption(sortingOption).ConfigureAwait(false); floatingActionTextButtonStatistic1Text = RepositoryPage.InformationButtonStatistic1Text; floatingActionTextButtonStatistic2Text = RepositoryPage.InformationButtonStatistic2Text; floatingActionTextButtonStatistic3Text = RepositoryPage.InformationButtonStatistic3Text; RepositoryPage.TapInformationButton(); //Assert finalFirstRepository = RepositoryPage.VisibleCollection.First(); finalSecondTopRepository = RepositoryPage.VisibleCollection.Skip(1).First(); finalLastRepository = RepositoryPage.VisibleCollection.Last(); if (initialFirstRepository.IsTrending == initialSecondTopRepository.IsTrending) { Assert.GreaterOrEqual(initialFirstRepository.TotalViews, initialSecondTopRepository.TotalViews); } Assert.GreaterOrEqual(initialFirstRepository.TotalViews, initialLastRepository.TotalViews); var floatingActionTextButtonStatistic1Text_Expected = StatisticsService.GetFloatingActionTextButtonText(MobileSortingService.GetSortingCategory(sortingOption), RepositoryPage.VisibleCollection, FloatingActionButtonType.Statistic1); var floatingActionTextButtonStatistic2Text_Expected = StatisticsService.GetFloatingActionTextButtonText(MobileSortingService.GetSortingCategory(sortingOption), RepositoryPage.VisibleCollection, FloatingActionButtonType.Statistic2); var floatingActionTextButtonStatistic3Text_Expected = StatisticsService.GetFloatingActionTextButtonText(MobileSortingService.GetSortingCategory(sortingOption), RepositoryPage.VisibleCollection, FloatingActionButtonType.Statistic3); Assert.AreEqual(floatingActionTextButtonStatistic1Text_Expected, floatingActionTextButtonStatistic1Text); Assert.AreEqual(floatingActionTextButtonStatistic2Text_Expected, floatingActionTextButtonStatistic2Text); Assert.AreEqual(floatingActionTextButtonStatistic3Text_Expected, floatingActionTextButtonStatistic3Text); switch (sortingOption) { case SortingOption.Views when finalFirstRepository.IsTrending == finalSecondTopRepository.IsTrending: Assert.LessOrEqual(finalFirstRepository.TotalViews, finalSecondTopRepository.TotalViews); break; case SortingOption.Views: Assert.LessOrEqual(finalSecondTopRepository.TotalViews, finalLastRepository.TotalViews); break; case SortingOption.Stars when finalFirstRepository.IsTrending == finalSecondTopRepository.IsTrending: Assert.GreaterOrEqual(finalFirstRepository.StarCount, finalSecondTopRepository.StarCount); break; case SortingOption.Stars: Assert.GreaterOrEqual(finalSecondTopRepository.StarCount, finalLastRepository.StarCount); break; case SortingOption.Forks when finalFirstRepository.IsTrending == finalSecondTopRepository.IsTrending: Assert.GreaterOrEqual(finalFirstRepository.ForkCount, finalSecondTopRepository.ForkCount); break; case SortingOption.Forks: Assert.GreaterOrEqual(finalSecondTopRepository.ForkCount, finalLastRepository.ForkCount); break; case SortingOption.Issues when finalFirstRepository.IsTrending == finalSecondTopRepository.IsTrending: Assert.GreaterOrEqual(finalFirstRepository.IssuesCount, finalSecondTopRepository.IssuesCount); break; case SortingOption.Issues: Assert.GreaterOrEqual(finalSecondTopRepository.IssuesCount, finalLastRepository.IssuesCount); break; case SortingOption.Clones when finalFirstRepository.IsTrending == finalSecondTopRepository.IsTrending: Assert.GreaterOrEqual(finalFirstRepository.TotalClones, finalSecondTopRepository.TotalClones); break; case SortingOption.Clones: Assert.GreaterOrEqual(finalSecondTopRepository.TotalClones, finalLastRepository.TotalClones); break; case SortingOption.UniqueClones when finalFirstRepository.IsTrending == finalSecondTopRepository.IsTrending: Assert.GreaterOrEqual(finalFirstRepository.TotalUniqueClones, finalSecondTopRepository.TotalUniqueClones); break; case SortingOption.UniqueClones: Assert.GreaterOrEqual(finalSecondTopRepository.TotalUniqueClones, finalLastRepository.TotalUniqueClones); break; case SortingOption.UniqueViews when finalFirstRepository.IsTrending == finalSecondTopRepository.IsTrending: Assert.GreaterOrEqual(finalFirstRepository.TotalUniqueViews, finalSecondTopRepository.TotalUniqueViews); break; case SortingOption.UniqueViews: Assert.GreaterOrEqual(finalSecondTopRepository.TotalUniqueViews, finalLastRepository.TotalUniqueViews); break; default: throw new NotSupportedException(); } ; }
public static SortingCategory GetSortingCategory(SortingOption sortingOption) => sortingOption switch {
public SortingDialog(SortingOption sortingOption) { DataContext = sortingOption; InitializeComponent(); }
public async Task VerifySortingOptions(SortingOption sortingOption) { //Arrange Repository finalTopRepository; Repository finalSecondTopRepository; Repository initialTopRepository = RepositoryPage.GetVisibleRepositoryList().First(); Repository initialSecondTopRepository = RepositoryPage.GetVisibleRepositoryList().Skip(1).First(); //Act RepositoryPage.SetSortingOption(sortingOption); //Allow RepositoryList to update await Task.Delay(1000).ConfigureAwait(false); //Assert finalTopRepository = RepositoryPage.GetVisibleRepositoryList().First(); finalSecondTopRepository = RepositoryPage.GetVisibleRepositoryList().Skip(1).First(); if (initialTopRepository.IsTrending && initialSecondTopRepository.IsTrending || !initialTopRepository.IsTrending && !initialSecondTopRepository.IsTrending) { Assert.GreaterOrEqual(initialSecondTopRepository.TotalViews, initialSecondTopRepository.TotalViews); } Assert.AreNotEqual(initialTopRepository, finalTopRepository); Assert.AreNotEqual(initialSecondTopRepository, finalSecondTopRepository); Assert.AreNotEqual(initialTopRepository, initialSecondTopRepository); Assert.AreNotEqual(finalTopRepository, finalSecondTopRepository); switch (sortingOption) { case SortingOption.Stars: Assert.GreaterOrEqual(finalTopRepository.StarCount, finalSecondTopRepository.StarCount); break; case SortingOption.Clones: Assert.GreaterOrEqual(finalTopRepository.TotalClones, finalSecondTopRepository.TotalClones); break; case SortingOption.Forks: Assert.GreaterOrEqual(finalTopRepository.ForkCount, finalSecondTopRepository.ForkCount); break; case SortingOption.Issues: Assert.GreaterOrEqual(finalTopRepository.IssuesCount, finalSecondTopRepository.IssuesCount); break; case SortingOption.UniqueClones: Assert.GreaterOrEqual(finalTopRepository.TotalUniqueClones, finalSecondTopRepository.TotalUniqueClones); break; case SortingOption.UniqueViews: Assert.GreaterOrEqual(finalTopRepository.TotalUniqueViews, finalSecondTopRepository.TotalUniqueViews); break; case SortingOption.Views: Assert.GreaterOrEqual(finalTopRepository.TotalViews, finalSecondTopRepository.TotalViews); break; case SortingOption.Trending: Assert.LessOrEqual(finalTopRepository.TotalViews, finalSecondTopRepository.TotalViews); break; default: throw new NotSupportedException(); } ; }
public static IEnumerable <TSource> Sort <TSource>(this IEnumerable <TSource> source, Comparison <TSource> comparison, SortingOption sortingOption = SortingOption.None) { foreach (var item in source.ToSortedList(comparison, sortingOption)) { yield return(item); } }
public void SetChartOptions(ChartDisplayMode mode, SortingOption sorting) { Sorting = sorting; Mode = mode; DrawChart(PathsInSortedOrder); }
public int BinarySearch(T value, int index, int count, SortingOption sortingOption = SortingOption.None) { return(InnerList.BinarySearch(index, count, t => SortComparison(t, value), sortingOption)); }
public static TList ToSortedList <TSource, TList>(this IEnumerable <TSource> source, Func <int, TList> factory, Comparison <TSource> comparison, SortingOption sortingOption = SortingOption.None) where TList : IList <TSource> { if (source == null) { throw new ArgumentNullException("source"); } if (comparison == null) { throw new ArgumentNullException("comparison"); } if (factory == null) { throw new ArgumentNullException("factory"); } int capacity = 0; ICollection <TSource> coll = source as ICollection <TSource>; if (coll != null) { capacity = coll.Count; } else { IReadOnlyCollection <TSource> roColl = source as IReadOnlyCollection <TSource>; if (roColl != null) { capacity = roColl.Count; } } TList list = factory(capacity); int index = 0; foreach (var item in source) { if (list.AddSorted(item, comparison, sortingOption) < 0) { throw new ArgumentCollectionElementException("source", "Duplicate item found.", index); } } return(list); }
public static PwrList <TSource> ToSortedPwrList <TSource>(this IEnumerable <TSource> source, Comparison <TSource> comparison, SortingOption sortingOption = SortingOption.None) { return(source.ToSortedList(capacity => new PwrList <TSource>(capacity), comparison, sortingOption)); }
public LeaderboardCommMessage(int id, long sid, SortingOption sortBy) : base(id, sid) { SortedBy = sortBy; }
public void SortRepositoriesTests(SortingOption sortingOption, bool isReversed) { //Arrange Repository topRepository, bottomRepository; List <Repository> repositoryList = new List <Repository>(); for (int i = 0; i < DemoDataConstants.RepoCount; i++) { repositoryList.Add(CreateRepository()); } //Act var sortedRepositoryList = SortingService.SortRepositories(repositoryList, sortingOption, isReversed); topRepository = sortedRepositoryList.First(); bottomRepository = sortedRepositoryList.Last(); //Assert switch (sortingOption) { case SortingOption.Clones when isReversed: Assert.Less(topRepository.TotalClones, bottomRepository.TotalClones); break; case SortingOption.Clones: Assert.Greater(topRepository.TotalClones, bottomRepository.TotalClones); break; case SortingOption.Forks when isReversed: Assert.Less(topRepository.ForkCount, bottomRepository.ForkCount); break; case SortingOption.Forks: Assert.Greater(topRepository.ForkCount, bottomRepository.ForkCount); break; case SortingOption.Issues when isReversed: Assert.Less(topRepository.IssuesCount, bottomRepository.IssuesCount); break; case SortingOption.Issues: Assert.Greater(topRepository.IssuesCount, bottomRepository.IssuesCount); break; case SortingOption.Stars when isReversed: Assert.Less(topRepository.StarCount, bottomRepository.StarCount); break; case SortingOption.Stars: Assert.Greater(topRepository.StarCount, bottomRepository.StarCount); break; case SortingOption.UniqueClones when isReversed: Assert.Less(topRepository.TotalUniqueClones, bottomRepository.TotalUniqueClones); break; case SortingOption.UniqueClones: Assert.Greater(topRepository.TotalUniqueClones, bottomRepository.TotalUniqueClones); break; case SortingOption.UniqueViews when isReversed: Assert.Less(topRepository.TotalUniqueViews, bottomRepository.TotalUniqueViews); break; case SortingOption.UniqueViews: Assert.Greater(topRepository.TotalUniqueViews, bottomRepository.TotalUniqueViews); break; case SortingOption.Views when isReversed: Assert.Less(topRepository.TotalViews, bottomRepository.TotalViews); break; case SortingOption.Views: Assert.Greater(topRepository.TotalViews, bottomRepository.TotalViews); break; default: throw new NotSupportedException(); } }
public static IEnumerable <TSource> Sort <TSource>(this IEnumerable <TSource> source, IComparer <TSource> comparer, SortingOption sortingOption = SortingOption.None) { if (comparer == null) { throw new ArgumentNullException("comparer"); } foreach (var item in source.ToSortedList(comparer.Compare, sortingOption)) { yield return(item); } }
public static IEnumerable <TSource> Sort <TSource>(this IEnumerable <TSource> source, SortingOption sortingOption = SortingOption.None) { foreach (var item in source.ToSortedList(Comparer <TSource> .Default.Compare, sortingOption)) { yield return(item); } }