@@ -1569,6 +1569,26 @@ public void ReplaceCellValue_ShouldReplaceAllOccurrences(object? oldValue, objec
15691569 Assert . Equal ( differentValue , worksheet . Cells [ "D1" ] . Value ) ;
15701570 }
15711571
1572+ [ Fact ( DisplayName = "Test of the ReplaceCellValue on an existing occurrence of a DateTime value" ) ]
1573+ public void ReplaceCellValue_ShouldReplaceAllOccurrences2 ( )
1574+ {
1575+ var worksheet = new Worksheet ( ) ;
1576+ string oldValue = "oldValue" ;
1577+ worksheet . AddCell ( oldValue , 0 , 0 ) ;
1578+ worksheet . AddCell ( oldValue , 1 , 0 ) ;
1579+ worksheet . AddCell ( oldValue , 2 , 0 ) ;
1580+ worksheet . AddCell ( "differentValue" , 3 , 0 ) ;
1581+
1582+ DateTime newValue = new DateTime ( 2025 , 02 , 10 , 5 , 6 , 7 , DateTimeKind . Utc ) ;
1583+ int replacedCount = worksheet . ReplaceCellValue ( oldValue , newValue ) ;
1584+
1585+ Assert . Equal ( 3 , replacedCount ) ;
1586+ Assert . Equal ( newValue , worksheet . Cells [ "A1" ] . Value ) ;
1587+ Assert . Equal ( newValue , worksheet . Cells [ "B1" ] . Value ) ;
1588+ Assert . Equal ( newValue , worksheet . Cells [ "C1" ] . Value ) ;
1589+ Assert . Equal ( "differentValue" , worksheet . Cells [ "D1" ] . Value ) ;
1590+ }
1591+
15721592 [ Theory ( DisplayName = "Test of the ReplaceCellValue when one existing values is to replace" ) ]
15731593 [ InlineData ( "oldValue" , "newValue" , "differentValue" ) ]
15741594 [ InlineData ( "oldValue" , 23 , true ) ]
@@ -1663,7 +1683,24 @@ public void FirstCellByValue_ShouldReturnCorrectCell(object? matchingValue)
16631683 {
16641684 var worksheet = new Worksheet ( ) ;
16651685 var cell1 = new Cell ( "Test1" , CellType . STRING , "A1" ) ;
1666- var cell2 = new Cell ( matchingValue , CellType . STRING , "B1" ) ;
1686+ var cell2 = new Cell ( matchingValue , CellType . DEFAULT , "B1" ) ;
1687+ worksheet . Cells . Add ( "A1" , cell1 ) ;
1688+ worksheet . Cells . Add ( "B1" , cell2 ) ;
1689+
1690+ Cell ? result = worksheet . FirstCellByValue ( matchingValue ) ;
1691+
1692+ Assert . NotNull ( result ) ;
1693+ Assert . Equal ( matchingValue , ( ( Cell ) result ) . Value ) ;
1694+ Assert . Equal ( "B1" , result . CellAddress ) ;
1695+ }
1696+
1697+ [ Fact ( DisplayName = "Test of the FirstCellByValue when one existing values exists, on a DateTime value" ) ]
1698+ public void FirstCellByValue_ShouldReturnCorrectCell2 ( )
1699+ {
1700+ var worksheet = new Worksheet ( ) ;
1701+ var cell1 = new Cell ( "Test1" , CellType . STRING , "A1" ) ;
1702+ DateTime matchingValue = new DateTime ( 2025 , 02 , 10 , 5 , 6 , 7 , DateTimeKind . Utc ) ;
1703+ var cell2 = new Cell ( matchingValue , CellType . DATE , "B1" ) ;
16671704 worksheet . Cells . Add ( "A1" , cell1 ) ;
16681705 worksheet . Cells . Add ( "B1" , cell2 ) ;
16691706
@@ -1693,11 +1730,8 @@ public void FirstCellByValue_ShouldReturnNull_WhenValueNotFound(object? notMatch
16931730
16941731 Assert . Null ( result ) ;
16951732 }
1696-
1697-
16981733#nullable disable
16991734
1700-
17011735 [ Fact ( DisplayName = "Test of the InsertRow function" ) ]
17021736 public void TestInsertRow ( )
17031737 {
@@ -1769,12 +1803,8 @@ public void TestInsertColumn()
17691803 Assert . Null ( worksheet . Cells [ "F2" ] . CellStyle ) ;
17701804 Assert . Null ( worksheet . Cells [ "H3" ] . CellStyle ) ;
17711805 }
1772-
1773-
17741806 #endregion
17751807
1776-
1777-
17781808 public static Worksheet InitWorksheet ( Worksheet worksheet , string address , Worksheet . CellDirection direction , Style style = null )
17791809 {
17801810 if ( worksheet == null )
0 commit comments