public void ReturnSortedCollection_WhenThereAreTwoDifferentCriterias() { // Arrange var listOfItems = new List <UserTestingClass> { new UserTestingClass { Age = 10, FirstName = "Eadgar" }, new UserTestingClass { Age = 33, FirstName = "Barny" }, new UserTestingClass { Age = 5, FirstName = "Danny" }, new UserTestingClass { Age = 5, FirstName = "Connie" }, new UserTestingClass { Age = 10, FirstName = "Angel" } }; var modulesSettings = new ModulesSettings { Sorting = new List <SortingObject> { new SortingObject { Prop = "Age", Direction = SortingDirection.Asc }, new SortingObject { Prop = "FirstName", Direction = SortingDirection.Desc } } }; var sortingModule = new SortingModule(); // Act var sortedCollection = sortingModule.ApplyExpression(listOfItems, modulesSettings).ToList(); // Assert Assert.IsTrue(sortedCollection.Any()); Assert.AreEqual(5, sortedCollection.First().Age); Assert.AreEqual("Danny", sortedCollection.First().FirstName); Assert.AreEqual(10, sortedCollection[3].Age); Assert.AreEqual("Angel", sortedCollection[3].FirstName); Assert.AreEqual(33, sortedCollection.Last().Age); Assert.AreEqual("Barny", sortedCollection.Last().FirstName); }
public void ReturnsNull_WhenPassingNullSortingObjec() { // Arrange var sortingModule = new SortingModule(); var requestJson = new ComboRequestJson(); var modulesSettings = new ModulesSettings(); // Act IModulesSettings result = sortingModule.Initialize(requestJson, modulesSettings); // Assert Assert.IsNull(result.Sorting); }
public static Dictionary <string, IModule> GetModules() { modules = new Dictionary <string, IModule>(); IModule filtersModule = new FiltersModule(); IModule sortingModule = new SortingModule(); IModule paginationModule = new PaginationModule(); modules.Add(filtersModule.ModuleName, filtersModule); modules.Add(sortingModule.ModuleName, sortingModule); modules.Add(paginationModule.ModuleName, paginationModule); return(modules); }
public void ReturnSortedCollection() { // Arrange var listOfItems = new List <UserTestingClass> { new UserTestingClass { Age = 10 }, new UserTestingClass { Age = 33 }, new UserTestingClass { Age = 5 }, new UserTestingClass { Age = 55 }, new UserTestingClass { Age = 15 } }; var modulesSettings = new ModulesSettings { Sorting = new List <SortingObject> { new SortingObject { Prop = "Age", Direction = SortingDirection.Asc } } }; var sortingModule = new SortingModule(); // Act var sortedCollection = (IOrderedEnumerable <UserTestingClass>)sortingModule.ApplyExpression(listOfItems, modulesSettings); // Assert Assert.IsTrue(sortedCollection.Any()); Assert.AreEqual(5, sortedCollection.First().Age); Assert.AreEqual(55, sortedCollection.Last().Age); }
public void SetSortingObjectCorrectly() { // Arrange var sortingModule = new SortingModule(); var requestJson = new ComboRequestJson(); var modulesSettings = new ModulesSettings(); requestJson.Sorting = new List <SortingObject> { new SortingObject { Direction = SortingDirection.Asc, Prop = "Test" } }; // Act IModulesSettings result = sortingModule.Initialize(requestJson, modulesSettings); // Assert Assert.IsNotNull(result.Sorting); Assert.IsNotNull(result.Sorting[0]); Assert.AreEqual(result.Sorting[0].Direction, result.Sorting[0].Direction); Assert.AreEqual(result.Sorting[0].Prop, result.Sorting[0].Prop); }
public void SetCollection() { // Arrange var sortingModule = new SortingModule(); var listOfItems = new List <UserTestingClass> { new UserTestingClass { Id = Guid.NewGuid() } }; var resultData = new ResultData(); // Act IResultData result = sortingModule.ConstructResult(listOfItems, resultData); // Assert Assert.IsNotNull(result); var firstDataItem = result.Data as List <UserTestingClass>; Assert.AreEqual(listOfItems[0].Id, firstDataItem[0].Id); }
public void FsharpMergeSortSortTest() { var tmp = SortingModule.mergeSort(fsharpListToSort); }
public void FsharpInsertSortFoldTest() { var tmp = SortingModule.insertsortFold(fsharpListToSort); }
public void FsharpSelectSortFoldTest() { var tmp = SortingModule.selectsortFold(fsharpListToSort); }