public class SortPublic Class Sorttype Sort = class endusing System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Firefly.Box;
using Firefly.Box.Testing;
namespace TestFirefly.Box.Documentation
{
[TestFixture]
public class DemoOrderBy
{
[Test]
public void UsingDefaultInstance()
{
var jobs = new Pubs.Jobs();
jobs.InitializeWithTestData();
var bp = new BusinessProcess
{
From = jobs,
};
bp.Where.Add(jobs.Id.IsLessOrEqualTo(5));
bp.OrderBy.Segments.Add(jobs.Id, SortDirection.Descending);
string result = "";
bp.ForEachRow(() =>
{
result += jobs.Id + "\n";
});
result.ShouldBe(" 5\n" +
" 4\n" +
" 3\n" +
" 2\n" +
" 1\n");
}
[Test]
public void UsingNewInstance()
{
var jobs = new Pubs.Jobs();
jobs.InitializeWithTestData();
var bp = new BusinessProcess
{
From = jobs,
};
bp.Where.Add(jobs.Id.IsLessOrEqualTo(5));
var sort = new Sort();
sort.Segments.Add(jobs.MinLevel);
sort.Segments.Add(jobs.Id, SortDirection.Descending);
bp.OrderBy = sort;
string result = "";
bp.ForEachRow(() =>
{
result += jobs.Id + " - " + jobs.MinLevel + "\n";
});
result.ShouldBe(" 1 - 10\n" +
" 5 - 150\n" +
" 4 - 175\n" +
" 3 - 175\n" +
" 2 - 200\n");
}
[Test]
public void ReverseRowOrder()
{
var jobs = new Pubs.Jobs();
jobs.InitializeWithTestData();
var bp = new BusinessProcess
{
From = jobs,
};
bp.Where.Add(jobs.Id.IsLessOrEqualTo(5));
bp.OrderBy.Segments.Add(jobs.MinLevel);
bp.OrderBy.Segments.Add(jobs.Id, SortDirection.Descending);
bp.OrderBy.Reversed = true;
string result = "";
bp.ForEachRow(() =>
{
result += jobs.Id + " - " + jobs.MinLevel + "\n";
});
result.ShouldBe(" 2 - 200\n" +
" 3 - 175\n" +
" 4 - 175\n" +
" 5 - 150\n" +
" 1 - 10\n");
}
}
}| Sort | Initializes a new instance of the Sort class. |
| Caption | Gets or sets the Sort's caption |
| Name | Gets or sets the Sort's name |
| Reversed | Gets or sets the value determining wether to reverse the order of the rows returned by the task |
| Segments | Gets the SortSortSegments |
| Unique | Gets or sets the value determining if the combination of columns represent a unique row |
| Add(ColumnBase) | Adds a columns to this Sort |
| Add(SortSegment) | Adds a segment to this Sort |
| Add(ColumnBase, SortDirection) | Adds a column to this Sort |
| Clear | |
| Clone | |
| Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
| Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object) |
| GetHashCode | Serves as the default hash function. (Inherited from Object) |
| GetType | Gets the Type of the current instance. (Inherited from Object) |
| MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object) |
| PopulateClone | |
| ToString | Returns a string that represents the current object. (Overrides ObjectToString) |