|
| 1 | +using Newtonsoft.Json.Linq; |
1 | 2 | using NUnit.Framework; |
2 | | -using System; |
| 3 | +using System.Collections.Generic; |
3 | 4 |
|
4 | 5 | namespace KalmarKommun.Datalager.Sort.Tests |
5 | 6 | { |
6 | 7 | [TestFixture] |
7 | 8 | class TestClass |
8 | 9 | { |
9 | 10 | /// <summary> |
10 | | - /// You need to run KalmarKommun.Datalager.Sort.SetPaswordsEnv.ps1 before running unit test, or some other way set environment variables e.g. with GitHub Secrets. |
| 11 | + /// Tests class SortAscendingByParsedIntThenDescendingByText. |
11 | 12 | /// </summary> |
12 | 13 | [Test] |
13 | | - public void ThreeSorts() |
| 14 | + public void TestSortAscendingByParsedIntThenDescendingByText() |
14 | 15 | { |
15 | | - var input = new Parameters |
16 | | - { |
17 | | - Message = Environment.GetEnvironmentVariable("EXAMPLE_ENVIROMENT_VARIABLE") |
18 | | - }; |
19 | 16 |
|
20 | | - var options = new Options |
| 17 | + var input = new Parameters |
21 | 18 | { |
22 | | - Amount = 3, |
23 | | - Delimiter = ", " |
| 19 | + ListToSort = JArray.FromObject( |
| 20 | + new List<Dictionary<string, string>>{ |
| 21 | + new Dictionary<string, string> { |
| 22 | + { "season", "autum-2023" }, |
| 23 | + { "month", "october" } |
| 24 | + }, |
| 25 | + new Dictionary<string, string> { |
| 26 | + { "season", "spring-2022" } |
| 27 | + }, |
| 28 | + new Dictionary<string, string> { |
| 29 | + { "season", "autum-2022" }, |
| 30 | + { "month", "november" } |
| 31 | + }, |
| 32 | + new Dictionary<string, string> { |
| 33 | + { "season", "spring-2023" } |
| 34 | + } |
| 35 | + } |
| 36 | + ), |
| 37 | + Key = JToken.FromObject("season") |
24 | 38 | }; |
25 | 39 |
|
26 | | - var ret = Sort.SortByParsedInt(input, options, new System.Threading.CancellationToken()); |
| 40 | + var ret = Sort.SortAscendingByParsedIntThenDescendingByText(input, new System.Threading.CancellationToken()); |
27 | 41 |
|
28 | | - Assert.That(ret.Replication, Is.EqualTo("foobar, foobar, foobar")); |
| 42 | + Assert.That(ret.SortedList, Is.EqualTo(JArray.FromObject( |
| 43 | + new List<Dictionary<string, string>> { |
| 44 | + new Dictionary<string, string> { |
| 45 | + { "season", "spring-2022" } |
| 46 | + }, |
| 47 | + new Dictionary<string, string> { |
| 48 | + { "season", "autum-2022" }, |
| 49 | + { "month", "november" } |
| 50 | + }, |
| 51 | + new Dictionary<string, string> { |
| 52 | + { "season", "spring-2023" } |
| 53 | + }, |
| 54 | + new Dictionary<string, string> { |
| 55 | + { "season", "autum-2023" }, |
| 56 | + { "month", "october" } |
| 57 | + } |
| 58 | + }))); |
29 | 59 | } |
30 | 60 | } |
31 | 61 | } |
0 commit comments