11using Microsoft . VisualStudio . TestTools . UnitTesting ;
22using OfficeOpenXml ;
3- using System ;
4- using System . Collections . Generic ;
5- using System . Linq ;
6- using System . Text ;
73
84namespace EPPlusTest . FormulaParsing . Excel . Functions . RefAndLookup
95{
@@ -131,7 +127,7 @@ public void SortByColAscending_NullValues_1()
131127 Assert . AreEqual ( "Street 1" , _sheet . Cells [ "B4" ] . Value ) ;
132128 Assert . AreEqual ( "Phil" , _sheet . Cells [ "A5" ] . Value ) ;
133129 Assert . AreEqual ( "Steve" , _sheet . Cells [ "A6" ] . Value ) ;
134-
130+
135131 }
136132
137133 [ TestMethod ]
@@ -155,7 +151,31 @@ public void SortByColAscending_NullValues_2()
155151 Assert . AreEqual ( "Street 3" , _sheet . Cells [ "B4" ] . Value ) ;
156152 Assert . AreEqual ( "Steve" , _sheet . Cells [ "A5" ] . Value ) ;
157153 Assert . AreEqual ( "Bob" , _sheet . Cells [ "A6" ] . Value ) ;
154+ }
155+ [ TestMethod ]
156+ public void SortByColShould ( )
157+ {
158+ _sheet . Cells [ "A1" ] . Value = "Bob" ;
159+ _sheet . Cells [ "B1" ] . Value = "Street 2" ;
160+ _sheet . Cells [ "A2" ] . Value = "Bob" ;
161+ _sheet . Cells [ "B2" ] . Value = "Street 1" ;
162+ _sheet . Cells [ "A3" ] . Value = "Steve" ;
163+ _sheet . Cells [ "B3" ] . Value = "Street 3" ;
164+ _sheet . Cells [ "A4" ] . Value = "Bob" ;
165+ _sheet . Cells [ "B4" ] . Value = "Street 3" ;
166+ _sheet . Cells [ "A5" ] . Value = "Steve" ;
167+ _sheet . Cells [ "B5" ] . Value = "Street 4" ;
168+ _sheet . Cells [ "A6" ] . Value = "Bob" ;
169+ _sheet . Cells [ "B6" ] . Value = "Street 0" ;
158170
171+ _sheet . Cells [ "A7" ] . Formula = "SORTBY(A1:B6,A1:A6)" ;
172+ _sheet . Calculate ( ) ;
173+ Assert . AreEqual ( "Street 2" , _sheet . Cells [ "B7" ] . Value ) ;
174+ Assert . AreEqual ( "Street 1" , _sheet . Cells [ "B8" ] . Value ) ;
175+ Assert . AreEqual ( "Street 3" , _sheet . Cells [ "B9" ] . Value ) ;
176+ Assert . AreEqual ( "Street 0" , _sheet . Cells [ "B10" ] . Value ) ;
177+ Assert . AreEqual ( "Street 3" , _sheet . Cells [ "B11" ] . Value ) ;
178+ Assert . AreEqual ( "Street 4" , _sheet . Cells [ "B12" ] . Value ) ;
159179 }
160180 }
161181}
0 commit comments