public void TestEncodingWithPrefix() { Sorter <SortClass> sorter = new Sorter <SortClass>("e"); sorter.AddProperty(x => x.A, true); sorter.AddProperty(x => x.B, true); Assert.AreEqual("e.A'e.B", sorter.Encode()); sorter.SortBy(x => x.A, false).SortBy(x => x.B, false); Assert.AreEqual("e.B!'e.A!", sorter.Encode()); sorter.SortBy(x => x.A, true); Assert.AreEqual("e.A'e.B!", sorter.Encode()); }
public void TestEncoding() { Sorter <SortClass> sorter = new Sorter <SortClass>(); sorter.AddProperty(x => x.A, true); sorter.AddProperty(x => x.B, true); Assert.AreEqual("A'B", sorter.Encode()); sorter.SortBy(x => x.A, false).SortBy(x => x.B, false); Assert.AreEqual("B!'A!", sorter.Encode()); sorter.SortBy(x => x.A, true); Assert.AreEqual("A'B!", sorter.Encode()); }
public void TestEncodingWithPrefixAndTranslationDictionary() { IDictionary <Expression <Func <SortClass, object> >, string> translationDictionary = new Dictionary <Expression <Func <SortClass, object> >, string> { { s => s.A, "0" }, { s => s.B, "1" }, }; Sorter <SortClass> sorter = new Sorter <SortClass>("e", translationDictionary); sorter.AddProperty(x => x.A, true); sorter.AddProperty(x => x.B, true); Assert.AreEqual("e.0'e.1", sorter.Encode()); sorter.SortBy(x => x.A, false).SortBy(x => x.B, false); Assert.AreEqual("e.1!'e.0!", sorter.Encode()); sorter.SortBy(x => x.A, true); Assert.AreEqual("e.0'e.1!", sorter.Encode()); }