Compare commits

..

726 Commits

Author SHA1 Message Date
Atanas Korchev
ed0f8892a8 Fix nullability errors. 2026-01-19 11:30:49 +02:00
Atanas Korchev
452e3f046c WEEKNUM function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
797fcefbc8 Extract common code. 2026-01-19 11:30:49 +02:00
Atanas Korchev
9677545c6c WEEKDAY function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
00f37c4562 HOUR, MINUTE, SECOND functions. 2026-01-19 11:30:49 +02:00
Atanas Korchev
69dfd2a672 YEAR function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
8f35d495f2 MONTH function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
e6e91e96d7 DAY function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
7b0e05069e NOW function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
425b36db7f TODAY function and date arithmetic with numbers. 2026-01-19 11:30:49 +02:00
Atanas Korchev
7e28102477 REPT function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
722ae13c00 VALUE function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
11863e2f91 LOWER function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
0b5e629f78 UPPER function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
1639325741 PROPER function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
665372b397 SUBSTITUTE function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
0d218e174f REPLACE function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
c88a4c19fe FIND function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
bb1b810c72 Use common code for wildcards. 2026-01-19 11:30:49 +02:00
Atanas Korchev
d098a6c0f1 SEARCH function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
f0edbce9c6 Refactor common parameter parsing. 2026-01-19 11:30:49 +02:00
Atanas Korchev
112f7d1b70 MID function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
cd6eba4882 RIGHT function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
b1aae0904c Add boolean literal parsing tests. 2026-01-19 11:30:49 +02:00
Atanas Korchev
019977d7e7 Unary parsing. 2026-01-19 11:30:49 +02:00
Atanas Korchev
c556e0de1a LEFT function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
8fdf1ba312 Boolean token support (TRUE, FALSE). TEXTJOIN function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
7fe4f0f96d CONCAT function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
c70efee29a TRIM function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
b1c1687c48 LEN function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
082894054b ROWS and COLUMNS function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
da19e7404b COLUMN function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
3cb7106c4f ROW function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
716a75872d CHOOSE function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
ae1c0d8ee1 INDEX function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
463db22a2e Refactor common code. 2026-01-19 11:30:49 +02:00
Atanas Korchev
f104d939a2 Add RAND and RANDBETWEEN functions. 2026-01-19 11:30:49 +02:00
Atanas Korchev
9da74fb81d Refactor common code. 2026-01-19 11:30:49 +02:00
Atanas Korchev
b694daa52e AGGREGATE function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
4fd3e3c910 SUBTOTAL function. 2026-01-19 11:30:49 +02:00
Atanas Korchev
4c619fa5c9 INT and TRUNC functions. 2026-01-19 11:30:49 +02:00
Atanas Korchev
83bf1ae2cd ROUND, ROUNDUP and ROUNDDOWN functions. 2026-01-19 11:30:48 +02:00
Atanas Korchev
f75ed5734c LARGE and SMALL functions. 2026-01-19 11:30:48 +02:00
Atanas Korchev
09f229602d MIN, MINA, MAX and MAXA functions. 2026-01-19 11:30:48 +02:00
Atanas Korchev
c8225a71bb HLOOKUP, VLOOKUP and XLOOKUP functions. 2026-01-19 11:30:48 +02:00
Atanas Korchev
1e881ddd6e Support sheet names in references. 2026-01-19 11:30:48 +02:00
Atanas Korchev
095c5d2059 Conditional formatting. 2026-01-19 11:30:48 +02:00
Atanas Korchev
019f367466 Parse unknown tokens. 2026-01-19 11:30:48 +02:00
Atanas Korchev
28918e792b Move absolute flags to CellRef. 2026-01-19 11:30:48 +02:00
Atanas Korchev
57d832549d Address aware copy and cut. 2026-01-19 11:30:48 +02:00
Atanas Korchev
7c0768fc7a Insert before the first selected item or after the last selected item. 2026-01-19 11:30:48 +02:00
Atanas Korchev
fd69705fd9 Delete multiple rows and columns. 2026-01-19 11:30:48 +02:00
Atanas Korchev
55b58a744c Add row and column command tests. 2026-01-19 11:30:48 +02:00
Atanas Korchev
e264d654c6 Column insert and delete tools. 2026-01-19 11:30:48 +02:00
Atanas Korchev
d0f00bd7f6 Add Insert Row Before tool. Refactor row tools. 2026-01-19 11:30:48 +02:00
Atanas Korchev
1a62deaf35 Add InsertRowAfter tool. 2026-01-19 11:30:48 +02:00
Atanas Korchev
7fcf4047a1 Insert row and column and tests. 2026-01-19 11:30:48 +02:00
yordanov
ac4fd8d5b3 Update premium themes 2026-01-19 11:30:48 +02:00
Atanas Korchev
48d1c87908 Improved formula handling when a cell is deleted. 2026-01-19 11:30:48 +02:00
Atanas Korchev
dd7a13f3cf DeleteRow tool. 2026-01-19 11:30:48 +02:00
Atanas Korchev
db3c81388a Delete rows and columns. Absolute references. 2026-01-19 11:30:48 +02:00
Atanas Korchev
1e6dd77759 Extract highlight component. 2026-01-19 11:30:48 +02:00
Atanas Korchev
8a81491c29 Extract FunctionHint component. 2026-01-19 11:30:48 +02:00
Atanas Korchev
86245ae162 Refactor formula parsing to accumulate errors. 2026-01-19 11:30:48 +02:00
Atanas Korchev
05b957a8d3 Display function suggestions. 2026-01-19 11:30:48 +02:00
Atanas Korchev
21828c6ae7 Formula highlight. 2026-01-19 11:30:48 +02:00
Atanas Korchev
89e91e5c0e Rename ContentEditable to SheetEditor. 2026-01-19 11:30:48 +02:00
Atanas Korchev
06c4d41273 Move matching to CellData. 2026-01-19 11:30:48 +02:00
Atanas Korchev
60cb216fbd Rename parameters. 2026-01-19 11:30:48 +02:00
Atanas Korchev
f4d916a0de Add support for SUMIF. Describe function parameters. 2026-01-19 11:30:48 +02:00
Atanas Korchev
eb54d808cf Move function tests in separate files. 2026-01-19 11:30:48 +02:00
Atanas Korchev
0565451a97 Introduce CellData. Use it for formula calculation. Unify formula behavior with Excel. 2026-01-19 11:30:48 +02:00
Atanas Korchev
8174ac2725 Remove expressions from formulas. 2026-01-19 11:30:48 +02:00
Atanas Korchev
493bd69a1e Add support for IFERROR. Support functions that accept error arguments. 2026-01-19 11:30:48 +02:00
Atanas Korchev
794d8255cf Add COUNTA function. 2026-01-19 11:30:48 +02:00
Atanas Korchev
edadfe493b Add COUNT function. 2026-01-19 11:30:48 +02:00
Atanas Korchev
c7bda57838 Add Average function. 2026-01-19 11:30:48 +02:00
Atanas Korchev
947a23a4cb Add support for the NOT function. 2026-01-19 11:30:48 +02:00
Atanas Korchev
bf30dabe4d Add Or function. 2026-01-19 11:30:48 +02:00
Atanas Korchev
c5b6b8da95 Add And function. 2026-01-19 11:30:48 +02:00
Atanas Korchev
e171252ecc Add function registry. 2026-01-19 11:30:48 +02:00
Atanas Korchev
7d090a4147 Extract function base class. 2026-01-19 11:30:48 +02:00
Atanas Korchev
bbd2cd777b IF expressions in formulas. 2026-01-19 11:30:48 +02:00
Atanas Korchev
d7bc875d83 Add keyboard shortcuts for undo and redo. 2026-01-19 11:30:48 +02:00
Atanas Korchev
ae997416a2 Double-clicking edits the right merged cell. 2026-01-19 11:30:48 +02:00
Atanas Korchev
97d94b2512 Render the menu toggle only for the last cell of a merged region. 2026-01-19 11:30:48 +02:00
Atanas Korchev
14ec0a8e4e Do not reset the editor value. 2026-01-19 11:30:48 +02:00
Atanas Korchev
985a802314 Use DialogService.Alert to display the validation message. 2026-01-19 11:30:48 +02:00
Atanas Korchev
a3b4526c33 Do not trigger unnecessary undo commands. Do not trigger blur when changing between cell and formula editor. 2026-01-19 11:30:48 +02:00
Atanas Korchev
42e595ed85 Add cell value type class. 2026-01-19 11:30:48 +02:00
Atanas Korchev
cc62ceae3b Persist column width only if different from the default. 2026-01-19 11:30:48 +02:00
Atanas Korchev
1d0e748c91 Save the row height only if different from the default. 2026-01-19 11:30:48 +02:00
Atanas Korchev
b70a6cba99 Save the worksheets to a worksheets directory. 2026-01-19 11:30:48 +02:00
Atanas Korchev
cb469e97c5 Refactor LoadFromStream. 2026-01-19 11:30:48 +02:00
Atanas Korchev
0ebc789de0 Split SaveToStream in multiple methods. 2026-01-19 11:30:48 +02:00
Atanas Korchev
299f565d66 Export and import filters. 2026-01-19 11:30:48 +02:00
Atanas Korchev
8dd6aba59c Refactor the filter criterions. 2026-01-19 11:30:48 +02:00
Atanas Korchev
ebf0e4fadf Restore the spreadsheet filter dialog from the current filter. 2026-01-19 11:30:48 +02:00
Atanas Korchev
2e1aeffbf8 Filter dialog. 2026-01-19 11:30:48 +02:00
Atanas Korchev
0a83fee55d Move the filter tool to Data tab. 2026-01-19 11:30:48 +02:00
Atanas Korchev
5a89117c6f Remove filter menu item. 2026-01-19 11:30:48 +02:00
Atanas Korchev
eb0e96ea42 Do not render merged cells that are hidden. 2026-01-19 11:30:48 +02:00
Atanas Korchev
a9f38fa9e9 Mask position fixes. 2026-01-19 11:30:48 +02:00
Atanas Korchev
b680633b5c Add filtering tests. 2026-01-19 11:30:48 +02:00
Atanas Korchev
ff5ce9298a Add numeric filter criterions. 2026-01-19 11:30:48 +02:00
Atanas Korchev
2b4bf2aef4 Rename DataTable to Table. 2026-01-19 11:30:48 +02:00
Atanas Korchev
fd59a1a1be Do not display the formula in the filter menu. 2026-01-19 11:30:48 +02:00
Atanas Korchev
3ff93dd0e6 Sort auto filter. 2026-01-19 11:30:48 +02:00
Atanas Korchev
b8edfad166 Sorting is undoable. 2026-01-19 11:30:48 +02:00
Atanas Korchev
6aaf42d883 CellMenu selected value state is no longer stale. 2026-01-19 11:30:48 +02:00
Atanas Korchev
9306c6f6d7 Undo filtering. 2026-01-19 11:30:48 +02:00
Atanas Korchev
1ddc854da9 RadzenSpreadsheet does the filtering. 2026-01-19 11:30:48 +02:00
Atanas Korchev
ae5c48f5e5 Use the AutoFilter range to get the filter values. 2026-01-19 11:30:48 +02:00
Atanas Korchev
e47848bf5a Add filter tool. 2026-01-19 11:30:48 +02:00
Atanas Korchev
e09002fa43 Refactor tables. Add AutoFilter. 2026-01-19 11:30:48 +02:00
Atanas Korchev
eb817de8e4 Simplify spreadsheet configuration. 2026-01-19 11:30:48 +02:00
Atanas Korchev
b2bc210eca Close the menu after sorting. 2026-01-19 11:30:48 +02:00
Atanas Korchev
da230e0cbe Styling improvements of the cell menu. 2026-01-19 11:30:48 +02:00
Atanas Korchev
ffae640c3f Disable the apply button when no value is selected. 2026-01-19 11:30:48 +02:00
Atanas Korchev
9f3e0d6098 Add show all and blank options. 2026-01-19 11:30:48 +02:00
Atanas Korchev
4078927d58 Filtering. 2026-01-19 11:30:48 +02:00
Atanas Korchev
c7994e0479 Add InList and Null filter. 2026-01-19 11:30:48 +02:00
Atanas Korchev
26c87de08c Bring back text align and vertical align tools. 2026-01-19 11:30:48 +02:00
Atanas Korchev
0b938dd51c Render cell popup chevron. 2026-01-19 11:30:48 +02:00
Atanas Korchev
8427d8688b Export cell sizes. 2026-01-19 11:30:48 +02:00
Atanas Korchev
9f198cbd23 Add more freeze options. 2026-01-19 11:30:47 +02:00
Atanas Korchev
a97e378800 Persist and load frozen state to XLSX. 2026-01-19 11:30:47 +02:00
Atanas Korchev
790f13ef2b Freeze tool. 2026-01-19 11:30:47 +02:00
Atanas Korchev
179d59c195 Use pointer events. 2026-01-19 11:30:47 +02:00
Atanas Korchev
87bdc2f859 Row resize. 2026-01-19 11:30:47 +02:00
Atanas Korchev
d75cf817c4 Column resizing. 2026-01-19 11:30:47 +02:00
Atanas Korchev
ca0806d5b1 Vertical align tool. 2026-01-19 11:30:47 +02:00
Atanas Korchev
3318386fe6 Remove justify align as Excel does not support it. 2026-01-19 11:30:47 +02:00
Atanas Korchev
44a835cfe8 Add text align tool. 2026-01-19 11:30:47 +02:00
Atanas Korchev
81b28b9602 Export bold, italic and underline. 2026-01-19 11:30:47 +02:00
Atanas Korchev
dc8ea54c91 Add Bold, Italic and Underline. 2026-01-19 11:30:47 +02:00
Atanas Korchev
1d40582cbd Move the tools in their own directory. 2026-01-19 11:30:47 +02:00
Atanas Korchev
e4cbcfdf74 Use command for applying the format. 2026-01-19 11:30:47 +02:00
Atanas Korchev
7ab385e552 Add background color tool. 2026-01-19 11:30:47 +02:00
Atanas Korchev
9b713a7f38 Add color button. 2026-01-19 11:30:47 +02:00
Atanas Korchev
11400e3690 Add RedoButton. 2026-01-19 11:30:47 +02:00
Atanas Korchev
fc31bd6fc6 Add undo button. 2026-01-19 11:30:47 +02:00
Atanas Korchev
d1d9a254d7 Add save button. 2026-01-19 11:30:47 +02:00
Atanas Korchev
d79f3a887d Add built-in upload button. 2026-01-19 11:30:47 +02:00
Atanas Korchev
849ec9c91a Move spreadsheet implementation. 2026-01-19 11:30:47 +02:00
Vladimir Enchev
13afd0fddb Version updated 2026-01-19 10:43:13 +02:00
Vladimir Enchev
fa7120571d DataGrid, DataFilter and PivotDataGrid numeric filter cannot be cleared 2026-01-19 10:42:35 +02:00
Vladimir Enchev
4d4e882dcc Upload API example fixed 2026-01-19 09:39:50 +02:00
Vladimir Enchev
af8c7179d1 Pivot Grid Sorting: SortOrder="SortOrder.Descending" can break sort controls
Fix #2425
2026-01-19 09:31:31 +02:00
Vladimir Enchev
c743054184 RadzenAIChat sometimes first character not detected in chat input field
Fix #2424
2026-01-19 09:17:31 +02:00
Vladimir Enchev
935d850296 Version updated 2026-01-16 11:46:46 +02:00
Vladimir Enchev
ad6b6886f1 ToFilterString() and ToODataString() fixed for non string values 2026-01-16 09:33:21 +02:00
Maxim Becker
d5d08c89de Fix filtering in RadzenAutoComplete if Data is simple list of strings (#2422) 2026-01-16 09:22:46 +02:00
Vladimir Enchev
5a246f732e Version updated 2026-01-15 18:28:58 +02:00
Vladimir Enchev
669ad421d9 Chart 0 at beginning and end of x-axis 2026-01-15 18:28:39 +02:00
Vladimir Enchev
98e8393d14 DataGrid column UniqueID initialization fixed 2026-01-15 18:08:38 +02:00
tharreck
de8dfb7e93 Fix issue where selectedItem is not updated when value is set to null in dropdown. (#2420)
Co-authored-by: Steven Torrelle <steven.torrelle@uzgent.be>
2026-01-15 17:14:16 +02:00
Vladimir Enchev
61b32d6490 RadzenDropDown with AllowFiltering and single selection should close on ENTER 2026-01-15 09:21:08 +02:00
Vladimir Enchev
5057fb1cc8 PivotDataGrid row/col groups should respect sorting
Fix #2413
2026-01-14 16:07:14 +02:00
Vladimir Enchev
ed49dfc2fa DatePicke invalid cast with nullable DateTimeOffset 2026-01-14 13:52:29 +02:00
Vladimir Enchev
839018795c version updated 2026-01-13 14:28:29 +02:00
yordanov
c541f9d3e5 Style borders demos 2026-01-13 14:11:02 +02:00
yordanov
5e5957e4c4 Add video to borders' demos 2026-01-13 14:05:46 +02:00
yordanov
84a759267e Style Barcode demo 2026-01-13 13:48:58 +02:00
Vladimir Enchev
eb1e6fab0d Barcode added (#2416)
demo improved

various fixes

more fixes
2026-01-13 10:44:09 +02:00
Vladimir Enchev
6094953009 DataGrid drag to group or reorder restricted over grid only 2026-01-13 10:41:01 +02:00
Vladimir Enchev
b845c73ad6 DataGrid cannot group by column in some cases 2026-01-13 10:00:58 +02:00
Vladimir Enchev
2788606105 Version updated 2026-01-12 17:09:07 +02:00
Vladimir Enchev
aebf267320 Scheduler Planner/Year view: appointments missing when start month is January
Fix #2415
2026-01-12 17:08:37 +02:00
Vladimir Enchev
33896ea8db RadzenChat user is typing option added
Fix #2376
2026-01-12 10:51:11 +02:00
Vladimir Enchev
cb8699f315 RadzenTabs aria-selected accessibility issue 2026-01-12 09:50:09 +02:00
Vladimir Enchev
2a43db6560 RadzenChat always eats first key press after sending first message 2026-01-12 09:37:35 +02:00
Pavlo Iatsiuk
0ad1200870 #2406 - Allow to define Http method for Upload component (#2407)
* #2406 - Allow to define Http method for Upload component

* #2406 - Allow to define Http method for Upload component and stream raw file data

* #2406 - Allow to define Http method for Upload component
Example how to stream file

---------

Co-authored-by: Pavlo Iatsiuk <pavlo.iatsiuk@nems.eco>
2026-01-12 09:22:15 +02:00
yordanov
2debdbfd38 Update copyright year 2026-01-11 13:20:15 +02:00
tharreck
07c96bd4bd fix strange oninput behavior on textbox and textarea (server rendering) (#2410)
* use bind:get and bind:set to fix  strange behavior on input while using server rendering

* only update the Immediate textarea and textbox

---------

Co-authored-by: Steven Torrelle <steven.torrelle@uzgent.be>
2026-01-09 14:29:03 +02:00
Vladimir Enchev
704c6abe7c Version updated 2026-01-09 08:09:02 +02:00
Vladimir Enchev
e0e0e608e2 DataGrid ToFilterString() fixed
Fix #2411
2026-01-09 08:07:17 +02:00
Vladimir Enchev
40e15a0720 Symbols package fixed 2026-01-08 10:48:34 +02:00
Vladimir Enchev
d6235fd147 Version updated 2026-01-08 10:24:26 +02:00
Vladimir Enchev
c5a3a911e0 DataGrid filtering by IsNull/IsNotNull fixed 2026-01-08 10:08:54 +02:00
Vladimir Enchev
4e7a037bc5 RadzenPickList selection by ValueProperty fixed 2026-01-08 10:08:29 +02:00
Vladimir Enchev
f1c3f46ad7 RadzenPickList ValueProperty added 2026-01-08 09:22:07 +02:00
Vladimir Enchev
6c0e39da20 DataGrid filter operators should check if the property is nullable 2026-01-07 13:48:59 +02:00
Vladimir Enchev
2a9d638acf null item selection restored 2026-01-07 13:23:04 +02:00
Vladimir Enchev
426e1ba8e8 DropDownBase/ListBox/DataGridHeaderCell selection of null item fixed 2026-01-07 13:03:07 +02:00
Vladimir Enchev
1bb36ef207 demo fixed 2026-01-07 10:06:45 +02:00
Vladimir Enchev
67cde0fd59 RadzenDropDownDataGrid paging fixed 2026-01-07 09:50:50 +02:00
Vladimir Enchev
0696cd20d5 Various warnings resolved and TreatWarningsAsErrors enabled (#2409) 2026-01-07 09:29:58 +02:00
Vladimir Enchev
34fce5188f DataGrid should not call Count() more than once 2026-01-07 09:11:33 +02:00
Vladimir Enchev
273ba0381f Version updated 2026-01-06 10:45:51 +02:00
Vladimir Enchev
63a05d86e8 Nested DataGrid ContextMenu not working properly 2026-01-06 10:41:52 +02:00
Vladimir Enchev
283e115d0a Upload file cannot be reselected after removed 2026-01-06 10:08:40 +02:00
Atanas Korchev
b513ebba8e Allow HEAD requests to routable URLs. 2026-01-05 11:41:22 +02:00
Vladimir Enchev
e324cea7b9 DropDown will select item on ENTER if there is only one item 2025-12-27 16:47:01 +02:00
Vladimir Enchev
c3cda91a2d DataGrid columns visibility not saved in settings when changing PageSize 2025-12-23 10:35:49 +02:00
Vladimir Enchev
bb9f611629 ClearSearchAfterSelection does not reset filtering after reopening DropDown
Fix #2405
2025-12-23 09:57:24 +02:00
Atanas Korchev
6cc8e62b15 Update the bug report issue template to include playground snippet instructions. 2025-12-22 14:46:27 +02:00
Atanas Korchev
5a44b76adb Use unique image name to produce a new deploy every time. 2025-12-22 12:45:07 +02:00
Atanas Korchev
109d6bc617 Update deploy.yml 2025-12-22 12:22:06 +02:00
Vladimir Enchev
7249ff6107 Version updated 2025-12-22 11:38:43 +02:00
Vladimir Enchev
406830fa13 Numeric fails to accept pasted input when Min is specified
Fix #2401
2025-12-22 10:25:17 +02:00
Vladimir Enchev
a6a3278443 Single selection filtered dropdown popup does not close when selecting an item with enter key
Fix #2398
2025-12-22 09:43:17 +02:00
Atanas Korchev
9fd8531529 Using ___ or *** in markdown content causes exception in RadzenMarkdown. Fixes #2402. 2025-12-22 08:29:07 +02:00
Atanas Korchev
c687976796 Update deploy.yml 2025-12-20 06:49:59 +02:00
Atanas Korchev
ae511929f7 Keep only one container version (the latest) 2025-12-20 06:30:41 +02:00
Atanas Korchev
e78e756206 Workaround for https://github.com/dotnet/aspnetcore/issues/64693. 2025-12-19 20:46:55 +02:00
Atanas Korchev
2e9e0dac1a Update deploy.yml 2025-12-19 19:44:36 +02:00
Atanas Korchev
bff97712e2 Update deploy.yml 2025-12-19 19:29:28 +02:00
Atanas Korchev
78bc25cce0 Update deploy.yml 2025-12-19 19:17:34 +02:00
Atanas Korchev
a2e829417d Update deploy.yml 2025-12-19 18:55:44 +02:00
Atanas Korchev
9902413daf Logging. 2025-12-19 18:54:05 +02:00
Atanas Korchev
06a35f4a73 Create deploy.yml 2025-12-19 18:26:49 +02:00
Atanas Korchev
e2a46157b9 Playground (#2400)
* Playground page.

* Persist the changes.

* Add copy button.

* Style Playground

* Update Playground button in CodeViewer

* Add AntiForgery support.

* Update Save alert

* Extract common code.

* Loading tweaks.

---------

Co-authored-by: yordanov <vasil@yordanov.info>
2025-12-19 17:36:32 +02:00
Atanas Korchev
c4913a94c4 Remove duplicate anchors from the chart series demo. 2025-12-19 11:29:47 +02:00
Vladimir Enchev
d6e04c3ae8 DropDownDataGrid ContextMenuDataGrid added 2025-12-18 16:04:02 +02:00
Vladimir Enchev
5b17ef5217 Version updated 2025-12-17 16:19:05 +02:00
Anspitzen
8edeedc32c Rework paste handler and add same function to new drop handler (#2394)
* Rework paste handler and add same function to new drop handler

* Remove eventlistener on destroy

* Try restore formating of Radzen.Balzor.js

* Fix missing delegate flag on create editor from restoring formating

* Handle drop and paste with same c# EventCallback OnPaste/Paste
2025-12-17 11:34:04 +02:00
Atanas Korchev
543dbc9e50 Serve uploaded images as static assets. 2025-12-17 11:18:30 +02:00
tharreck
3710f4297b Add ExpandAll/CollapseAll button in hierarchy datagrid (#2391)
* Add ExpandAll/CollapseAll button in hierarchy datagrid

* update icons of ExpandAll/CollapseAll button

* Update naming and use default values for ExpandAllTitle and CollapseAllTitle

---------

Co-authored-by: Steven Torrelle <steven.torrelle@uzgent.be>
2025-12-17 08:44:30 +02:00
Paul Ruston
91d6ba4da8 Add another condition for overlapping appointments (#2392) 2025-12-16 13:56:18 +02:00
Atanas Korchev
fbfa3c1abe Update README.md 2025-12-16 13:50:54 +02:00
Atanas Korchev
d13d7bef0c RadzenMarkdown allows unsafe protocols in attributes - javascript: etc. 2025-12-16 13:45:54 +02:00
joriverm
510f5d7190 RadzenDropdown: correctly close popup on item selection, ignoring OpenOnFocus (#2389)
Co-authored-by: AI\jvermeyl <joris.vermeylen@uzgent.be>
2025-12-15 16:08:29 +02:00
Vladimir Enchev
595b98d4b7 DropDownDataGrid row not focused on select 2025-12-15 11:01:29 +02:00
Atanas Korchev
c696107aeb Build does not finish. 2025-12-11 18:18:16 +02:00
Atanas Korchev
632722cd7b Llms.txt fixes. 2025-12-11 17:54:58 +02:00
Atanas Korchev
60c264ea49 Remove UseStaticAssets to restore compression. 2025-12-11 17:10:19 +02:00
Vladimir Enchev
10ce92264d Version updated 2025-12-11 10:35:03 +02:00
Vladimir Enchev
2e5c7aa6bc Mask and Numeric Immediate property added
Fix #2384, #2386
2025-12-11 10:15:24 +02:00
yordanov
1e7e2c5b51 Add video to RadzenIcon demos 2025-12-11 10:08:29 +02:00
Atanas Korchev
46790ce3fe Html editor dropdown aria attributes. Closes #2385. (#2387)
* Add ARIA attributes to HtmlEditorDropdown.

* Fix spacing and font size of rz-html-editor-dropdown

---------

Co-authored-by: yordanov <vasil@yordanov.info>
2025-12-10 11:31:33 +02:00
yordanov
7bd891f8f0 Add video to RadzenText demos 2025-12-10 09:50:27 +02:00
Vladimir Enchev
1ae16acbac Fixed possible DropDown NullReferenceException
Fix #2380
2025-12-10 08:20:33 +02:00
Vladimir Enchev
2281fb7f61 DataGrid expand/collapse of items using right/left keys added 2025-12-10 08:12:10 +02:00
Vladimir Enchev
89e8db6c6e Version updated 2025-12-09 10:24:30 +02:00
Vladimir Enchev
11300692e5 DropDownBase search by key enabled when bound without TextProperty 2025-12-09 10:21:38 +02:00
Barry
a31161c6d8 Fix: TreeItem Template click does not toggle Checkbox (#2374)
* add click handler for treeviewitem when Template used with checkboxes

* change approach to expose a toggle option

* remove unused method and add select to toggle checkbox selection

* rename to toggle checked

---------

Co-authored-by: Barry Wright <ace90210ace@msn.com>
2025-12-09 09:02:38 +02:00
xsainteer
edd85f8ec0 added UseDisplayName parameter to DataGridColumn component (#2378) 2025-12-08 08:48:18 +02:00
Vladimir Enchev
0d420604dd code fixed 2025-12-05 12:03:43 +02:00
Vladimir Enchev
777f5666e2 Docker improved to avoid running demos browse problems 2025-12-05 11:59:42 +02:00
Vladimir Enchev
e7bded641f Version updated 2025-12-05 11:16:11 +02:00
Vladimir Enchev
6f0dfbe038 Fixed cannot use ?? unparenthesized within || and && expressions 2025-12-05 11:15:57 +02:00
Vladimir Enchev
0e92eeb50e UseStaticFiles() added to enable llms.txt visibility 2025-12-05 11:06:56 +02:00
Vladimir Enchev
50b6cb879a Version updated 2025-12-05 10:14:58 +02:00
Vladimir Enchev
739ebde6a8 Llmtxt generation added (#2379)
* RadzenBlazorDemos.Tools added

* GenerateLlmsTxt Condition update to Release

* GenerateLlmsTxt updated again

* code fixed

* content generation cleaned

* razor/html tags removed from example descriptions and the code is now inside codeblock

* more fixes
2025-12-05 10:14:15 +02:00
Vladimir Enchev
24ef74f16d Upload remove file throws cannot read property 'find' exception 2025-12-05 10:10:13 +02:00
Vladimir Enchev
9e0a57ca5b RadzenDropDownDataGrid ColumnResized, ColumnReordering and ColumnReordered added 2025-12-04 11:00:07 +02:00
Vladimir Enchev
feaebb6f0f Version updated 2025-12-04 10:52:15 +02:00
yordanov
9a45759414 Add rz-default-scrollbars CSS class to base themes 2025-12-04 10:49:10 +02:00
yordanov
14c5a0447b Remove Black Friday promo banner 2025-12-04 10:37:47 +02:00
yordanov
7793e03d82 Update premium themes 2025-12-03 10:27:13 +02:00
Martin Hans
f422573fcc Add resizable option to side dialog. (#2331)
* Add resizable option to side dialog.

* Fix resize bar CSS class typo and make sideDialogResizeHandleJsModule nullable

* Add tests for resizable side dialog.

* Rename element references.

* Enable nullable refernce types for RadzenDialg.razor.cs

* Resolve requested change

Move code back to RadzenDialog.razor.

* Use sideDialog.classList to gather position rather than data-dir attribute.

* Rework initSideDialogResize function.

- Take position from options.
- Take width and height from sideDialogs clientWidth and clientHeight.
- Take minWidth and minHeight from options.
- Remove superflous pointer capturing.
- Remove superflous 'dragging' class.

* Replace title and aria label string constants by properties.

* Treat resizableMinWidth and resizableMinHeight as present.

* Reformat

* Use options.resizableMinWidth/Height only

* No need to set min-width neither min-height on side dialog.

* Rename ResizableMinWidth => MinWidth, ResizableMinHeight => MinHeight.

* Rename initSideDialogResize => createSideDialogResizer.

* Add dialog resize bar css variables

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: yordanov <vasil@yordanov.info>
2025-12-03 10:22:33 +02:00
tharreck
516109ecd3 Correctly select RadzenTocItem based on scroll direction in RadzenToc (#2370)
* Select toc item based on scroll direction in TOC

* Select correct RadzenTocItem when reloading a page with anchor
cleanup code

* add debounce back into scrollhandler

---------

Co-authored-by: Torrelle Steven <steven.torrelle@uzgent.be>
2025-12-02 15:45:10 +02:00
Mason Voxland
31d32b16a5 Clicking SelectAllText in CheckBoxList will do change (#2377) 2025-12-02 11:13:16 +02:00
yordanov
435c1bd6e2 Update Black Friday promo 2025-12-01 10:56:10 +02:00
Vladimir Enchev
6d5ebf3f58 Version updated 2025-12-01 10:55:13 +02:00
Vladimir Enchev
b97036b447 Support large strings added to QRCode
Fix #2373
2025-12-01 10:51:55 +02:00
Vladimir Enchev
d7ef3cb896 Upload file not removed properly when on file delete from UI 2025-11-27 14:10:49 +02:00
Robyn Choi
2218eefa67 RadzenPivotDataGrid AddPivotAggregate exposed (#2371) 2025-11-27 08:14:10 +02:00
Vladimir Enchev
666d33d767 Version updated 2025-11-26 14:00:45 +02:00
Vladimir Enchev
3f4f83d354 PivotDataGrid filter icon popup exception after adding more fields 2025-11-26 08:35:43 +02:00
Atanas Korchev
3dea547559 Enable CSS minification for the embedded themes. 2025-11-25 18:33:46 +02:00
rklfss
0e9c6acb84 Allow Specifying the interactive SortOrder Sequence on Data Grids (#2366) 2025-11-25 15:46:23 +02:00
Vladimir Enchev
1b6881673e AI assistant messages are sent as ‘user’ instead of ‘assistant’ role. ChatMessage Role property added
Fix #2365
2025-11-25 10:17:15 +02:00
yordanov
f069b33b60 Add videos to UI fundamentals demos 2025-11-25 10:03:54 +02:00
Vladimir Enchev
c0a86e31da Version updated 2025-11-24 10:05:17 +02:00
Vladimir Enchev
7b95778efe PivotDataGrid ColumnsCollection, RowsCollection and AggregatesCollection added 2025-11-24 09:45:02 +02:00
Vladimir Enchev
ef8a102d0a DataGrid OData column Type Guid exception on set filter
Fix #2363
2025-11-24 09:18:55 +02:00
Vladimir Enchev
95448de3ed DataGrid column CloseFilter() does not work when FilterProperty has a value 2025-11-21 10:14:08 +02:00
Vladimir Enchev
0a574762c7 RadzenTocItem inherits RadzenComponentWithChildren 2025-11-18 14:10:07 +02:00
joriverm
59b1440990 RadzenTocItem: take in attributes to pass on to the list item element (#2360)
Co-authored-by: AI\jvermeyl <joris.vermeylen@uzgent.be>
2025-11-18 13:56:36 +02:00
Vladimir Enchev
98d6729d4b Version updated 2025-11-18 09:06:25 +02:00
Vladimir Enchev
135a0bbe5c RadzenPivotDataGrid AddPivotField, AddPivotColumn and AddPivotRow exposed 2025-11-18 09:05:05 +02:00
Vladimir Enchev
c3f579931d RadzenDropDownDataGrid LoadChildData event added 2025-11-18 08:57:30 +02:00
Vladimir Enchev
21c51e81d2 PagedDataBoundComponent current page not synced for top and bottom pagers
Fix #2357
2025-11-18 08:48:03 +02:00
Ali Yousefi
e6538c95ad feat: keyboard key that triggers opening the popup (#2356) 2025-11-17 15:50:59 +02:00
Vladimir Enchev
0e63e87f9b DatePicker will not populate iniitially hour and minutes when bound to TimeOnly 2025-11-14 09:49:22 +02:00
Vladimir Enchev
1e900ec775 Added XML comments to Popup public API 2025-11-14 09:30:44 +02:00
edgett
5ff30874dd Add CloseOnClickOutside parameter to Popup (#2355)
* Add CloseOnClickOutside parameter to Popup

Add a parameter called CloseOnClickOutside Popup, default is true. This maintains the current behavior. If set false, the Popup will remain open with the user click outside of it.

* Fix js function usage

Updated the parameters for the Radzen.openPopup JS function to include closeOnDocumentClick.
2025-11-14 09:27:36 +02:00
Vladimir Enchev
94550006c4 RadzenPivotDataGrid code improved 2025-11-13 15:54:11 +02:00
yordanov
202636ce72 Add BlackFriday offer 2025-11-13 13:12:12 +02:00
Vladimir Enchev
cae8c6f622 version updated 2025-11-13 10:37:42 +02:00
Vladimir Enchev
0e03c4377f PivotDataGrid set filter value should invalidate filter 2025-11-13 10:32:16 +02:00
Vladimir Enchev
7497ea1262 PivotDataGrid dynamic data support added 2025-11-13 10:19:37 +02:00
Atanas Korchev
d68bb34f6f Update getting started to include .NET 10. 2025-11-12 12:38:43 +02:00
Vladimir Enchev
732a6f4942 DataGrid sort ambiguous match found 2025-11-12 09:40:55 +02:00
Atanas Korchev
70fb896ae1 Update CI workflow to use .NET 10 2025-11-12 08:04:17 +02:00
Vladimir Enchev
034eae6722 Version updated 2025-11-11 17:50:22 +02:00
Vladimir Enchev
3472949bf0 sdk updated 2025-11-11 17:46:25 +02:00
Vladimir Enchev
c333b8ca30 Net10 support added (#2353)
* NET10 support added

* DataGrid Paging Disappears on Click in .NET Core 10.0.0 RC

Fix #2286

* various fixes

* KnownIPNetworks used instead KnownNetworks

* build fixed
2025-11-11 17:43:29 +02:00
Vladimir Enchev
17e3fbdabf version updated 2025-11-10 10:27:36 +02:00
Vladimir Enchev
30c5c9dfaf More strict GetDeclaredMethods() for FirstOrDefault(), LastOrDefault(), Cast() and Distinct()
Fix #2343
2025-11-10 09:41:06 +02:00
Vladimir Enchev
585d1ee38a DropDown ReadOnly XML description fixed 2025-11-10 09:37:02 +02:00
Vladimir Enchev
3255afb487 DialogService method CloseSideAsync made virtual
Fix #2349
2025-11-10 09:28:07 +02:00
Vladimir Enchev
9f75648b50 DropDownDataGrid exception with sorting when no columns are defined 2025-11-10 09:18:21 +02:00
yordanov
50406f8984 Update Material Icons font. Resolves #2342 2025-11-07 15:05:05 +02:00
Atanas Korchev
f24c7ebc5f Add demo showing how to use Google Fonts. 2025-11-07 13:34:18 +02:00
Vladimir Enchev
75dcecfab0 Version updated 2025-11-07 08:18:47 +02:00
Atanas Korchev
34c603ce53 Revert "Cleanup code a little (#2336)"
This reverts commit d816d841a8.
2025-11-07 07:01:16 +02:00
Vladimir Enchev
7785a73876 Version updated 2025-11-06 16:26:34 +02:00
Vladimir Enchev
cfa8f731f2 DropDown FooterTemplate added
Close #2344
2025-11-06 16:25:59 +02:00
Ondrej Bach
5ecd05c7b3 Additional parameters passed from RadzenDropDownDataGrid to RadzenDataGrid (#2347)
* Inject ServiceProvider to RadzenDataAnnotationValidator to use it within ValidationContext

* Fix ... add inject attribute

* Add pass-through parameters AllowColumnPicking, AllowColumnReorder and PageSizeOptions to DropDownDataGrid

---------

Co-authored-by: Ondrej Bach <ondrej.bach@external.drivalia.com>
2025-11-06 16:17:08 +02:00
Vladimir Enchev
4ec95c2f1c Various types extracted in separate files 2025-11-05 14:31:34 +02:00
Ondrej Bach
9e4413b02e Inject ServiceProvider to RadzenDataAnnotationValidator to use it wit… (#2339)
* Inject ServiceProvider to RadzenDataAnnotationValidator to use it within ValidationContext

* Fix ... add inject attribute

---------

Co-authored-by: Ondrej Bach <ondrej.bach@external.drivalia.com>
2025-11-04 18:43:12 +02:00
Vladimir Enchev
38d0d689b3 DataGrid CollectionFilterMode improved and added example 2025-11-04 11:38:06 +02:00
Vladimir Enchev
799c5e9e4e DataGrid column CollectionFilterMode property added
Close #2313
2025-11-04 10:27:11 +02:00
joriverm
b98dffda8f Add Immediate to Radzen Password (#2337)
Co-authored-by: AI\jvermeyl <joris.vermeylen@uzgent.be>
2025-11-03 19:08:12 +02:00
joriverm
d816d841a8 Cleanup code a little (#2336)
* TextArea/Box change tests extended

fixup copy paste fail

* Cleanup warnings about FieldIdentifier.FieldName not able to be null

its defined as a non-nullable string, and an empty string is considerd valid

---------

Co-authored-by: AI\jvermeyl <joris.vermeylen@uzgent.be>
2025-11-03 19:06:46 +02:00
Vladimir Enchev
1730e02dc3 Version updated 2025-11-02 10:19:59 +02:00
Vladimir Enchev
53737d2f3c TextArea/TextBox adding custom oninput attribute fixed 2025-11-02 10:14:55 +02:00
MVSAlex
932dc3f9f6 Fix for Dialog autofocus for HTMLEditors wrapped in RadzenFormField with Tabindex correct (#2334)
* Fix for Dialog Autofocus for HTMLEditors inside RadzenFormField

If a Dialog had an HTMLEditor which was wrapped inside of a RadzenFormField it would always get focused no matter where it is breaking the Autofocus of the first Element

* Fix for unintentionally ignored TabIndex

Made a mistake that would completely ignore the TabIndex being set to -1 and therefore still include those elements
2025-10-30 15:54:27 +02:00
Vladimir Enchev
567fdb6a36 ListBoxTests extended 2025-10-30 14:33:24 +02:00
Vladimir Enchev
3e323b929d DropDownDataGridTests extended 2025-10-30 14:26:46 +02:00
Vladimir Enchev
a53fb126ac Version updated 2025-10-30 14:00:46 +02:00
MVSAlex
ec2c17bc21 Fix for Dialog Autofocus for HTMLEditors inside RadzenFormField (#2332)
If a Dialog had an HTMLEditor which was wrapped inside of a RadzenFormField it would always get focused no matter where it is breaking the Autofocus of the first Element
2025-10-30 13:43:29 +02:00
Vladimir Enchev
3894f31c2c RadzenPivotDataGrid tests added 2025-10-30 10:04:48 +02:00
Vladimir Enchev
342b96801a RadzenTextArea/RadzenTestBox Immediate code improved 2025-10-29 16:20:04 +02:00
Vladimir Enchev
36f1dfe2e0 more tests added 2025-10-29 16:07:47 +02:00
Vladimir Enchev
f90951add1 various tests added 2025-10-29 15:24:49 +02:00
joriverm
7d65c45833 Add Support for Immediate changes in TextArea (#2329)
Co-authored-by: AI\jvermeyl <joris.vermeylen@uzgent.be>
2025-10-29 15:12:11 +02:00
joriverm
3629235a00 Cleanup RadzenStack's style compiling to not generate an extra semicolon (#2330)
Co-authored-by: AI\jvermeyl <joris.vermeylen@uzgent.be>
2025-10-29 15:10:40 +02:00
Atanas Korchev
09ff7744dc Load compilation dependencies on demand. 2025-10-28 23:30:57 +02:00
Atanas Korchev
1fa9d59634 Use specific static asset provider for the source code. 2025-10-28 21:53:07 +02:00
Atanas Korchev
ccec9dbc70 Remove UseStaticAssets as it seems to disable compression. 2025-10-28 20:51:59 +02:00
Vladimir Enchev
a49dbad913 Version updated 2025-10-28 16:17:54 +02:00
Vladimir Enchev
4f0497158b Upload cannot drag & drop files after file remove
Fix #2160
2025-10-28 14:19:10 +02:00
Vladimir Enchev
4757d158a8 Label moved to Forms 2025-10-28 10:25:46 +02:00
Vladimir Enchev
4bbd371a42 Label demos added 2025-10-27 15:31:02 +02:00
Vladimir Enchev
10b4b877de RadzenMediaQuery examples added
Fix #1755
2025-10-27 14:56:27 +02:00
Vladimir Enchev
3bd030c397 Splitter double click will toggle expand/collapse
Fix #385
2025-10-27 14:47:07 +02:00
Vladimir Enchev
7c408808c9 more descriptions added 2025-10-27 13:53:33 +02:00
Vladimir Enchev
39dcaa8fc4 demos descriptions improved 2025-10-27 12:27:25 +02:00
Vladimir Enchev
04cdd584a2 demo improved 2025-10-27 11:27:41 +02:00
Atanas Korchev
2693487f81 Move AddRadzenComponents in theme registration as RadzenTheme needs it. 2025-10-27 11:15:15 +02:00
Vladimir Enchev
d73dce8804 Components API remarks moved to summary 2025-10-27 09:22:20 +02:00
Vladimir Enchev
cf333e8c15 Version updated 2025-10-24 17:46:02 +03:00
Vladimir Enchev
5aea28611b DataGrid LoadDataArgs.Filter and LoadDataArgs.Filters represent different filters after remove filtered column by column picker
Fix #1286
2025-10-24 17:44:16 +03:00
Vladimir Enchev
c58ccf0a66 SecurityCode Doesn't work well with Android
Fix #2323
2025-10-24 17:14:51 +03:00
Vladimir Enchev
d5c870eb9d XML API improved 2025-10-24 16:28:11 +03:00
Vladimir Enchev
a41b00e0be various demos descriptions added 2025-10-24 12:32:11 +03:00
Vladimir Enchev
383ee7e577 Cascading DropDowns demo extended with additional DataGrid 2025-10-24 09:50:15 +03:00
Atanas Korchev
b3b1f887ef Enable color lists in the color picker tools of RadzenHtmlEditor. 2025-10-23 21:28:56 +03:00
yordanov
b6089f5d28 Update banners 2025-10-23 18:37:18 +03:00
yordanov
2d7d5cad39 Update subscription info 2025-10-23 15:55:52 +03:00
Vladimir Enchev
cb06833882 ContextMenu on Datagrid does not respect specificity
Fix #2325
2025-10-23 14:38:26 +03:00
Vladimir Enchev
cf3ab86cec Version updated 2025-10-23 14:22:29 +03:00
Vladimir Enchev
efd3d18484 RadzenProfileMenuItem Template property added
Fix #1754
2025-10-23 12:45:27 +03:00
Atanas Korchev
e6baaa6184 (internal) Flatten elements within <span class="rbs-text"> for improved RBS support. 2025-10-23 12:32:57 +03:00
Vladimir Enchev
81c943ecda "Update dialog properties" does not work for side dialogs.
Fix #2091
2025-10-23 12:10:38 +03:00
Vladimir Enchev
587a4f479c Screen reader is not announcing the name for the 'progress bar' control in Windows.
Fix #2184
2025-10-23 11:51:21 +03:00
Vladimir Enchev
5638152121 Wrong Pager position/displayed data on PagedDataBoundComponent after triggering Visible Parameter
Fix #2225
2025-10-23 11:39:57 +03:00
Vladimir Enchev
81fc744270 Focus not set to the RadzenDropDown with options 'AllowFiltering=true' and 'Multiple=true', when pressing Esc or TAB to close dropdown
Fix #2308
2025-10-23 11:32:51 +03:00
Vladimir Enchev
2437b9e028 more descriptions added 2025-10-23 11:18:57 +03:00
Vladimir Enchev
d148cac10e more descriptions added 2025-10-23 11:10:26 +03:00
Vladimir Enchev
af8c9e3cc3 Fixed DatePicker keyboard navigation with multiple selection 2025-10-23 10:50:29 +03:00
Vladimir Enchev
b64c71c307 various descriptions added 2025-10-23 10:39:49 +03:00
Vladimir Enchev
2d60d8fcc1 Version updated 2025-10-22 16:30:35 +03:00
Vladimir Enchev
814221997e DatePicker invalid cast error with Multiple 2025-10-22 16:30:20 +03:00
Vladimir Enchev
5e112b6f59 await removed 2025-10-22 16:03:44 +03:00
Vladimir Enchev
6b253c30b2 Version updated 2025-10-22 15:56:02 +03:00
Vladimir Enchev
b5b0c1efa7 DatePicker async void removed 2025-10-22 15:55:33 +03:00
Vladimir Enchev
5dce6f81af Version updated 2025-10-22 15:26:07 +03:00
yordanov
6ff186d7de Update premium themes 2025-10-22 15:19:55 +03:00
yordanov
801a1cab1a Update links 2025-10-22 12:54:05 +03:00
Vladimir Enchev
737539e3a8 DataGrid demo improved
Fix #2311
2025-10-22 09:17:57 +03:00
Petar Slavov
2992f868ef Added ShowFooter property to GroupDescriptor. Added ability to show group footer rows on every group lavel. Added ability to control group footer visibility from the ShowFooter property of the GroupDescriptor. (#2321) 2025-10-22 09:08:36 +03:00
yordanov
e718ef80dc Update responsive styles 2025-10-21 18:31:07 +03:00
yordanov
220a441422 Move QRCode to Data Visualization category 2025-10-21 17:21:38 +03:00
yordanov
8440eb513a Update font-sizes 2025-10-21 17:20:53 +03:00
yordanov
09004fd7db Update demos homepage and footer 2025-10-21 16:41:35 +03:00
Vladimir Enchev
e9fb2bf677 various descriptions improved 2025-10-21 14:31:42 +03:00
Vladimir Enchev
81261e2413 DatePicker Multiple property added 2025-10-21 11:44:15 +03:00
Vladimir Enchev
2c7b51dc00 DatePicker ShowHour and ShowMinutes properties added 2025-10-20 15:05:37 +03:00
Atanas Korchev
47447badc1 Remove first line from Dockerfile. 2025-10-20 11:47:05 +03:00
Vladimir Enchev
1233a2347d Version updated 2025-10-20 11:18:21 +03:00
Vladimir Enchev
b0cec6f668 RadzenQRCode component added (#2319)
* RadzenQRCode added

* RadzenQRCode render improved

* QRCode improved

* Update qrcode demos

* Reorder color pickers in qrcode demo

---------

Co-authored-by: yordanov <vasil@yordanov.info>
2025-10-20 11:09:25 +03:00
Atanas Korchev
05e25d51ec Remove trailing / from sitemap. 2025-10-19 12:14:21 +03:00
Atanas Korchev
81c27836c2 Proxy the protocol. 2025-10-19 00:06:44 +03:00
Atanas Korchev
24aa1ec1b3 Add sitemap.xml and robots.txt 2025-10-18 23:33:39 +03:00
Atanas Korchev
6c7bc84ff4 Add canonical links. 2025-10-18 21:17:20 +03:00
Bilal Korkmaz
bc1d139cca set filter datetimes according to specified DateTimeKind (#2317)
* set filter datetimes according to specified DateTimeKind

* Updated DateTimeKind implementation to avoid new parameter as per code review

---------

Co-authored-by: Bilal Korkmaz <b58korkmaz@hotmail.com>
2025-10-17 14:53:34 +03:00
Vladimir Enchev
c1afef18f3 ChatUser color not applied 2025-10-17 12:34:44 +03:00
Vladimir Enchev
f46ff6237b demos fixed 2025-10-15 14:38:34 +03:00
Atanas Korchev
fd94e8037d Add NotFound page. 2025-10-15 09:21:36 +03:00
Vladimir Enchev
b95bf75dce Filtering of collection by item property tests added 2025-10-14 14:24:27 +03:00
Vladimir Enchev
b08b3aa3b1 more filtering tests added 2025-10-14 13:26:59 +03:00
Vladimir Enchev
5ed931243e QueryableExtensionTests added 2025-10-14 11:19:32 +03:00
Vladimir Enchev
f5ab48c8af More DataGrid filtering tests added 2025-10-14 11:12:02 +03:00
Vladimir Enchev
75202f4ff8 DataGrid filtering tests added 2025-10-14 10:59:21 +03:00
Vladimir Enchev
3c679674d5 Version updated 2025-10-08 14:59:23 +03:00
yordanov
6f7921691c The total number of UI components is now over 100. 2025-10-08 10:49:35 +03:00
Vladimir Enchev
13ba136c66 DataGrid IsValid should call all EditContexts Validate() 2025-10-08 09:35:21 +03:00
Vladimir Enchev
abd80af816 DatePicker InitialViewDate change should be respected 2025-10-08 09:20:24 +03:00
Vladimir Enchev
aac927e6ea AIChatServiceOptions exposed as individual properties of RadzenAIChat 2025-10-07 10:06:21 +03:00
Atanas Korchev
f7e0d7d698 Theme changing does not work in RenderMode.InteractiveAuto. 2025-10-07 08:14:30 +03:00
Vladimir Enchev
eb633bae3a Version updated 2025-10-06 17:37:39 +03:00
Vladimir Enchev
76a0b5e3e2 PivotDataGrid expression for non string values improved 2025-10-06 17:36:39 +03:00
Vladimir Enchev
0679525905 Version updated 2025-10-06 16:17:44 +03:00
Vladimir Enchev
3396c7bca4 PivotDataGrid aggregates for nested properties fixed 2025-10-06 15:00:33 +03:00
Vladimir Enchev
5031ce3936 PivotDataGrid invalid expression with non string row values 2025-10-06 14:06:11 +03:00
Vladimir Enchev
8b774b47e2 New examples updated 2025-10-06 13:06:29 +03:00
Vladimir Enchev
f0e7a398fa version updated 2025-10-06 12:02:32 +03:00
Vladimir Enchev
72c3f23c67 Fields picking properties moved to RadzenPivotDataGrid 2025-10-06 12:02:08 +03:00
yordanov
33c01b611e Update demos 2025-10-06 10:58:35 +03:00
yordanov
7cc2e6953b Update changelog 2025-10-06 10:33:17 +03:00
yordanov
1284d4ab80 Add PivotDataGrid to demos home and update component icon 2025-10-06 10:13:28 +03:00
Vladimir Enchev
cd83f01132 Version updated 2025-10-06 10:06:18 +03:00
Vasil Yordanov
3b4480fa8b Sidebar Position and FullHeight options added (#2310)
* Add SidebarPosition and FullHeight options to RadzenSidebar and adjust layout styles accordingly

* Update RadzenLayout demos
2025-10-06 10:02:00 +03:00
Vladimir Enchev
a9f8fbbff5 code fixed 2025-10-06 09:10:18 +03:00
Vladimir Enchev
e37b055e24 DatePicker updates year/months before setting YearRange which can cause a crash
Fix #2250
2025-10-06 09:08:12 +03:00
Vladimir Enchev
8eeda0e647 RadzenAIChat MessageTemplate and EmptyTemplate added 2025-10-03 14:14:46 +03:00
Vladimir Enchev
c28b47e231 RadzenPivotDataGrid added (#2307) 2025-10-03 11:07:39 +03:00
Atanas Korchev
ab989107a5 Serve demo source from wwwroot instead of github. 2025-10-02 15:50:21 +03:00
Vladimir Enchev
268fe93dd9 code fixed 2025-10-02 15:34:57 +03:00
Vladimir Enchev
e154fb05ea RadzenChat component added (#2306)
* RadzenChat component added

* Update chat message layout

* Update participant avatars in chat header

---------

Co-authored-by: yordanov <vasil@yordanov.info>
2025-10-02 14:45:45 +03:00
Vasil Yordanov
fb14fe587b Add new RadzenFab and RadzenFabMenu components (#2305)
* Add Fab and FabMenu components

---------

Co-authored-by: Atanas Korchev <akorchev@gmail.com>
2025-10-01 15:23:52 +03:00
Vladimir Enchev
e72a17ce32 Update DropDownBase.cs
Closes #2302, Closes #2298, Closes #2304
2025-10-01 11:46:30 +03:00
Vladimir Enchev
6c11409e7e Version updated 2025-09-29 15:14:16 +03:00
Vladimir Enchev
f43db71b01 SecurityCode invalid index error on paste
Fix #2300
2025-09-29 14:40:47 +03:00
Atanas Korchev
dc3611474f Markdown anchors that contain only fragments (e.g. [link](#fragment)) navigate to the root. 2025-09-28 13:50:35 +03:00
Atanas Korchev
5c5a306f7f Optimize the drag-and-drop performance of Scheduler appointments. 2025-09-27 13:42:38 +03:00
Vladimir Enchev
024d9fb5ac Version updated 2025-09-26 07:36:01 +03:00
Vladimir Enchev
6fb480042f Revert "RadzenDataGrid throws an exception when a filter value is loaded for a sub property (#2290)"
This reverts commit 224032d0c2.
2025-09-26 07:35:34 +03:00
Vladimir Enchev
acc1f8624e Version updated 2025-09-24 16:49:33 +03:00
Atanas Korchev
0b97853a57 Enabling WCAG colors via ThemeService no longer works. Fixes #2296. 2025-09-24 16:47:14 +03:00
Vladimir Enchev
8408b55e08 Version updated 2025-09-24 16:08:17 +03:00
Atanas Korchev
e49d9f7eab Prevent FOUC in RadzenTheme (#2294)
* ThemeService.SetTheme uses JavaScript to change the theme CSS files to prevent FOUC during Blazor initial hydration.

* Update the getting started instructions.

* Initialize the theme in ThemeService from RadzenTheme.
2025-09-23 16:47:24 +03:00
yordanov
6202bd78f3 Update banners 2025-09-23 15:21:27 +03:00
Vladimir Enchev
a2a5916e09 Version updated 2025-09-23 10:05:52 +03:00
Atanas Korchev
3f52e42661 Add Reload method to RadzenSankeyDiagram. 2025-09-22 11:37:34 +03:00
IncaTechnologies
224032d0c2 RadzenDataGrid throws an exception when a filter value is loaded for a sub property (#2290)
* Add tests

* Fix load settings from json

---------

Co-authored-by: noname <noname@nomail>
2025-09-22 08:37:52 +03:00
joriverm
4dece2e58a DataBoundFormComponent: Generate FieldIdentifier if ValueChanged is given (#2291)
Co-authored-by: AI\jvermeyl <joris.vermeylen@uzgent.be>
2025-09-22 08:37:40 +03:00
Atanas Korchev
7eb85d4454 Scheduler does not use the Culture when determining the start of the week. Fixes #2293. 2025-09-20 14:19:18 +03:00
Atanas Korchev
bd750e6f97 RadzenScheduler no longer uses a private Rect class. 2025-09-20 13:31:58 +03:00
Vladimir Enchev
ee0d4d29e1 Source links fixed
Fix #2289
2025-09-16 14:09:14 +03:00
Vladimir Enchev
10d2ea7c0a Version updated 2025-09-16 13:29:53 +03:00
Vladimir Enchev
0ab76d53ec DataGrid GroupFooterTemplate wrong rendering when ShowGroupExpandColumn=false 2025-09-15 15:31:07 +03:00
Vladimir Enchev
3dea0a5f67 Chat model updated 2025-09-15 11:28:13 +03:00
Vladimir Enchev
41c2e04cfa Chat messages cleared in some cases 2025-09-15 10:29:10 +03:00
DinuRoth
d8183feb07 only use the designated fragment when pasting html into a RadzenHtmlEditor (#2285)
* only use the designated fragment when pasting html into a RadzenHtmlEditor

* fragment-extraction inlined

---------

Co-authored-by: Martin Roth <martin.roth@swisscom.com>
2025-09-15 10:10:45 +03:00
Vladimir Enchev
e49fe2bca8 Version updated 2025-09-11 10:34:12 +03:00
Vladimir Enchev
67664a2816 DataGrid CheckBoxList with OData demo updated
Fix https://github.com/radzenhq/radzen-blazor/issues/2252
2025-09-09 09:37:16 +03:00
Gincsai Gábor
eefbe00aec Fix grid settings handling for sub properties column (#2274)
* Fix loading settings when multiple colum has same Property (e.g using sub-property filtering)
Fix loaded settings type handling to handle IEnumerable column with non ValueKind.Array.
Added default value for Unique ID is not set.

Add example.

* Set shouldUpdateState too.

* Make QueryableExtension.Select public

* Change filter mode back to original on demo page.
2025-09-09 09:15:34 +03:00
Atanas Korchev
be67d5f120 JavaScript error is thrown when the user selects an image in RadzenHtmlEditor and presses the insert link tool. 2025-09-04 13:57:50 +03:00
Vladimir Enchev
fa1fe694cf version updated 2025-09-02 13:53:40 +03:00
yordanov
9f681c0c09 Add CSS variables for DataGrid alternating row backgrounds in frozen columns 2025-09-02 12:43:31 +03:00
Vladimir Enchev
18dde2849e DataGrid will look first for column UniqueID before Property when loading settings 2025-08-29 18:25:20 +03:00
Vladimir Enchev
5678774de0 PickList MoveFilteredItemsOnlyOnMoveAll added 2025-08-29 18:19:51 +03:00
Vladimir Enchev
f5370e1384 RadzenColorPicker SelectedColorChanged null exception fixed 2025-08-29 08:46:45 +03:00
Vladimir Enchev
934d7cb104 Version updated 2025-08-28 09:58:56 +03:00
Vladimir Enchev
33b201147d DynamicExtensions Where() should use ExpressionSerializer Value for Format for FilterParameters 2025-08-28 09:58:27 +03:00
yordanov
abe2006e15 RadzenDialog source link should point to DialogService as well. Resolves #2270 2025-08-27 19:25:00 +03:00
Vladimir Enchev
81b5cb386d DataGridLoadColumnFilterDataEventArgs Property setter made public 2025-08-27 08:53:44 +03:00
Vladimir Enchev
c713dd6c87 Version updated 2025-08-26 09:18:01 +03:00
Vladimir Enchev
eda5c490b7 DropDownDataGrid AllowFilteringByAllStringColumns will raise exception with IDictionary binding 2025-08-26 09:17:22 +03:00
yordanov
b6bc9e1257 Fix link to Skeleton animations example source 2025-08-25 17:50:31 +03:00
yordanov
123ffd8886 Update premium themes 2025-08-25 12:51:51 +03:00
Vladimir Enchev
9a2c09c6e8 version updated 2025-08-25 11:38:24 +03:00
Vladimir Enchev
5b5fdde9a2 Skeleton component added (#2268)
* RadzenSkeleton component added

* Update Skeleton component properties, themes, and demos

* Skeleton tests fixed

---------

Co-authored-by: yordanov <vasil@yordanov.info>
2025-08-25 11:31:34 +03:00
Vladimir Enchev
0cc50d70da Fixed RadzenPanelMenuItem will not show tooltip 2025-08-25 11:17:13 +03:00
mtboeke
c79ecddee4 Expose Responsive MaxWidth in RadzenSidebar (#2260)
* Expose ResponsiveMaxWidth

* Change property to a string to be more versatile

---------

Co-authored-by: Matt Boeke <gangolfus@hotmail.com>
2025-08-25 11:07:11 +03:00
Nopke
e929edbd53 ColorPicker: highlight selected color item (#2267) 2025-08-25 11:00:39 +03:00
Atanas Korchev
8de7a1ec70 Wrong value axis display when all values in a series are the same and negative. 2025-08-22 19:17:20 +03:00
Vladimir Enchev
0b6ae4d225 Version updated 2025-08-21 07:48:09 +03:00
yordanov
c69bb8bb2b Add MCP logo 2025-08-20 22:26:08 +03:00
yordanov
e8dda6f946 Update list of components 2025-08-20 18:21:40 +03:00
yordanov
3daebfc0c1 Update AI page layout 2025-08-20 18:09:00 +03:00
Atanas Korchev
d5fcbb97c3 Add AI page. 2025-08-20 16:47:11 +03:00
yordanov
97555e7849 FrozenColumn should have alternating rows. Resolves #2265 2025-08-20 13:43:14 +03:00
Vladimir Enchev
7eb799d2a6 DataGridLoadColumnFilterDataEventArgs Property added 2025-08-20 11:17:08 +03:00
Vladimir Enchev
d06a85a3b6 Fixed DataGrid CheckBoxFilter form id when both Property and FilterProperty are defined 2025-08-20 11:05:32 +03:00
Vladimir Enchev
f616eadccf DataGrid column AlwaysShowAllCheckBoxListData property added 2025-08-20 10:57:57 +03:00
Vladimir Enchev
b69d6c193b Fixed DataGrid endless loop in load settings with columns width 2025-08-19 16:02:57 +03:00
Josh
d12908778e RadzenDropDown/Grid: Modify bound collection in-place (#2261)
* Refactor out code that assigns and notifies for Multiple when items are Selected

* Add alternative handling to support keeping the bound collection instance unchanged. This also enables support for custom collections without default ctors, and HashSets

* Ensure ClearAll maintains collection instance, instead of setting to null

* Ensure SelectdAll uses the same new behavior

* resolve the actual type of the bound collection, in determining if to apply the ReferenceGenericCollectionAssignment

# Conflicts:
#	Radzen.Blazor/DropDownBase.cs

* fixup: Ensure non-multiple/non-collection sources are accomodated

# Conflicts:
#	Radzen.Blazor/DropDownBase.cs

* use the more tactical approach for altering the collection to match selectedItems.  This preserves ordering and will raise expected INotifyCollectionChanged events if implemented

* cleanup: naming convention
2025-08-19 07:44:31 +03:00
Vladimir Enchev
95c42f3266 Version updated 2025-08-18 10:58:09 +03:00
Vladimir Enchev
597e6de682 AIChatService HttpClient resolved runtime 2025-08-18 10:38:57 +03:00
Vladimir Enchev
406141a4f1 Injected HttpClient removed from RadzenAIChat since it's not needed 2025-08-18 10:32:28 +03:00
Ali Yousefi
0db7fe63b0 feat: make ClearFilters virtual (#2263) 2025-08-18 10:09:03 +03:00
Vladimir Enchev
e5a43ef5b6 DatePicker will not display value initially when set to midnight 2025-08-15 10:03:00 +03:00
Petar Slavov
4d9a9c9ac2 Add GetProperty that supports retrieval of interface properties. (#2255)
* Introduces a new static method `GetProperty` in the `Radzen.PropertyAccess` class to retrieve properties by name, including support for interfaces. Updates `DropDownBase.cs` to utilize this new method, enabling property retrieval for collections of interfaces in multiselect DropDowns.

* Add unit tests for property resolution in interfaces

Implemented unit tests in `PropertyAccessTests.cs` to verify
the resolution of `Description`, `Name`, and `Id` properties
from the interfaces `ISimpleInterface`, `ISimpleNestedInterface`,
and `ISimpleBaseInterface`. Defined the interfaces to support
the tests for the `GetProperty` method functionality.
2025-08-15 09:28:52 +03:00
Vladimir Enchev
3cc1f6b994 Version updated 2025-08-14 08:57:50 +03:00
Vladimir Enchev
4322361269 AIChatService added to AddRadzenComponents 2025-08-14 08:57:12 +03:00
Vladimir Enchev
44d3651aa8 chat tests fixed 2025-08-14 07:55:09 +03:00
Atanas Korchev
03423f32c8 Remove the version. 2025-08-13 20:38:23 +03:00
Atanas Korchev
bf8c950a8a Build the API reference without mono. 2025-08-13 19:12:24 +03:00
Vladimir Enchev
f16ae734cc More DocFX removed 2025-08-13 18:18:01 +03:00
Vladimir Enchev
91196dca39 DOCFX removed 2025-08-13 18:17:17 +03:00
Vladimir Enchev
ea36ff5011 update 2025-08-13 18:13:50 +03:00
Vladimir Enchev
dad418140b mono:latest updated 2025-08-13 18:11:43 +03:00
Vladimir Enchev
d5f8877768 docker updated 2025-08-13 17:54:50 +03:00
Vladimir Enchev
95f2dfa8ac docker updated 2025-08-13 17:53:10 +03:00
Vladimir Enchev
d60b14c686 various warnings fixed 2025-08-13 16:23:26 +03:00
Vladimir Enchev
fabcd7b8f4 Version updated 2025-08-13 16:16:36 +03:00
yordanov
045880c234 Update premium themes 2025-08-13 16:09:38 +03:00
Vladimir Enchev
d2071102c5 RadzenChat component added (#2254) 2025-08-13 15:37:01 +03:00
Ehab Hussein
864bc8c7f9 Add Sankey Diagram Component to Radzen Blazor (#2220)
* Add SankeyDiagram Component

---------

Co-authored-by: Atanas Korchev <akorchev@gmail.com>
Co-authored-by: yordanov <vasil@yordanov.info>
2025-08-13 15:20:06 +03:00
Nenad Kovačević
b63b861b8a Fixed a typo in IconPage.razor (#2253) 2025-08-13 13:35:58 +03:00
Vladimir Enchev
23effbb3ec Upload MaxFileCount error handling fixed 2025-08-13 09:55:42 +03:00
Vladimir Enchev
c0a87c834c all tests fixed 2025-08-13 09:29:41 +03:00
Vladimir Enchev
4d02213260 test fixed 2025-08-13 09:19:41 +03:00
Vladimir Enchev
46118964ea Added DataTable support for DataGrid 2025-08-13 09:14:59 +03:00
Vladimir Enchev
ca52c588fd Revert "feature: DataGrid Columns allow Sort and Filter when bound to Array<o… (#2233)"
This reverts commit 4503361877.
2025-08-13 08:52:41 +03:00
Vladimir Enchev
b9905e10de Revert "XML comment fixed"
This reverts commit 62cf565a09.
2025-08-13 08:52:30 +03:00
Vladimir Enchev
7ea08af177 Revert "DataGrid DataTable improved"
This reverts commit c90e3bedb1.
2025-08-13 08:52:25 +03:00
Vladimir Enchev
fa59aff6d5 RadzenDropDown ReadOnly can be bypassed with keyboard select as you type 2025-08-13 07:59:49 +03:00
Vladimir Enchev
c90e3bedb1 DataGrid DataTable improved 2025-08-12 10:39:37 +03:00
Vladimir Enchev
62cf565a09 XML comment fixed 2025-08-12 10:26:49 +03:00
EdJohnstonG9
4503361877 feature: DataGrid Columns allow Sort and Filter when bound to Array<o… (#2233)
* feature: DataGrid Columns allow Sort and Filter when bound to Array<object>[] i.e. DataRow.ItemArray[n]

* Expose Test page and fix AmbiguousMatch in test (ItemArray not Item)

* Working filters before test

* In Sorting Tests

* Filter by ChecBoxList to be done

* Better solution to filter types

* Solution for Enum in DataTable

* Tidy up and fix of Enum Null
Working Enums

* Re-enabled all data sources in tests

* Prevent display of simple filter input when fitler expects enumerable
Show correct demo code, only when merged with Master

* Fix to handle Filter lists with nullable enums
2025-08-12 10:24:53 +03:00
Vladimir Enchev
f2bc7ef3ed Version updated 2025-08-11 09:16:59 +03:00
Vladimir Enchev
f9505e42c4 Fixed DataGrid CheckBoxList Filter error when filtering ICollection property 2025-08-10 09:04:28 +03:00
GAUSS-LVS Dev
d340df758e Fixed timing problem in RadzenTreeItem OnInitializedAsync (#2246)
Fixed an issue that the order of CurrentItems could be wrong when items are expanded simultaneously.

Co-authored-by: mde <m.deppe@gauss-lvs.de>
2025-08-09 10:30:53 +03:00
Vladimir Enchev
741ecf0955 Fixed DataGrid DoesNotContains filter throws No coercion operator is defined between types ‘System.String’ and ‘System.Boolean’ 2025-08-09 10:28:33 +03:00
yordanov
90ab2e468e Preloader should have properly set opacity when the grid is loading. Resolves #2205 2025-08-08 15:01:01 +03:00
yordanov
360b9d7730 Wrong link in image URL demo. Resolves #2245 2025-08-07 18:26:12 +03:00
Vladimir Enchev
bb698dbe9d version updated 2025-08-04 08:31:12 +03:00
Vladimir Enchev
5e120a7328 DataGrid filter clear not visible, for simple FilterMode, when FilterProperty is different from Property
Fix #2237
2025-08-04 08:23:39 +03:00
Vladimir Enchev
206daba741 DataGrid simple filter should be rendered only for relevant columns 2025-08-04 08:08:33 +03:00
Mohammad Mohammadi
79e86e8b76 Improve numeric input handling for all locales (including Persian and Arabic) (#2240)
* Improve numeric input support in JS: accept all Unicode digits using `\p{Nd}`

Replaced hardcoded digit ranges with Unicode-based digit detection using `\p{Nd}‍` to ensure support for Persian, Arabic, and other locale-specific numerals.

* fix: support all Unicode digit inputs in RadzenNumeric

Replaced digit handling logic with Unicode-aware checks using `char.IsDigit` to support numeric input from any language, including Persian and Arabic.

Previously, non-ASCII digits were blocked, which caused issues for users entering Persian or Arabic numerals. This fix makes the component input-agnostic to digit origin.
2025-08-01 08:08:51 +03:00
Atanas Korchev
398c17c75a Add support for immediate changes to RadzenTextBox (enabled via Immediate=true). Closes #909. 2025-07-25 10:03:22 +03:00
Vladimir Enchev
49adc95170 Version updated 2025-07-24 10:10:15 +03:00
Dmitry Solovev
2b71bd1178 Fix IconColor in ProfileMenuItem (#2229)
Co-authored-by: Дмитрий Соловьев <dsolo@codestetic.com>
2025-07-23 10:16:49 +02:00
Frank Folsche
c53938bc0a #1761 offset when filtermenu row is active (#2223) 2025-07-16 15:26:44 +03:00
joriverm
718827d757 feature: implement disabled on panel menu items (#2222)
Co-authored-by: AI\jvermeyl <joris.vermeylen@uzgent.be>
2025-07-16 15:22:20 +03:00
Vladimir Enchev
b4c87e7e10 Role "tab" removed from a element in RadzenTabsItem 2025-07-16 11:54:52 +03:00
Vladimir Enchev
20dd0e9b2d TabsItem role set to "tab" 2025-07-16 11:53:21 +03:00
Vladimir Enchev
397e2d207e Version updated 2025-07-10 15:36:45 +03:00
Vladimir Enchev
29f7b6cb74 DropDownBase should allow filter on SPACE while still be able to select/deselect items 2025-07-10 15:33:33 +03:00
joriverm
a004b55e8c feature: make fieldidentifier settable as parameter (#2216)
Co-authored-by: AI\jvermeyl <joris.vermeylen@uzgent.be>
2025-07-10 14:48:29 +03:00
Vladimir Enchev
221d8f0697 DataGrid should set column CustomFilterExpression to null on Reset() 2025-07-10 14:36:03 +03:00
Vladimir Enchev
e7a243ab7f DataGrid LoadDataArgs.Filter should use it for instance name in case of column CustomFilterExpression 2025-07-10 14:27:45 +03:00
Vladimir Enchev
ce1ffe2070 DataGrid FilterMode.CheckBoxList crashes when selecting all items in a non string column
Fix #2213
2025-07-10 12:05:22 +03:00
Gincsai Gábor
32e2419b67 Suppott filtering List<string> like sub-property. (#2210)
* Suppott filtering List<string> like sub-property. In this case no nested property so use the collectionItemTypeParameter.

* Extend the FilterValueDemo with Awards that uses List<string> property with multiple filter.
The demo works with in memory data, but not with on backend side with Oracle database.
2025-07-09 17:59:15 +03:00
Piotr Mazur
5f7079e526 Fix type assignment in RadzenDataGrid to get the correct type (#2209)
* Add missing Type field when creating FilterDescriptors in RadzenDataGrid InvokeLoadData method

* Fix type assignment in RadzenDataGrid to get the correct type

---------

Co-authored-by: Piotr Mazur <piotr.mazur@lstsoft.com.pl>
2025-07-08 13:34:39 +03:00
Vladimir Enchev
4ffeae11e2 code fixed 2025-07-08 13:32:39 +03:00
Vladimir Enchev
7621e31d38 RadzenAutoComplete will select value on NumpadEnter 2025-07-08 11:32:29 +03:00
Gincsai Gábor
c00c751127 System.Type cannot be serialized out of the box in C# (possible security issue) (#2208)
With ignoring the Type property FilterDescriptor can be used for custom server side filtering.
2025-07-08 08:11:23 +03:00
Vladimir Enchev
a09f550b52 DataGrid double IsEmpty/IsNotEmpty filters fixed 2025-07-07 16:33:52 +03:00
Vladimir Enchev
0aeb1cfa97 Version updated 2025-07-07 14:55:49 +03:00
Piotr Mazur
46da7e45b9 Add missing Type field when creating FilterDescriptors in RadzenDataGrid InvokeLoadData method (#2207)
Co-authored-by: Piotr Mazur <piotr.mazur@lstsoft.com.pl>
2025-07-07 14:54:59 +03:00
Vladimir Enchev
83bf448bdd Add in RadzenTree with async Expand calls error 2025-07-07 10:30:14 +03:00
Atanas Korchev
5ab15fb812 Add crossorigin attribute when preloading the icon font. 2025-07-03 15:32:38 +03:00
mvoxland
0dc70f3e42 DropDownDataGrid null check to prevent error that occurs when using AllowFilteringByAllStringColumns="true" (#2201)
To replicate this bug: just add AllowFilteringByAllStringColumns="true" to the Multiple Selection example for DropDownDataGrid
2025-07-01 13:47:14 +03:00
Vladimir Enchev
5bc86a75bc DataGrid column ShowCellDataAsTooltip property added 2025-07-01 13:46:26 +03:00
Vladimir Enchev
51d3df9282 Version updated 2025-06-30 11:08:57 +03:00
Vladimir Enchev
31925ea099 DropDownBase select item as you type fixed 2025-06-28 09:22:30 +03:00
yordanov
a56e6540e8 Update premium themes 2025-06-27 11:32:34 +03:00
Cosmatevs
03bccb4cb4 DropDown, DropDownDataGrid: fix font family in filter inputs 2025-06-27 11:30:38 +03:00
yordanov
bba9b7b6ec Update Material Icons font. Resolves #2187 2025-06-26 11:47:37 +03:00
yordanov
5b8ea6e4b0 Add font-display rules 2025-06-26 11:14:41 +03:00
yordanov
91676d802c Improve ripple styles for rz-state-disabled 2025-06-25 18:54:33 +03:00
yordanov
395d343f69 Grid cell focus state should be visually distinct from selected state in Standard and Material3 themes 2025-06-25 16:36:38 +03:00
Atanas Korchev
201993ff08 RadzenTheme preloads the icon font. 2025-06-24 13:43:30 +03:00
Vladimir Enchev
f9499904f3 DataGrid simple filter menu will not show string filter operators for string columns 2025-06-24 13:26:07 +03:00
Vladimir Enchev
0a152474a2 Version updated 2025-06-23 14:39:59 +03:00
Lukas Grützmacher
8dc522e054 Function key should not trigger DropDown Change event (#2195) 2025-06-23 07:40:29 +03:00
Vladimir Enchev
eb8209d575 Missing XML comments added 2025-06-20 11:05:29 +03:00
Simon Lissack
96b3ac7435 Support deserializing unsigned integers when loading filter column values (#2190) 2025-06-20 11:00:25 +03:00
Vladimir Enchev
42d7113896 DropDownDataGrid GridLines property added 2025-06-20 07:45:17 +03:00
Vladimir Enchev
7f19786053 ContextMenu should prevent the browser context menu 2025-06-20 07:37:31 +03:00
Lee
52b121a9f4 Updating HtmlEditor methods and properties to public (#2189)
* Updating methods and properties to public, to make it easier to customise and create custom HtmlEditor buttons in your own projects.

* Putting SourceChanged back to private
2025-06-19 16:37:11 +03:00
Atanas Korchev
d191a8223e Events with zero duration are sometimes invisible in month view. 2025-06-19 15:09:52 +03:00
Vincent Schmandt
b371b43a86 fix: avoid accessing parameter view in SetParametersAsync after an async call to prevent a race condition (#2186)
* fix: avoid accessing parameter view in SetParametersAsync after an async call to prevent a race condition

Fixes: https://forum.radzen.com/t/the-parameterview-instance-can-no-longer-be-read-because-it-has-expired/18912/7
See also: https://stackoverflow.com/questions/66717054/the-parameterview-instance-can-no-longer-be-read-because-it-has-expired-paramet

* fix SetParametersAsync reordering
2025-06-18 14:35:59 +03:00
Vladimir Enchev
c243f384a5 DataGrid column filter menu not unique in case of columns with same property names 2025-06-18 14:06:16 +03:00
Vladimir Enchev
e10f8d759c Version updated 2025-06-18 11:15:21 +03:00
Vladimir Enchev
977e5b8cb6 DataGrid LoadDataArgs Filters should respect the column FilterProperty 2025-06-17 14:59:57 +03:00
yordanov
b68f95a7e7 Update main navigation 2025-06-17 10:08:37 +03:00
yordanov
e30b01de23 Update premium themes 2025-06-17 09:39:27 +03:00
Vladimir Enchev
68f87db33e DataGrid CheckBoxList filter on wrong column in some cases 2025-06-16 14:26:21 +03:00
Romaniv Volodymyr
f2bfa462a0 Fix #2167 (#2185)
Set cursor to initial for disabled RadioButtonList elements
2025-06-16 10:07:11 +03:00
yordanov
adffcf5229 RadzenLayout components should not have 100vw on mobile screens. Resolves #1956 2025-06-13 10:43:40 +03:00
yordanov
a4f37cbcfa Fix active state styles in demos navigation menu 2025-06-12 17:21:44 +03:00
Vladimir Enchev
18d8328a9c Version updated 2025-06-12 11:04:17 +03:00
Vladimir Enchev
a466578ebf ExpressionSerializer should respect the DateTime.Kind
Fix #2183
2025-06-12 11:03:51 +03:00
yordanov
c92f8833e2 Fix toc confing in home layout 2025-06-12 10:44:17 +03:00
Vladimir Enchev
2f46c58028 Enabled search on non string properties for DataGrid CheckBoxList filter
Fix #2182
2025-06-12 10:35:47 +03:00
joriverm
a1c24e346c fixes: Let all DataBoundFormComponent's expose value as the actual type that it is (#2179)
Co-authored-by: AI\jvermeyl <joris.vermeylen@uzgent.be>
2025-06-11 15:39:37 +03:00
yordanov
fb7fb62a0e Update links in main nav 2025-06-11 15:28:39 +03:00
Vladimir Enchev
7378ee1a32 Login ShowLoginButton not respected in some cases 2025-06-11 15:25:15 +03:00
yordanov
0bee5b4365 Update demos main navigation and overview layout 2025-06-11 15:23:20 +03:00
yordanov
47bfd6f539 RadzenMenu active state should be visually distinguishable 2025-06-11 15:23:20 +03:00
Erik van der Boom
1b92cb7f86 Reset select on filter (#2180)
* Add reset index on filter option

* remove unwanted spaces

* correct order
2025-06-11 09:34:31 +03:00
Vladimir Enchev
2931d47d05 AllowFilteringByWordCount default value set to 10 2025-06-09 11:12:43 +03:00
Vladimir Enchev
7668a54648 DropDownDataGrid AllowFilteringByWordCount property added 2025-06-06 10:08:03 +03:00
Vladimir Enchev
aa0aaf7c10 Version updated 2025-06-05 10:04:29 +03:00
Vladimir Enchev
4b80da96ab Shift key should not trigger DropDown Change event
Fix #2165
2025-06-05 10:03:20 +03:00
Vladimir Enchev
396fa19d7b ListBox registers two keys on focus
Fix #2172
2025-06-04 07:57:02 +03:00
Vladimir Enchev
4cd235a08e DataGrid filter menu IsEmpty/IsNotEmpty options added for string columns 2025-06-04 07:46:53 +03:00
Vladimir Enchev
edd21956c5 DateTimeWithRoundtripKind test added 2025-05-30 09:58:59 +03:00
mvoxland-MoorheadSchools
f842156253 Datetime parsing fix, stop converting to local Kind (#2171) 2025-05-30 09:44:56 +03:00
Paul Ruston
ce0ce0f229 Supply Appointment data to SchedulerSlotRenderEventArgs - #2050 (#2154)
* Supply Appointment data to SchedulerSlotRenderEventArgs

* Get appointments on demand

* Revert YearView SlotRender code to remove breaking change. Update demo
2025-05-27 10:24:37 +03:00
Vladimir Enchev
ae2e9219c3 Version updated 2025-05-27 09:14:27 +03:00
Vladimir Enchev
146b374ca8 DataGrid CheckBoxList filter not populated properly in case of self-referencing hierarchy 2025-05-27 07:54:53 +03:00
Vladimir Enchev
9264676407 Non generic IDictionary support added for expressions
Close #2169
2025-05-27 07:17:05 +03:00
Victor Ureta
eb74460fcf add icon in Title Dialog (#2170)
* add icon in Title Dialog

* fix IconColor in DialogService.cs

* fix variables
2025-05-26 18:48:47 +03:00
Vladimir Enchev
16ed582052 DataGrid column with CustomFilterExpression will not filter innitially 2025-05-23 09:26:15 +03:00
Vladimir Enchev
a7ddb81ad1 ToFilterString() should serialize only date of DateTime with zero time 2025-05-23 09:02:38 +03:00
Atanas Korchev
d09f3870b1 RadzenCompareValidator validates when the Visible property is set to true. Closes #2148. 2025-05-22 11:58:20 +03:00
Atanas Korchev
9a8e249964 RadzenScheduler throws error on window resize when placed in a hidden element. 2025-05-22 11:47:56 +03:00
Vladimir Enchev
c63d9cf0b9 DataGrid CheckBoxList filter search will work properly when binding to dynamic data 2025-05-22 09:46:06 +03:00
Vladimir Enchev
f6648f80ec Numeric null. reference exception fixed 2025-05-22 09:23:19 +03:00
Vladimir Enchev
250bff7ef3 ToCSV() export method will handle comma 2025-05-22 09:23:18 +03:00
Nopke
fa0b925aa9 TimeSpanPicker: fix missing panel fields if only Min or only Max is set (#2166) 2025-05-21 08:39:43 +03:00
Atanas Korchev
28fe2949f2 Add CloseSideAsync method to DialogService which waits for the close animation to complete. Closes #2161. 2025-05-20 11:49:50 +03:00
Vladimir Enchev
d7f46216e9 ToFilterString() and ToODataFilterString() extension methods added to IEnumerable<CompositeFilterDescriptor> 2025-05-20 11:46:24 +03:00
Vladimir Enchev
3f0d82a427 Version updated 2025-05-20 08:56:30 +03:00
yordanov
d2811c9fba Fix typo. 2025-05-16 22:20:20 +03:00
yordanov
028e26ef59 Add Accessibility Conformance Report 2025-05-16 10:19:42 +03:00
yordanov
4086332857 RadzenAccordion items should be displayed vertically in RadzenStep 2025-05-15 15:32:43 +03:00
yordanov
1eebfccf14 Remove Dialog's scale animation if it has RadzenChart inside 2025-05-15 15:03:32 +03:00
Vladimir Enchev
f1127f917d DataGrid CheckBoxList filter list not populated in some cases 2025-05-15 13:59:47 +03:00
yordanov
6cc8700bb9 Update UI blocks description 2025-05-15 10:44:16 +03:00
yordanov
3cabcd5cf9 Update info on how to use UI Blocks 2025-05-15 10:25:56 +03:00
yordanov
c5aaeb67b5 Update badges on homepage 2025-05-15 10:25:56 +03:00
Vladimir Enchev
47fcd54d1c version updated 2025-05-15 07:28:28 +03:00
Vladimir Enchev
5dd5cd8ae1 DataGrid grouping exception with wrong type discovery
Fix #2153
2025-05-15 07:28:10 +03:00
Vladimir Enchev
8ab18160a5 Demo updated to handle query that cannot be translated to SQL 2025-05-14 10:52:26 +03:00
Vladimir Enchev
b70b697f3f DataGrid column FilterProperty should be respected if specified 2025-05-14 09:18:30 +03:00
Vladimir Enchev
48eb35e20d Version updated 2025-05-13 20:57:58 +03:00
Atanas Korchev
4fd899133f Cannot parse certain expressions that include string and number comparisons. 2025-05-13 20:52:44 +03:00
Vladimir Enchev
3b134cf8b5 code fixed 2025-05-13 09:28:55 +03:00
Atanas Korchev
86bc538601 Some zero-length events appear on top of each other in month view. 2025-05-13 08:42:11 +03:00
Atanas Korchev
fb00fbc850 Add anchor for the day, week and month view demo. 2025-05-13 08:42:11 +03:00
Vladimir Enchev
309f9fcfa1 DataGrid will populate Query.Filter and LoadDataArgs.Filter only if accessed 2025-05-12 13:46:29 +03:00
Vladimir Enchev
253aa63980 Version updated 2025-05-12 13:03:28 +03:00
Vladimir Enchev
93dea13f20 Added support for indexer expressions with sub properties 2025-05-12 12:36:02 +03:00
Atanas Korchev
3d3d1718b7 Add editable source code to dashboard demo. 2025-05-12 11:00:25 +03:00
Cosmatevs
90c2a5d51f fix recognizing standard dark theme as dark by components 2025-05-12 10:34:44 +03:00
Vladimir Enchev
8846a229d8 Added support for Dictionary<string, string> for expressions 2025-05-12 09:31:12 +03:00
Pedro Constantino
acf0591adc [FEAT] - Adding the possibility to return the source in the upload event args when managing file uploads via RadzenUpload. (#2151) 2025-05-12 07:31:42 +03:00
yordanov
95bee47826 PanelMenu item expand arrow should not be displayed when child items are absent. Resolves #2147 2025-05-09 19:44:18 +03:00
Atanas Korchev
b701976356 Expanded panel menu items do not always collapse when Multiple is set to false. 2025-05-09 14:53:54 +03:00
Vladimir Enchev
2b61941e34 Version updated 2025-05-08 17:24:08 +03:00
yordanov
1526ffa3af Update premium themes 2025-05-08 17:19:02 +03:00
Cosmatevs
bb4227e537 fix the bottom border color of a hovered/focused input field in Standard themes 2025-05-08 17:08:01 +03:00
Vladimir Enchev
778691405d version updated 2025-05-08 15:04:17 +03:00
Atanas Korchev
cb7d3b91c6 Add Template property to RadzenTocItem. 2025-05-08 15:01:53 +03:00
Atanas Korchev
fd8cf16336 NullReferenceException thrown by RadzenLayout when AddRadzenComponents is not used. 2025-05-08 14:54:33 +03:00
yordanov
2403cf222f Add TOC to demos homepage 2025-05-08 14:39:31 +03:00
yordanov
20152dd8a6 Fix duration progress position in Notification. Resolves #2104 2025-05-08 11:47:42 +03:00
Vladimir Enchev
b459207b7a Links inside popup should close the popup only on left mouse button click 2025-05-08 07:48:44 +03:00
Atanas Korchev
8b009509c8 Add accordion breaking change to changelog. 2025-05-07 20:13:29 +03:00
Atanas Korchev
c456891a11 Convert to the left operand type if the right type is object during null coalescing. 2025-05-07 15:25:34 +03:00
yordanov
6b044d8086 Update demos' badges 2025-05-07 14:53:07 +03:00
Atanas Korchev
3162de84ed Update the busy dialog demo. 2025-05-07 14:32:20 +03:00
Atanas Korchev
641768240a Update the changelog. 2025-05-07 14:07:30 +03:00
Vladimir Enchev
8b7ade4b9c Version updated 2025-05-07 13:14:37 +03:00
Vladimir Enchev
c7db9394c8 V7 (#2144)
* Remove Microsoft.CodeAnalysis. Add own C# expression parser.

* Popup dialog animations (#2118)

* Experiment with popup and dialog animations.

* Move animations to a separate _animations.scss

* Remove dialog closing animation.

* Support side dialog positions. Prefix keyframes.

* Use --rz-transition for animation function and duration

* Reset site.css.

* PanelMenu animations.

* Display none is toggled a bit late.

* RadzenPanel animations.

* More animations.

* Use transitions for panel menu.

* Remove old code.

* Accordion uses transitions.

* Panel uses transitions.

* Extract expand and collapse implementation in a separate component.

* Set initial expand state earlier to prevent two renders.

* Add open animation to notifications.

* Handle onanimationend before toggling the animation classes.

* Add menu animation.

* Experiment with tree animation.

* Add animations to fieldset.

---------

Co-authored-by: yordanov <vasil@yordanov.info>

* ExpressionSerializer and tests added (#2119)

* Fix failing tests.

* various components RequiresUnreferencedCode attribute added (#2120)

* RequiresUnreferencedCode added to ExpressionSerializer

* Update premium themes

* RequiresUnreferencedCode added to ExpressionParser

* FormComponentWithAutoComplete RequiresUnreferencedCode removed

* Revert "FormComponentWithAutoComplete RequiresUnreferencedCode removed"

This reverts commit ec900a4df8.

* Revert "RequiresUnreferencedCode added to ExpressionParser"

This reverts commit f93b3b159b.

* Revert "RequiresUnreferencedCode added to ExpressionSerializer"

This reverts commit 06fecec9a6.

* Revert "various components RequiresUnreferencedCode attribute added (#2120)"

This reverts commit 2ed1a6cac1.

* Remove RadzenHtml.

* ExpressionSerializer FormatValue updated to use InvariantCulture

* Catch potential JS interop exceptions that could occur during disposing.

* Revert "Remove RadzenHtml."

This reverts commit 319085bf49.

* SelectBar made single tab stop

* RadioButtonList and CheckBoxList made single tab stop

* SelectBar accessibility improved

* RadioButtonList accessibility improved

* CheckBoxList accessibility improved

* Update radio button focus styles

* Update checkbox list focus styles

* Update Checkbox Radio and SelectBar focus styles

* SelectBar, CheckBoxList and RadioButtonList focus state improved

* Check for Multiple added

* Use non-rendering event handlers for transitionend.

* Rename css class rz-selectbutton to rz-selectbar and improve focus states

* Fix selectbar focus outline offset

* Update premium themes

* Selectbar item focus styles should not be visible if the item is disabled.

* CheckBoxList and RadioButtonList item focus should be visible only on keyboard input

* SelectBar, CheckBoxList and RadioButtonList focus logic improved

* Update animations

* RadzenText margin-block should be 0 if it is in RadzenStack. Resolves #2134

* RadzenText margin-block should be 0 if it is first level child in RadzenStack

* CheckBoxList focused fixed

* Add toggle state classes to panel menu icon.

* Update accordion styles to reflect expander changes

* Add animation styles to expand arrow in Menu and ProfileMenu

* Use a instead of NavLink as it seems to cause performance issues.

* Set @bind-Expanded.

* Revert "Set @bind-Expanded."

This reverts commit 994107367bdf09043950f8bbe701eb9edefec676.

* Revert "Use a instead of NavLink as it seems to cause performance issues."

This reverts commit 05d5bef8f421bbeb5828ba1e9c5af6793ea3d32a.

* Reduce rendering of panel menu items.

* Add panel menu component.

* Use ChildContent to render the toggle icon of the panel menu item.

* Sync panel menu item selection in the item itself.

* Rename ExpandedInternal to expanded.

* Move filtering to the panel menu component.

* Remove the transitionend handler to avoid a second rendering pass.

* Build the assets for the net9.0 framework.

* Do not trigger render when Click is used.

* Panel menu keyboard navigation renders only when needed.

* Focus reworked to use AsNonRenderingEventHandler

* Focus the first item.

* Update Panel demo

* Use a more robust algorithm for month view event rendering that handles overlapping of events across a week.

* Use RadzenStack in RadioButtonList

* Add parsing support for `&` and `|`.

* Add parsing support for `^`, `>>` and `<<`.

* Simplify expression parsing tests.

* Use RadzenStack in RadioButtonList and CheckBoxList

* Change defaults for AlignItems and JustifyContent in RadioButtonList and CheckBoxList

* Update RadioButtonList and CheckBoxList demos

* Add --rz-input-border-block-end css variables to improve Fluent theme styles

* Removed AsNonRenderingEventHandler from RadioButtonList and HtmlEditor focus and blur

* Removed AsNonRenderingEventHandler from CheckBoxList

* Simplify RadzenTable rendering.

* Optimize memory usage of the ClassList utility.

* Refactor RadzenButton to use ClassList.

* RadzenSelectBar and RadzenSplitButton use ClassList.

* Refactor RadzenBadge and RadzenAlert to use ClassList.

* Refactor RadzenCard and RadzenFormField to use ClassList.

* Refactor RadzenCardGroup and progress components to use ClassList.

* Refactor RadzenMenu to use ClassList.

* Use ClassList in RadzenBody, RadzenLayout and editor rendering components.

* RadzenDialog uses ClassList.

* RadzenDataGrid uses ClassList.

* RadzenPager uses ClassList.

* RadzenColumn uses ClassList.

* Fix RadzenSplitButtonItem focused state.

---------

Co-authored-by: Atanas Korchev <akorchev@gmail.com>
Co-authored-by: Atanas Korchev <454726+akorchev@users.noreply.github.com>
Co-authored-by: yordanov <vasil@yordanov.info>
Co-authored-by: Quentin H <67709967+quintushr@users.noreply.github.com>
2025-05-07 13:11:30 +03:00
yordanov
513e63329b Fix RadzenSplitButtonItem focused state. Resolves #2137 2025-05-05 16:36:54 +03:00
amir7800h
cfd104385d Update RadzenDatePicker.razor.cs (#2140)
When setting the project culture (e.g., to fa-IR), the year was still being displayed using the Gregorian calendar, which caused incorrect date representation in the UI.
This fix ensures that the DateTimeFormat.Calendar is properly respected, and now the year is displayed correctly based on the assigned calendar (e.g., PersianCalendar).

Before
Culture set to fa-IR

Year displayed as Gregorian (e.g., 2025 instead of 1404)

After
Year display matches the Calendar set in DateTimeFormat

Fully localized and culture-respecting date output
2025-05-05 08:09:59 +03:00
Atanas Korchev
2d9641eecf Toc preserves query string parameters. 2025-05-03 15:18:09 +03:00
Vladimir Enchev
65a78125b2 DropDownBase select item as you type fixed 2025-04-30 11:45:09 +03:00
Vladimir Enchev
28572ba4d3 version updated 2025-04-29 18:06:24 +03:00
Vladimir Enchev
28a603ca1e Dynamic Where() with parameters fixed 2025-04-29 18:06:11 +03:00
Frank
b9fa303f7f NotifyValidationStateChanged() / StateHasChanged() is only be executed if the IsValid field has actually changed. (#2127) 2025-04-28 11:14:11 +03:00
Vladimir Enchev
756dde90ab DataGrid will allow combining advanced and simple filtering for different columns
Close #2128
2025-04-25 11:40:59 +03:00
Vladimir Enchev
c2a396167e DataGrid advanced filter clear fixed 2025-04-24 16:34:23 +03:00
Vladimir Enchev
c1fd207723 Version updated 2025-04-24 13:05:03 +03:00
Vladimir Enchev
8f1fc0a164 Revert "QueryableExtension OrderBy() should not use ExpressionParser"
This reverts commit a389dc702b.
2025-04-24 13:04:31 +03:00
Evan Dixon
538ec3c744 Make OnChipRemove overridable (#2122)
Co-authored-by: Dixon, Evan <edixon@mimeo.com>
2025-04-24 08:43:47 +03:00
Victor Ureta
6fed13bf12 Add TextTemplate parameter to RadzenFormField Blazor component (#2123)
* Update RadzenFormField.razor

* Update RadzenFormField.razor.cs
2025-04-24 08:25:02 +03:00
Vladimir Enchev
104cc7c900 Version updated 2025-04-23 10:00:49 +03:00
Reinhard
8fa699a92e Fixing 1st column with sub-row expander visible not taking column.IsInEditMode callback into account for rendering edit template. (#2097) 2025-04-23 09:06:24 +03:00
Quasmo
1ab7059830 Added DisplayToolTipFor Method to RadzenChart.razor.cs. (#2115)
* Added DisplayToolTipFor Method to RadzenChart.razor.cs. Made Series property public.

* Chnaged Series public accessor back to internal. Added GetSeries Method that returns an IReadOnlyList of the Series. Added XML documentation. Made changes to DisplayTooltipFor Method. Removed null checks and try/catch block.

* removed unnessecary usings.

---------

Co-authored-by: John Tolliver <jtolliver@wbrsllc.com>
2025-04-23 07:44:50 +03:00
Greg Horvath
377b2613db Fixes bug #2113. (#2114) 2025-04-23 07:18:00 +03:00
Atanas Korchev
bc7b0a9bdb Take axis label rotation into account when measuring the category axis size. 2025-04-22 10:36:09 +03:00
Krystian Szatan
8665a351db Update RadzenSplitButton (#2103)
Added ButtonType parameter to allow EditForm submit
2025-04-18 11:29:44 +03:00
Vladimir Enchev
dd02bf8b8d Notification demo reworked with toc 2025-04-16 11:31:03 +03:00
Vladimir Enchev
487c423eef Version updated 2025-04-15 18:20:24 +03:00
Atanas Korchev
87bcfa729c RadzenMarkdown renders HTML attributes incorrectly. 2025-04-15 18:18:50 +03:00
yordanov
0332e8c671 Fix anchors on Accordion demo page 2025-04-15 15:56:37 +03:00
Atanas Korchev
7264354ce6 Soft line breaks are not rendered and strip whitespace. Fixes #2095. 2025-04-15 13:14:05 +03:00
Vladimir Enchev
bde3315994 Version updated again 2025-04-15 12:59:24 +03:00
Vladimir Enchev
7ecd08b0d8 Version raised 2025-04-15 12:58:01 +03:00
Vladimir Enchev
93feb382ca Version updated 2025-04-15 12:56:35 +03:00
yordanov
186d9b3798 Update toc demos 2025-04-15 12:27:23 +03:00
yordanov
1f3e44819d Remove selected rz-toc-item font-weight and fix width of rz-toc-link 2025-04-15 12:06:33 +03:00
Atanas Korchev
4b942f2f45 Add toc to the upload demo. 2025-04-15 11:46:29 +03:00
Vasil Yordanov
7214cd7179 Add RadzenToc component (#2094)
RadzenToc component is a table of contents based on the titles in a page allowing users to quickly navigate the page.

---------

Co-authored-by: Atanas Korchev <akorchev@gmail.com>
2025-04-15 11:14:38 +03:00
Vladimir Enchev
90c11b5c04 Version updated 2025-04-14 11:39:59 +03:00
Atanas Korchev
4007339d26 Sanitize link and image destination. 2025-04-14 11:37:18 +03:00
yordanov
8bc43443a7 Fix contrast with new styles for active filter in DataGrid's simple filter modes. Resolves #2090 2025-04-14 10:26:52 +03:00
Vladimir Enchev
a389dc702b QueryableExtension OrderBy() should not use ExpressionParser 2025-04-14 09:33:02 +03:00
Nopke
1b39fa37e0 TimeSpanPicker: fix not using last changed input value, disable autocomplete (#2089)
* TimeSpanPicker:
* fix occasionally not using last changed input value after clicking the confirmation button,
* disable autocomplete in unit fields

* TimeSpanPicker:
* store last field input and try to parse it only if needed
2025-04-14 09:03:41 +03:00
Atanas Korchev
bfa18f72fa Sanitize HTML content in RadzenMarkdown. Expose a property to disable html content (AllowHtml) and also provide means to provide a custom list of allowed HTML tags and attributes. 2025-04-13 15:58:20 +03:00
Vladimir Enchev
82c2ec0c43 Version updated 2025-04-11 10:00:14 +03:00
Pedro Constantino
3810d088b5 [FEAT] - Add Fill property to RadzenSeriesDataLabels for customizing text color, default behavior is preserved when Fill is not specified. (#2086)
Co-authored-by: Pedro Constantino <pedro.constantino@enerwatt.com.br>
2025-04-11 09:38:43 +03:00
yordanov
7b34b096fe Update premium themes 2025-04-11 08:47:20 +03:00
leon42
831b0bd2d1 Added a ShowInput property to RadzenDatePicker to allow only the button to be shown. See the demo for an example. (#2085)
Added demos for ShowInput and ShowDateBox options.

Co-authored-by: Noel <noel.s@ivoterguide.com>
2025-04-11 08:23:30 +03:00
Vladimir Enchev
5875057282 Fixed Tabs component re-rendered on every focus
Close #2087
2025-04-11 07:56:27 +03:00
Vladimir Enchev
b78df8df2a Fix Ctrl / Alt navigate in DropDownList
Fix #2084
2025-04-10 14:21:47 +03:00
Vladimir Enchev
7fa3d08e61 DataGrid expand/collapse column headers accessibility error fixed 2025-04-10 11:00:00 +03:00
Vladimir Enchev
549303a34c code improved 2025-04-10 09:50:19 +03:00
Vladimir Enchev
9d2cbae115 DropDownBase should not try to handle keypress when not bound 2025-04-09 18:57:55 +03:00
Vladimir Enchev
d1a76922c5 Version updated 2025-04-09 12:23:00 +03:00
yordanov
648889d2d2 Accordion header icon styles should not propagate accross other icons. Resolves #2081 2025-04-09 10:26:51 +03:00
Vladimir Enchev
984e566fe2 RadzenLink cannot be clicked in Popup
Fix #2083
2025-04-09 10:12:30 +03:00
Atanas Korchev
145296ee10 RadzenTheme no longer requires PersistentComponentState but uses it if available. 2025-04-09 10:03:21 +03:00
yordanov
91b91ca96f Add RealEstate app template 2025-04-09 09:46:11 +03:00
Atanas Korchev
5ea1e9d6d5 PagingSummaryFormat does not apply to the bottom pager in RadzenDataGrid. 2025-04-09 09:23:41 +03:00
Vladimir Enchev
78f83fe103 Version updated 2025-04-08 17:32:55 +03:00
Atanas Korchev
1b0ee6a757 Add specific upload examples. 2025-04-08 13:36:52 +03:00
Atanas Korchev
c185853405 Update the changelog to include 6.x changes. 2025-04-08 10:05:24 +03:00
Atanas Korchev
f50b8bceb6 Js minify (#2080)
* Minify the JavaScript.

* Update the terser package.
2025-04-08 09:32:06 +03:00
Atanas Korchev
559a10603a Update the innerHTML of the editor when source changes. 2025-04-08 07:58:48 +03:00
Atanas Korchev
defe38daaa Update the HTML content of RadzenHtmlEditor after running ValueChanged. 2025-04-07 16:54:46 +03:00
Vladimir Enchev
6acdaf0603 Version updated 2025-04-07 16:06:51 +03:00
Vladimir Enchev
e9991fc995 DialogService Alert() and Confirm() overloads with RenderFragment added 2025-04-07 14:55:22 +03:00
Vladimir Enchev
7ad14174d7 code fixed 2025-04-07 10:54:12 +03:00
Vladimir Enchev
a638387dd4 DataGrid FilterOperator changing to Contains on clear even when restricted
Fix #2074
2025-04-07 10:28:59 +03:00
Jeffrey van der Stad
3818d0e607 PR: Add PagingSummaryTemplate to RadzenDataGrid (Fixes [#2077](https://github.com/radzenhq/radzen-blazor/issues/2077)) (#2079)
* fix: added PagingSummaryTemplate as replacement for PagingSummaryFormat

* In `DataGridPagerApi.razor`, added a `PagingSummaryTemplate` within the `RadzenDataGrid` component to provide a visual summary of the current page and total records displayed.
2025-04-05 15:51:16 +03:00
Jeffrey van der Stad
3ce4f8da3a Updated unit tests in DialogServiceTests.cs to assert properties OkButtonText and CancelButtonText in ConfirmOptions and AlertOptions, with default values set to "Ok" and "Cancel". Modified DialogService.cs to initialize these properties if not specified. (#2063) 2025-03-30 10:48:45 +03:00
Vladimir Enchev
9d272a1b19 version updated 2025-03-29 16:48:58 +02:00
Atanas Korchev
3b9224b4da Parse images inside markdown links. Closes #2062. 2025-03-29 16:15:02 +02:00
Atanas Korchev
b254152746 Remove markup string (#2066)
* Remove MarkupString usage from the demos.

* Remove MarkupString from RadzenPanelMenu.

* Remove MarkupString from RadzenAccordion.

* Remove MarkupString from RadzenIcon

* Remove MarkupString from RadzenSplitButton

* Remove MarkupString from RadzenButton

* Add spaces in the keyboard navigation grid.

* Remove MarkupString from RadzenDialog

* Use literal strings for the icons in the Index page.

* Remove MarkupString from RadzenSelectbar

* Remove MarkupString from RadzenFieldset

* Remove MarkupString from everything else.
2025-03-29 12:30:41 +02:00
yordanov
a2d796476e Update premium themes 2025-03-28 15:25:46 +02:00
nielsNocore
898e744767 Fix small dot in rz-ripple on state :active (#2061) 2025-03-28 15:22:25 +02:00
Vladimir Enchev
9ef9c5b3de Numeric MaxLength property added 2025-03-28 14:25:11 +02:00
Vladimir Enchev
b734eeb252 Version updated 2025-03-28 07:39:29 +02:00
Vladimir Enchev
92d69d9053 DialogService Alert and Confirm buttons text missing when no options are specified
Fix #2060
2025-03-28 07:39:12 +02:00
Vladimir Enchev
4879c49476 Version updated 2025-03-26 17:10:50 +02:00
Vladimir Enchev
e81ea15bb0 DropDown select item with SPACE added
Closes #2011, #2054
2025-03-26 09:18:55 +02:00
Vladimir Enchev
647f174b53 Menu should be closed on location changed not toggled 2025-03-25 13:14:39 +02:00
Atanas Korchev
d79e6a7606 Escaped characters in Markdown tables display as a number. Fixes #2053. 2025-03-24 11:39:32 +02:00
Jeffrey van der Stad
3fd3916ef9 Enhance dialog options with property change notifications to support automatic UI updates (#2051)
* Enhance dialog options with property change notifications

* Update dialog properties and functionality

- Changed dialog text in `DialogPage.razor` to reflect new functionality.
- Updated button text in `DialogWithCascadingValueCaller.razor` and modified dialog title.
- Enhanced `DialogWithCascadingValueImplementation.razor` with new buttons for setting titles and toggling close options, and added methods for updating the dialog title and counter.

* Add unit tests and improve DialogService options handling

* Allow internal methods visibility for unit tests

Added an `ItemGroup` in the project file to include an
`InternalsVisibleTo` attribute for the `Radzen.Blazor.Tests`
assembly, enabling unit tests to access internal methods.
2025-03-24 08:10:57 +02:00
yordanov
b9b73d44c2 Fix titles and descriptions of UI Blocks demo pages 2025-03-21 15:01:28 +02:00
Vladimir Enchev
afa7c2030c demos update 2025-03-21 08:02:17 +02:00
1435 changed files with 90007 additions and 15050 deletions

View File

@@ -11,10 +11,10 @@ assignees: ''
IMPORTANT: Read this first!!!
1. If you own a Radzen Professional or Еnterprise subscription you can report your issue or ask us a question via email at info@radzen.com. Radzen staff will reply within 24 hours (Professional) or 16 hours (Enterprise)
1. If you own a Radzen Blazor Pro or Team subscription you can also report your issue or ask us a question via email at info@radzen.com. Radzen staff will reply within 24 hours (Pro) or 16 hours (Team)
2. The Radzen staff guarantees a response to issues in this repo only to paid subscribers.
3. If you have a HOW TO question start a new forum thread in the Radzen Community forum: https://forum.radzen.com. Radzen staff will close issues that are HOWTO questions.
4. Please adhere to the issue template. Specify all the steps required to reproduce the issue or link a project which reproduces it easily (without requiring extra steps such as restoring a database).
4. Please adhere to the issue template. Specify all the steps required to reproduce the issue.
-->
**Describe the bug**
@@ -27,7 +27,12 @@ Steps to reproduce the behavior:
3. Scroll down to '....'
4. See error
Alternatively link your repo with a sample project that can be run.
Alternatively make a new [playground](https://blazor.radzen.com/playground) snippet and paste its URL.
1. Go to any live demo at https://blazor.radzen.com
2. Click the **Edit Source** tab.
3. Then click **Open in Playground**.
4. Reproduce the problem and save the snippet.
5. Copy the snippet URL and provide it in the issue description.
**Expected behavior**
A clear and concise description of what you expected to happen.

View File

@@ -5,4 +5,4 @@ contact_links:
about: Please ask and answer questions here.
- name: Radzen Commercial Support
url: info@radzen.com
about: Radzen Professional or Enterprise subscribers can get dedicated support over email.
about: Radzen Blazor subscribers can get dedicated support over email.

View File

@@ -11,7 +11,7 @@ assignees: ''
IMPORTANT: Read this first!!!
1. If you own a Radzen Professional or Еnterprise subscription you can request your feature via email at info@radzen.com. Radzen staff will reply within 24 hours (Professional) or 16 hours (Enterprise)
1. If you own a Radzen Blazor subscription you can request your feature via email at info@radzen.com. Radzen staff will reply within 24 hours (Pro) or 16 hours (Team)
2. The Radzen staff guarantees a response to issues in this repo only to paid subscribers.
3. If you have a HOW TO question start a new forum thread in the Radzen Community forum: https://forum.radzen.com. Radzen staff will close issues that are HOWTO questions.
4. Please adhere to the issue template.

View File

@@ -20,7 +20,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
dotnet-version: 10.0.x
- name: Build
run: dotnet build Radzen.Blazor/Radzen.Blazor.csproj

66
.github/workflows/deploy.yml vendored Normal file
View File

@@ -0,0 +1,66 @@
name: Deploy to blazor.radzen.com
on:
workflow_dispatch:
concurrency:
group: blazor-radzen-prod
cancel-in-progress: true
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Compute image tag (timestamp)
id: meta
run: |
TAG=$(date -u +"%Y%m%d%H%M%S")
IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${TAG}"
echo "image=$IMAGE" >> "$GITHUB_OUTPUT"
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.image }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Push to dokku
uses: dokku/github-action@master
with:
git_remote_url: ${{ secrets.DOKKU_REPO }}
ssh_private_key: ${{ secrets.DOKKU_SSH_PRIVATE_KEY }}
deploy_docker_image: ${{ steps.meta.outputs.image }}
- name: Prune GHCR versions (keep 1)
uses: actions/delete-package-versions@v5
with:
package-name: radzen-blazor
package-type: container
min-versions-to-keep: 1
delete-only-pre-release-versions: false

7
.gitignore vendored
View File

@@ -341,3 +341,10 @@ Radzen.DocFX/_exported_templates
Radzen.DocFX/api/*.yml
!Radzen.DocFX/api/index.md
Radzen.DocFX/api/.manifest
Radzen.Blazor.min.js
/.claude
/SANKEY_PATTERN_COMPARISON.md
*.md
/.gitignore
/.gitignore
RadzenBlazorDemos/wwwroot/demos

View File

@@ -19,7 +19,7 @@ You can ask your question here. Please use the [Radzen.Blazor Components](https:
### Dedicated technical support
Radzen staff provides technical support with guaranteed response time to Radzen Professional and Enterprise subscribers. The pricing options are available [here](https://www.radzen.com/blazor-studio/pricing/).
Radzen staff provides technical support with guaranteed response time to Radzen Professional and Enterprise subscribers. The pricing options are available [here](https://www.radzen.com/pricing).
## How Can I Contribute?

85
Directory.Build.props Normal file
View File

@@ -0,0 +1,85 @@
<Project>
<!--
Common build properties for all projects in the Radzen.Blazor solution.
To use this file:
1. Rename to Directory.Build.props (remove .sample extension)
2. Adjust settings based on your needs
3. Review the analyzer settings in .editorconfig
This file will be automatically imported by all projects in subdirectories.
-->
<PropertyGroup Label="Language Configuration">
<!-- Use latest C# language features -->
<LangVersion>latest</LangVersion>
<!-- Do NOT enable implicit usings - explicit imports preferred for library code -->
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoWarn>CA2007</NoWarn>
</PropertyGroup>
<PropertyGroup Label="Code Analysis Configuration">
<!-- Enable .NET code analyzers -->
<AnalysisLevel>latest</AnalysisLevel>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<!-- Run analyzers during build and in IDE -->
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
<RunAnalyzersDuringLiveAnalysis>true</RunAnalyzersDuringLiveAnalysis>
<!-- Don't enforce code style in build (yet) - just show warnings -->
<EnforceCodeStyleInBuild>false</EnforceCodeStyleInBuild>
<!-- Don't treat warnings as errors (yet) - too many to fix immediately -->
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<!-- Report all analyzer diagnostics -->
<AnalysisMode>All</AnalysisMode>
</PropertyGroup>
<PropertyGroup Label="Build Quality">
<!-- Enable deterministic builds for reproducibility -->
<Deterministic>true</Deterministic>
<!-- Enable deterministic builds in CI/CD -->
<ContinuousIntegrationBuild Condition="'$(CI)' == 'true'">true</ContinuousIntegrationBuild>
<!-- Embed source files for better debugging -->
<EmbedAllSources>true</EmbedAllSources>
<!--
IMPORTANT:
- NuGet symbol packages (.snupkg) require portable PDB files.
- If DebugType=embedded, there are no standalone PDBs, so the .snupkg ends up effectively empty.
Use portable PDBs when symbols are enabled; otherwise use embedded for local debugging convenience.
-->
<!--
NOTE: Directory.Build.props is imported before project files, so properties like IncludeSymbols
set in a .csproj may not be available yet for Conditions here.
IsPacking *is* set by `dotnet pack`, so use that to switch DebugType for symbol packages.
-->
<DebugType Condition="'$(IsPacking)' == 'true'">portable</DebugType>
<DebugType Condition="'$(IsPacking)' != 'true'">embedded</DebugType>
</PropertyGroup>
<PropertyGroup Label="Demos and Tests Project Configuration" Condition="$(MSBuildProjectName.Contains('Demos')) OR $(MSBuildProjectName.Contains('Tests'))">
<!-- Demo projects and Tests should not be packable -->
<IsPackable>false</IsPackable>
<!-- DISABLE ALL ANALYZERS FOR DEMO PROJECTS AND TESTS -->
<EnableNETAnalyzers>false</EnableNETAnalyzers>
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
<RunAnalyzersDuringLiveAnalysis>false</RunAnalyzersDuringLiveAnalysis>
<EnforceCodeStyleInBuild>false</EnforceCodeStyleInBuild>
</PropertyGroup>
<PropertyGroup Label="Performance">
<!-- Optimize startup time -->
<TieredCompilation>true</TieredCompilation>
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
</PropertyGroup>
</Project>

View File

@@ -1,31 +1,48 @@
# syntax=docker/dockerfile:1
FROM mono:latest
# =============================
# BUILD STAGE
# =============================
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
ENV DOCFX_VER 2.58.4
# Copy project files first for better caching
COPY Radzen.Blazor/*.csproj Radzen.Blazor/
COPY RadzenBlazorDemos/*.csproj RadzenBlazorDemos/
COPY RadzenBlazorDemos.Host/*.csproj RadzenBlazorDemos.Host/
RUN apt-get update && apt-get install unzip wget git -y && wget -q -P /tmp https://github.com/dotnet/docfx/releases/download/v${DOCFX_VER}/docfx.zip && \
mkdir -p /opt/docfx && \
unzip /tmp/docfx.zip -d /opt/docfx && \
echo '#!/bin/bash\nmono /opt/docfx/docfx.exe $@' > /usr/bin/docfx && \
chmod +x /usr/bin/docfx && \
rm -rf /tmp/*
# Radzen.DocFX usually has no csproj → copy full folder
COPY Radzen.DocFX/ Radzen.DocFX/
COPY Radzen.Blazor /app/Radzen.Blazor
COPY Radzen.DocFX /app/DocFX
COPY RadzenBlazorDemos /app/RadzenBlazorDemos
COPY RadzenBlazorDemos.Host /app/RadzenBlazorDemos.Host
# Restore dependencies
RUN dotnet restore RadzenBlazorDemos.Host/RadzenBlazorDemos.Host.csproj
# Copy full source after restore layer
COPY . .
# Install docfx (build stage only)
RUN dotnet tool install -g docfx
ENV PATH="$PATH:/root/.dotnet/tools"
# Build shared project (keep net8.0 if required)
RUN dotnet build -c Release Radzen.Blazor/Radzen.Blazor.csproj -f net8.0
# Generate documentation
RUN docfx Radzen.DocFX/docfx.json
# Publish the Blazor host app
WORKDIR /src/RadzenBlazorDemos.Host
RUN dotnet publish -c Release -o /app/out
# =============================
# RUNTIME STAGE
# =============================
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
WORKDIR /app
RUN docfx DocFX/docfx.json
FROM mcr.microsoft.com/dotnet/sdk:9.0
# Copy only published output
COPY --from=build /app/out ./
COPY --from=0 /app/RadzenBlazorDemos.Host /app/RadzenBlazorDemos.Host
COPY --from=0 /app/RadzenBlazorDemos /app/RadzenBlazorDemos
WORKDIR /app/RadzenBlazorDemos.Host
RUN dotnet publish -c Release -o out
ENV ASPNETCORE_URLS http://*:5000
WORKDIR /app/RadzenBlazorDemos.Host/out
# Set runtime URL
ENV ASPNETCORE_URLS=http://+:5000
ENTRYPOINT ["dotnet", "RadzenBlazorDemos.Host.dll"]

View File

@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2018-2025 Radzen Ltd
Copyright (c) 2018-2026 Radzen Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -3,7 +3,7 @@
Radzen Blazor Components
========================
A set of **90+ free and open source** native Blazor UI controls.
The most sophisticated free UI component library for Blazor, featuring **100+ native components**.
See Online Demos or Read the Docs
@@ -15,7 +15,7 @@ See Online Demos or Read the Docs
Radzen Blazor Components are open source and free for commercial use. You can install them from [NuGet](https://www.nuget.org/packages/Radzen.Blazor) or build your own copy from source.
Paid support is available as part of the [Radzen Professional subscription](https://www.radzen.com/blazor-studio/pricing/).
Paid support is available as part of the [Radzen Blazor subscription](https://www.radzen.com/pricing).
### :computer: Native
@@ -38,9 +38,9 @@ Everybody is welcome to visit the [Radzen Community forum](https://forum.radzen.
The Radzen team monitors the forum threads, but does not guarantee a response to every question. For guaranteed responses you may consider the dedicated support option.
Dedicated support for the Radzen Blazor Components is available as part of the [Radzen Professional subscription](https://www.radzen.com/blazor-studio/pricing/).
Dedicated support for the Radzen Blazor Components is available as part of the [Radzen Blazor subscription](https://www.radzen.com/pricing).
Our flagship product [Radzen Blazor Studio](https://www.radzen.com/blazor-studio/) provides tons of productivity features for Blazor developers:
Our flagship product [Radzen Blazor Studio](https://www.radzen.com/blazor-studio) provides tons of productivity features for Blazor developers:
- An industry-leading WYSIWYG Blazor design time canvas
- Scaffolding a complete CRUD applications from a database
- Built-in security - authentication and authorization
@@ -50,8 +50,8 @@ Our flagship product [Radzen Blazor Studio](https://www.radzen.com/blazor-studio
## Get started with Radzen Blazor Components
Check the [getting started](https://blazor.radzen.com/getting-started) instructions to start making awesome Blazor applications.
Check the [getting started](https://blazor.radzen.com/get-started) instructions to start making awesome Blazor applications.
## Run demos locally
Use Radzen.Server.sln to open and run demos as Blazor server application or Radzen.WebAssembly.sln to open and run demos as Blazor WebAssembly application. Radzen.sln has reference to all projects including tests.
Use **Radzen.Server.sln** to open and run demos as Blazor server application or **Radzen.WebAssembly.sln** to open and run demos as Blazor WebAssembly application. The demos require the .NET 10 SDK and should preferably be opened in VS2026.

View File

@@ -0,0 +1,171 @@
using Bunit;
using Microsoft.Extensions.DependencyInjection;
using Radzen;
using System;
using System.Net.Http;
using Microsoft.Extensions.Options;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class AIChatTests
{
private void RegisterChatService(TestContext ctx)
{
// Register a dummy HttpClient and default options for AIChatService
ctx.Services.AddSingleton(new HttpClient());
ctx.Services.AddScoped<IAIChatService, AIChatService>();
}
[Fact]
public void RadzenAIChat_ShouldRenderWithDefaultProperties()
{
using var ctx = new TestContext();
RegisterChatService(ctx);
var component = ctx.RenderComponent<RadzenAIChat>();
Assert.Contains("Type your message...", component.Markup);
}
[Fact]
public void RadzenAIChat_ShouldRenderWithCustomTitle()
{
using var ctx = new TestContext();
RegisterChatService(ctx);
var component = ctx.RenderComponent<RadzenAIChat>(parameters => parameters
.Add(p => p.Title, "Custom Chat"));
Assert.Contains("Custom Chat", component.Markup);
}
[Fact]
public void RadzenAIChat_ShouldRenderWithCustomPlaceholder()
{
using var ctx = new TestContext();
RegisterChatService(ctx);
var component = ctx.RenderComponent<RadzenAIChat>(parameters => parameters
.Add(p => p.Placeholder, "Enter your message here..."));
Assert.Contains("Enter your message here...", component.Markup);
}
[Fact]
public void RadzenAIChat_ShouldRenderWithCustomEmptyMessage()
{
using var ctx = new TestContext();
RegisterChatService(ctx);
var component = ctx.RenderComponent<RadzenAIChat>(parameters => parameters
.Add(p => p.EmptyMessage, "No messages yet"));
Assert.Contains("No messages yet", component.Markup);
}
[Fact]
public void RadzenAIChat_ShouldShowClearButtonByDefault()
{
using var ctx = new TestContext();
RegisterChatService(ctx);
var component = ctx.RenderComponent<RadzenAIChat>();
Assert.Contains("rz-chat-header-clear", component.Markup);
}
[Fact]
public void RadzenAIChat_ShouldHideClearButtonWhenShowClearButtonIsFalse()
{
using var ctx = new TestContext();
RegisterChatService(ctx);
var component = ctx.RenderComponent<RadzenAIChat>(parameters => parameters
.Add(p => p.ShowClearButton, false));
Assert.DoesNotContain("clear_all", component.Markup);
}
[Fact]
public void RadzenAIChat_ShouldBeDisabledWhenDisabledIsTrue()
{
using var ctx = new TestContext();
RegisterChatService(ctx);
var component = ctx.RenderComponent<RadzenAIChat>(parameters => parameters
.Add(p => p.Disabled, true));
Assert.Contains("disabled", component.Markup);
}
[Fact]
public void RadzenAIChat_ShouldBeReadOnlyWhenReadOnlyIsTrue()
{
using var ctx = new TestContext();
RegisterChatService(ctx);
var component = ctx.RenderComponent<RadzenAIChat>(parameters => parameters
.Add(p => p.ReadOnly, true));
Assert.Contains("readonly", component.Markup);
}
[Fact]
public void RadzenAIChat_ShouldHaveCorrectCssClass()
{
using var ctx = new TestContext();
RegisterChatService(ctx);
var component = ctx.RenderComponent<RadzenAIChat>();
Assert.Contains("rz-chat", component.Markup);
}
[Fact]
public void ChatMessage_ShouldHaveCorrectProperties()
{
// Arrange
var message = new ChatMessage
{
Content = "Test message",
IsUser = true,
Timestamp = DateTime.Now
};
// Assert
Assert.NotEmpty(message.Id);
Assert.Equal("Test message", message.Content);
Assert.True(message.IsUser);
Assert.False(message.IsStreaming);
}
[Fact]
public void RadzenAIChat_AddMessage_ShouldAddMessageToList()
{
using var ctx = new TestContext();
RegisterChatService(ctx);
var component = ctx.RenderComponent<RadzenAIChat>();
// Act
component.Instance.AddMessage("Test message", true);
// Assert
var messages = component.Instance.GetMessages();
Assert.Single(messages);
Assert.Equal("Test message", messages[0].Content);
Assert.True(messages[0].IsUser);
}
[Fact]
public void RadzenAIChat_ClearChat_ShouldRemoveAllMessages()
{
using var ctx = new TestContext();
RegisterChatService(ctx);
var component = ctx.RenderComponent<RadzenAIChat>();
component.Instance.AddMessage("Test message 1", true);
component.Instance.AddMessage("Test message 2", false);
// Act
component.InvokeAsync(async () => await component.Instance.ClearChat()).Wait();
// Assert
Assert.Empty(component.Instance.GetMessages());
}
[Fact]
public void RadzenAIChat_ShouldLimitMessagesToMaxMessages()
{
using var ctx = new TestContext();
RegisterChatService(ctx);
var component = ctx.RenderComponent<RadzenAIChat>(parameters => parameters.Add(p => p.MaxMessages, 3));
component.Instance.AddMessage("Message 1", true);
component.Instance.AddMessage("Message 2", false);
component.Instance.AddMessage("Message 3", true);
component.Instance.AddMessage("Message 4", false);
// Assert
var messages = component.Instance.GetMessages();
Assert.Equal(3, messages.Count);
Assert.Equal("Message 2", messages[0].Content);
Assert.Equal("Message 3", messages[1].Content);
Assert.Equal("Message 4", messages[2].Content);
}
}
}

View File

@@ -0,0 +1,195 @@
using Bunit;
using Microsoft.AspNetCore.Components;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class AccordionTests
{
[Fact]
public void Accordion_Renders_CssClasses()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenAccordion>();
Assert.Contains(@"rz-accordion", component.Markup);
}
[Fact]
public void Accordion_Renders_AccordionItems()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenAccordion>(parameters =>
{
parameters.Add(p => p.Items, builder =>
{
builder.OpenComponent<RadzenAccordionItem>(0);
builder.AddAttribute(1, "Text", "Test Item");
builder.AddAttribute(2, "ChildContent", (RenderFragment)(contentBuilder =>
{
contentBuilder.AddContent(0, "Item Content");
}));
builder.CloseComponent();
});
});
Assert.Contains("Test Item", component.Markup);
Assert.Contains("Item Content", component.Markup);
}
[Fact]
public void Accordion_Renders_ItemWithIcon()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenAccordion>(parameters =>
{
parameters.Add(p => p.Items, builder =>
{
builder.OpenComponent<RadzenAccordionItem>(0);
builder.AddAttribute(1, "Text", "Orders");
builder.AddAttribute(2, "Icon", "account_balance_wallet");
builder.AddAttribute(3, "ChildContent", (RenderFragment)(contentBuilder =>
{
contentBuilder.AddContent(0, "Order Details");
}));
builder.CloseComponent();
});
});
Assert.Contains("account_balance_wallet", component.Markup);
Assert.Contains("Orders", component.Markup);
}
[Fact]
public void Accordion_SingleExpand_OnlyOneItemExpanded()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenAccordion>(parameters =>
{
parameters.Add(p => p.Multiple, false); // Single expand mode
parameters.Add(p => p.Items, builder =>
{
// Add first item
builder.OpenComponent<RadzenAccordionItem>(0);
builder.AddAttribute(1, "Text", "Item 1");
builder.AddAttribute(2, "ChildContent", (RenderFragment)(b => b.AddContent(0, "Content 1")));
builder.CloseComponent();
// Add second item
builder.OpenComponent<RadzenAccordionItem>(1);
builder.AddAttribute(1, "Text", "Item 2");
builder.AddAttribute(2, "ChildContent", (RenderFragment)(b => b.AddContent(0, "Content 2")));
builder.CloseComponent();
});
});
Assert.False(component.Instance.Multiple);
}
[Fact]
public void Accordion_MultipleExpand_AllowsMultipleItemsExpanded()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenAccordion>(parameters =>
{
parameters.Add(p => p.Multiple, true);
});
Assert.True(component.Instance.Multiple);
}
[Fact]
public void Accordion_Raises_ExpandEvent()
{
using var ctx = new TestContext();
var expandRaised = false;
int expandedIndex = -1;
var component = ctx.RenderComponent<RadzenAccordion>(parameters =>
{
parameters.Add(p => p.Expand, EventCallback.Factory.Create<int>(this, (index) =>
{
expandRaised = true;
expandedIndex = index;
}));
parameters.Add(p => p.Items, builder =>
{
builder.OpenComponent<RadzenAccordionItem>(0);
builder.AddAttribute(1, "Text", "Test Item");
builder.AddAttribute(2, "ChildContent", (RenderFragment)(b => b.AddContent(0, "Content")));
builder.CloseComponent();
});
});
// Find and click the accordion header link to expand
var header = component.Find(".rz-accordion-header a");
header.Click();
Assert.True(expandRaised);
Assert.Equal(0, expandedIndex);
}
[Fact]
public void Accordion_Raises_CollapseEvent()
{
using var ctx = new TestContext();
var collapseRaised = false;
int collapsedIndex = -1;
var component = ctx.RenderComponent<RadzenAccordion>(parameters =>
{
parameters.Add(p => p.Collapse, EventCallback.Factory.Create<int>(this, (index) =>
{
collapseRaised = true;
collapsedIndex = index;
}));
parameters.Add(p => p.Items, builder =>
{
builder.OpenComponent<RadzenAccordionItem>(0);
builder.AddAttribute(1, "Text", "Test Item");
builder.AddAttribute(2, "Selected", true); // Start expanded
builder.AddAttribute(3, "ChildContent", (RenderFragment)(b => b.AddContent(0, "Content")));
builder.CloseComponent();
});
});
// Find and click the accordion header link to collapse
var header = component.Find(".rz-accordion-header a");
header.Click();
Assert.True(collapseRaised);
Assert.Equal(0, collapsedIndex);
}
[Fact]
public void Accordion_DisabledItem_CannotExpand()
{
using var ctx = new TestContext();
var expandRaised = false;
var component = ctx.RenderComponent<RadzenAccordion>(parameters =>
{
parameters.Add(p => p.Expand, EventCallback.Factory.Create<int>(this, (_) => expandRaised = true));
parameters.Add(p => p.Items, builder =>
{
builder.OpenComponent<RadzenAccordionItem>(0);
builder.AddAttribute(1, "Text", "Disabled Item");
builder.AddAttribute(2, "Disabled", true);
builder.AddAttribute(3, "ChildContent", (RenderFragment)(b => b.AddContent(0, "Content")));
builder.CloseComponent();
});
});
// Try to click the disabled item
var header = component.Find(".rz-accordion-header a");
header.Click();
// Event should not be raised for disabled item
Assert.False(expandRaised);
}
}
}

View File

@@ -0,0 +1,195 @@
using Bunit;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class AlertTests
{
[Fact]
public void Alert_Renders_CssClasses()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenAlert>();
Assert.Contains(@"rz-alert", component.Markup);
}
[Fact]
public void Alert_Renders_AlertStyle()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenAlert>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.AlertStyle, AlertStyle.Danger));
Assert.Contains("rz-danger", component.Markup);
component.SetParametersAndRender(parameters => parameters.Add(p => p.AlertStyle, AlertStyle.Success));
Assert.Contains("rz-success", component.Markup);
component.SetParametersAndRender(parameters => parameters.Add(p => p.AlertStyle, AlertStyle.Warning));
Assert.Contains("rz-warning", component.Markup);
component.SetParametersAndRender(parameters => parameters.Add(p => p.AlertStyle, AlertStyle.Info));
Assert.Contains("rz-info", component.Markup);
}
[Fact]
public void Alert_Renders_Shade()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenAlert>();
component.SetParametersAndRender(parameters => parameters
.Add(p => p.AlertStyle, AlertStyle.Primary)
.Add(p => p.Shade, Shade.Lighter));
Assert.Contains("rz-shade-lighter", component.Markup);
component.SetParametersAndRender(parameters => parameters
.Add(p => p.AlertStyle, AlertStyle.Primary)
.Add(p => p.Shade, Shade.Darker));
Assert.Contains("rz-shade-darker", component.Markup);
}
[Fact]
public void Alert_Renders_Variant()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenAlert>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.Variant, Variant.Outlined));
Assert.Contains("rz-variant-outlined", component.Markup);
component.SetParametersAndRender(parameters => parameters.Add(p => p.Variant, Variant.Flat));
Assert.Contains("rz-variant-flat", component.Markup);
}
[Fact]
public void Alert_Renders_Title()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenAlert>();
var title = "Alert Title";
component.SetParametersAndRender(parameters => parameters.Add(p => p.Title, title));
Assert.Contains(title, component.Markup);
Assert.Contains("rz-alert-title", component.Markup);
}
[Fact]
public void Alert_Renders_Text()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenAlert>();
var text = "This is an alert message";
component.SetParametersAndRender(parameters => parameters.Add(p => p.Text, text));
Assert.Contains(text, component.Markup);
}
[Fact]
public void Alert_Renders_ChildContent()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenAlert>(parameters =>
{
parameters.AddChildContent("Custom alert content");
});
Assert.Contains("Custom alert content", component.Markup);
}
[Fact]
public void Alert_ShowIcon_DisplaysIcon()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenAlert>();
// Default should show icon
Assert.Contains("rz-alert-icon", component.Markup);
component.SetParametersAndRender(parameters => parameters.Add(p => p.ShowIcon, false));
Assert.DoesNotContain("rz-alert-icon", component.Markup);
}
[Fact]
public void Alert_AllowClose_DisplaysCloseButton()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenAlert>();
// Default AllowClose is true - should contain a button with close icon
component.SetParametersAndRender(parameters => parameters.Add(p => p.AllowClose, true));
Assert.Contains("close", component.Markup);
Assert.Contains("rz-button", component.Markup);
component.SetParametersAndRender(parameters => parameters.Add(p => p.AllowClose, false));
// When AllowClose is false, should not have close button
var buttonCount = System.Text.RegularExpressions.Regex.Matches(component.Markup, "rz-button").Count;
Assert.Equal(0, buttonCount);
}
[Fact]
public void Alert_CloseButton_RaisesCloseEvent()
{
using var ctx = new TestContext();
var closeRaised = false;
var component = ctx.RenderComponent<RadzenAlert>(parameters =>
{
parameters.Add(p => p.AllowClose, true);
parameters.Add(p => p.Close, () => closeRaised = true);
});
var closeButton = component.Find("button.rz-button");
closeButton.Click();
Assert.True(closeRaised);
}
[Fact]
public void Alert_Visible_ControlsDisplay()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenAlert>(parameters =>
{
parameters.Add(p => p.Visible, true);
parameters.Add(p => p.Text, "Visible Alert");
});
Assert.Contains("Visible Alert", component.Markup);
component.SetParametersAndRender(parameters => parameters.Add(p => p.Visible, false));
// When not visible, component should not render
Assert.DoesNotContain("Visible Alert", component.Markup);
}
[Fact]
public void Alert_CloseButton_SetsVisibleToFalse()
{
using var ctx = new TestContext();
var visibleValue = true;
var component = ctx.RenderComponent<RadzenAlert>(parameters =>
{
parameters.Add(p => p.Visible, visibleValue);
parameters.Add(p => p.AllowClose, true);
parameters.Add(p => p.VisibleChanged, (bool value) => visibleValue = value);
});
var closeButton = component.Find("button.rz-button");
closeButton.Click();
Assert.False(visibleValue);
}
}
}

View File

@@ -1,9 +1,77 @@
using Xunit;
using System.Collections;
using Bunit;
using Xunit;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Radzen.Blazor.Tests
{
public class AutoCompleteTests
{
[Fact]
public void AutoComplete_Renders_WithClassName()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenAutoComplete>();
Assert.Contains(@"rz-autocomplete", component.Markup);
}
[Fact]
public void AutoComplete_Renders_InputElement()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenAutoComplete>();
Assert.Contains("type=\"text\"", component.Markup);
Assert.Contains("rz-inputtext", component.Markup);
}
[Fact]
public void AutoComplete_Renders_Disabled()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenAutoComplete>(parameters =>
{
parameters.Add(p => p.Disabled, true);
});
Assert.Contains("disabled", component.Markup);
Assert.Contains("rz-state-disabled", component.Markup);
}
[Fact]
public void AutoComplete_Renders_Placeholder()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenAutoComplete>(parameters =>
{
parameters.Add(p => p.Placeholder, "Type to search...");
});
Assert.Contains("placeholder=\"Type to search...\"", component.Markup);
}
[Fact]
public void AutoComplete_Renders_WithData()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<string> { "Apple", "Banana", "Cherry" };
var component = ctx.RenderComponent<RadzenAutoComplete>(parameters =>
{
parameters.Add(p => p.Data, data);
});
Assert.Contains("rz-autocomplete-panel", component.Markup);
}
[Fact]
public void AutoComplete_Enum_Converts_To_Attr_Value()
{
@@ -70,5 +138,30 @@ namespace Radzen.Blazor.Tests
Assert.Equal("additional-name", AutoCompleteType.MiddleName.GetAutoCompleteValue());
Assert.Equal("family-name", AutoCompleteType.LastName.GetAutoCompleteValue());
}
[Fact]
public void AutoComplete_Filters_StringList()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<string> { "Apple", "Banana", "Cherry" };
var component = ctx.RenderComponent<AutoCompleteWithAccessibleView>(parameters =>
{
parameters
.Add(p => p.Data, data)
.Add(p => p.SearchText, "Ban")
.Add(p => p.OpenOnFocus, true);
});
Assert.Contains("Banana", component.Instance.CurrentView.OfType<string>());
Assert.DoesNotContain("Apple", component.Instance.CurrentView.OfType<string>());
Assert.DoesNotContain("Cherry", component.Instance.CurrentView.OfType<string>());
}
private sealed class AutoCompleteWithAccessibleView : RadzenAutoComplete
{
public IEnumerable CurrentView => View;
}
}
}

View File

@@ -0,0 +1,46 @@
using Bunit;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class CardTests
{
[Fact]
public void Card_Renders_WithClassName()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenCard>();
Assert.Contains(@"rz-card", component.Markup);
}
[Fact]
public void Card_Renders_ChildContent()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenCard>(parameters =>
{
parameters.AddChildContent("<div>Card Content</div>");
});
Assert.Contains("Card Content", component.Markup);
}
[Fact]
public void Card_Renders_Variant()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenCard>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.Variant, Variant.Outlined));
Assert.Contains("rz-variant-outlined", component.Markup);
component.SetParametersAndRender(parameters => parameters.Add(p => p.Variant, Variant.Filled));
Assert.Contains("rz-variant-filled", component.Markup);
component.SetParametersAndRender(parameters => parameters.Add(p => p.Variant, Variant.Flat));
Assert.Contains("rz-variant-flat", component.Markup);
}
}
}

View File

@@ -0,0 +1,173 @@
using Bunit;
using Microsoft.AspNetCore.Components;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class CarouselTests
{
[Fact]
public void Carousel_Renders_WithClassName()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenCarousel>();
Assert.Contains(@"rz-carousel", component.Markup);
}
[Fact]
public void Carousel_Renders_AllowPaging_True()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenCarousel>(parameters =>
{
parameters.Add(p => p.AllowPaging, true);
parameters.Add(p => p.Items, builder =>
{
builder.OpenComponent<RadzenCarouselItem>(0);
builder.AddAttribute(1, "ChildContent", (RenderFragment)(b => b.AddContent(0, "Slide 1")));
builder.CloseComponent();
builder.OpenComponent<RadzenCarouselItem>(2);
builder.AddAttribute(3, "ChildContent", (RenderFragment)(b => b.AddContent(0, "Slide 2")));
builder.CloseComponent();
});
});
Assert.Contains("rz-carousel-pager-button", component.Markup);
}
[Fact]
public void Carousel_Renders_AllowPaging_False()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenCarousel>(parameters =>
{
parameters.Add(p => p.AllowPaging, false);
parameters.Add(p => p.Items, builder =>
{
builder.OpenComponent<RadzenCarouselItem>(0);
builder.AddAttribute(1, "ChildContent", (RenderFragment)(b => b.AddContent(0, "Slide 1")));
builder.CloseComponent();
});
});
Assert.DoesNotContain("rz-carousel-pager-button", component.Markup);
}
[Fact]
public void Carousel_Renders_AllowNavigation_True()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenCarousel>(parameters =>
{
parameters.Add(p => p.AllowNavigation, true);
});
Assert.Contains("rz-carousel-prev", component.Markup);
Assert.Contains("rz-carousel-next", component.Markup);
}
[Fact]
public void Carousel_Renders_AllowNavigation_False()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenCarousel>(parameters =>
{
parameters.Add(p => p.AllowNavigation, false);
});
Assert.DoesNotContain("rz-carousel-prev", component.Markup);
Assert.DoesNotContain("rz-carousel-next", component.Markup);
Assert.Contains("rz-carousel-no-navigation", component.Markup);
}
[Fact]
public void Carousel_Renders_PagerPosition_Top()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenCarousel>(parameters =>
{
parameters.Add(p => p.PagerPosition, PagerPosition.Top);
parameters.Add(p => p.AllowPaging, true);
parameters.Add(p => p.Items, builder =>
{
builder.OpenComponent<RadzenCarouselItem>(0);
builder.AddAttribute(1, "ChildContent", (RenderFragment)(b => b.AddContent(0, "Slide")));
builder.CloseComponent();
});
});
Assert.Contains("rz-carousel-pager-top", component.Markup);
}
[Fact]
public void Carousel_Renders_PagerPosition_Bottom()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenCarousel>(parameters =>
{
parameters.Add(p => p.PagerPosition, PagerPosition.Bottom);
parameters.Add(p => p.AllowPaging, true);
parameters.Add(p => p.Items, builder =>
{
builder.OpenComponent<RadzenCarouselItem>(0);
builder.AddAttribute(1, "ChildContent", (RenderFragment)(b => b.AddContent(0, "Slide")));
builder.CloseComponent();
});
});
Assert.Contains("rz-carousel-pager-bottom", component.Markup);
}
[Fact]
public void Carousel_Renders_PagerPosition_TopAndBottom()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenCarousel>(parameters =>
{
parameters.Add(p => p.PagerPosition, PagerPosition.TopAndBottom);
parameters.Add(p => p.AllowPaging, true);
parameters.Add(p => p.Items, builder =>
{
builder.OpenComponent<RadzenCarouselItem>(0);
builder.AddAttribute(1, "ChildContent", (RenderFragment)(b => b.AddContent(0, "Slide")));
builder.CloseComponent();
});
});
Assert.Contains("rz-carousel-pager-top", component.Markup);
Assert.Contains("rz-carousel-pager-bottom", component.Markup);
}
[Fact]
public void Carousel_Renders_PagerOverlay_True()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenCarousel>(parameters =>
{
parameters.Add(p => p.PagerOverlay, true);
});
Assert.Contains("rz-carousel-pager-overlay", component.Markup);
}
[Fact]
public void Carousel_Renders_PagerOverlay_False()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenCarousel>(parameters =>
{
parameters.Add(p => p.PagerOverlay, false);
});
Assert.DoesNotContain("rz-carousel-pager-overlay", component.Markup);
}
}
}

View File

@@ -0,0 +1,369 @@
using Bunit;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.DependencyInjection;
using Radzen.Blazor;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class ChatTests
{
[Fact]
public void RadzenChat_ShouldRenderWithTitle()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenChat>(parameters => parameters
.Add(p => p.Title, "Test Chat")
.Add(p => p.CurrentUserId, "user1")
.Add(p => p.Users, new List<ChatUser>())
.Add(p => p.Messages, new List<ChatMessage>())
);
Assert.Contains("Test Chat", component.Markup);
}
[Fact]
public void RadzenChat_ShouldShowEmptyMessageWhenNoMessages()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenChat>(parameters => parameters
.Add(p => p.Title, "Test Chat")
.Add(p => p.CurrentUserId, "user1")
.Add(p => p.Users, new List<ChatUser>())
.Add(p => p.Messages, new List<ChatMessage>())
.Add(p => p.EmptyMessage, "No messages yet!")
);
Assert.Contains("No messages yet!", component.Markup);
}
[Fact]
public void RadzenChat_ShouldDisplayMessages()
{
var messages = new List<ChatMessage>
{
new ChatMessage { Content = "Hello", UserId = "user1", Timestamp = DateTime.Now },
new ChatMessage { Content = "Hi there!", UserId = "user2", Timestamp = DateTime.Now }
};
var users = new List<ChatUser>
{
new ChatUser { Id = "user1", Name = "John" },
new ChatUser { Id = "user2", Name = "Jane" }
};
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenChat>(parameters => parameters
.Add(p => p.Title, "Test Chat")
.Add(p => p.CurrentUserId, "user1")
.Add(p => p.Users, users)
.Add(p => p.Messages, messages)
);
Assert.Contains("Hello", component.Markup);
Assert.Contains("Hi there!", component.Markup);
}
[Fact]
public void RadzenChat_ShouldShowUsersInHeader()
{
var users = new List<ChatUser>
{
new ChatUser { Id = "user1", Name = "John" },
new ChatUser { Id = "user2", Name = "Jane" }
};
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenChat>(parameters => parameters
.Add(p => p.Title, "Test Chat")
.Add(p => p.CurrentUserId, "user1")
.Add(p => p.Users, users)
.Add(p => p.Messages, new List<ChatMessage>())
.Add(p => p.ShowUsers, true)
);
Assert.Contains("John", component.Markup);
Assert.Contains("Jane", component.Markup);
}
[Fact]
public void RadzenChat_ShouldShowUserNamesAboveMessages()
{
var messages = new List<ChatMessage>
{
new ChatMessage { Content = "Hello", UserId = "user2", Timestamp = DateTime.Now }
};
var users = new List<ChatUser>
{
new ChatUser { Id = "user1", Name = "John" },
new ChatUser { Id = "user2", Name = "Jane" }
};
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenChat>(parameters => parameters
.Add(p => p.Title, "Test Chat")
.Add(p => p.CurrentUserId, "user1")
.Add(p => p.Users, users)
.Add(p => p.Messages, messages)
.Add(p => p.ShowUserNames, true)
);
Assert.Contains("Jane", component.Markup);
}
[Fact]
public void RadzenChat_ShouldShowClearButtonWhenEnabled()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenChat>(parameters => parameters
.Add(p => p.Title, "Test Chat")
.Add(p => p.CurrentUserId, "user1")
.Add(p => p.Users, new List<ChatUser>())
.Add(p => p.Messages, new List<ChatMessage>())
.Add(p => p.ShowClearButton, true)
);
var clearButton = component.Find(".rz-chat-header-clear");
Assert.NotNull(clearButton);
}
[Fact]
public void RadzenChat_ShouldNotShowClearButtonWhenDisabled()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenChat>(parameters => parameters
.Add(p => p.Title, "Test Chat")
.Add(p => p.CurrentUserId, "user1")
.Add(p => p.Users, new List<ChatUser>())
.Add(p => p.Messages, new List<ChatMessage>())
.Add(p => p.ShowClearButton, false)
);
var clearButton = component.FindAll(".rz-chat-header-clear");
Assert.Empty(clearButton);
}
[Fact]
public void RadzenChat_ShouldLimitVisibleUsers()
{
var users = new List<ChatUser>
{
new ChatUser { Id = "user1", Name = "John" },
new ChatUser { Id = "user2", Name = "Jane" },
new ChatUser { Id = "user3", Name = "Bob" },
new ChatUser { Id = "user4", Name = "Alice" },
new ChatUser { Id = "user5", Name = "Charlie" },
new ChatUser { Id = "user6", Name = "David" }
};
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenChat>(parameters => parameters
.Add(p => p.Title, "Test Chat")
.Add(p => p.CurrentUserId, "user1")
.Add(p => p.Users, users)
.Add(p => p.Messages, new List<ChatMessage>())
.Add(p => p.ShowUsers, true)
.Add(p => p.MaxVisibleUsers, 3)
);
// Should show "+3" for the remaining users
Assert.Contains("+3", component.Markup);
}
[Fact]
public void RadzenChat_ShouldShowUserMessagesOnRight()
{
var messages = new List<ChatMessage>
{
new ChatMessage { Content = "My message", UserId = "user1", Timestamp = DateTime.Now }
};
var users = new List<ChatUser>
{
new ChatUser { Id = "user1", Name = "John" }
};
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenChat>(parameters => parameters
.Add(p => p.Title, "Test Chat")
.Add(p => p.CurrentUserId, "user1")
.Add(p => p.Users, users)
.Add(p => p.Messages, messages)
);
var userMessage = component.Find(".rz-chat-message-user");
Assert.NotNull(userMessage);
}
[Fact]
public void RadzenChat_ShouldShowUserMessagesOnLeft()
{
var messages = new List<ChatMessage>
{
new ChatMessage { Content = "Other message", UserId = "user2", Timestamp = DateTime.Now }
};
var users = new List<ChatUser>
{
new ChatUser { Id = "user1", Name = "John" },
new ChatUser { Id = "user2", Name = "Jane" }
};
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenChat>(parameters => parameters
.Add(p => p.Title, "Test Chat")
.Add(p => p.CurrentUserId, "user1")
.Add(p => p.Users, users)
.Add(p => p.Messages, messages)
);
var participantMessage = component.Find(".rz-chat-message-participant");
Assert.NotNull(participantMessage);
}
[Fact]
public void RadzenChat_ShouldShowAvatarInitials()
{
var users = new List<ChatUser>
{
new ChatUser { Id = "user1", Name = "John Doe" }
};
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenChat>(parameters => parameters
.Add(p => p.Title, "Test Chat")
.Add(p => p.CurrentUserId, "user1")
.Add(p => p.Users, users)
.Add(p => p.Messages, new List<ChatMessage>())
.Add(p => p.ShowUsers, true)
);
Assert.Contains("JD", component.Markup);
}
[Fact]
public void RadzenChat_ShouldShowAvatarImageWhenProvided()
{
var users = new List<ChatUser>
{
new ChatUser { Id = "user1", Name = "John", AvatarUrl = "https://example.com/avatar.jpg" }
};
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenChat>(parameters => parameters
.Add(p => p.Title, "Test Chat")
.Add(p => p.CurrentUserId, "user1")
.Add(p => p.Users, users)
.Add(p => p.Messages, new List<ChatMessage>())
.Add(p => p.ShowUsers, true)
);
var avatarImage = component.Find(".rz-chat-participant-image");
Assert.NotNull(avatarImage);
Assert.Equal("https://example.com/avatar.jpg", avatarImage.GetAttribute("src"));
}
[Fact]
public void RadzenChat_ShouldBeDisabledWhenDisabled()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenChat>(parameters => parameters
.Add(p => p.Title, "Test Chat")
.Add(p => p.CurrentUserId, "user1")
.Add(p => p.Users, new List<ChatUser>())
.Add(p => p.Messages, new List<ChatMessage>())
.Add(p => p.Disabled, true)
);
var textarea = component.Find(".rz-chat-textarea");
Assert.True(textarea.HasAttribute("disabled"));
}
[Fact]
public void RadzenChat_ShouldBeReadOnlyWhenReadOnly()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenChat>(parameters => parameters
.Add(p => p.Title, "Test Chat")
.Add(p => p.CurrentUserId, "user1")
.Add(p => p.Users, new List<ChatUser>())
.Add(p => p.Messages, new List<ChatMessage>())
.Add(p => p.ReadOnly, true)
);
var textarea = component.Find(".rz-chat-textarea");
Assert.True(textarea.HasAttribute("readonly"));
}
[Fact]
public void RadzenChat_ShouldShowCustomPlaceholder()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenChat>(parameters => parameters
.Add(p => p.Title, "Test Chat")
.Add(p => p.CurrentUserId, "user1")
.Add(p => p.Users, new List<ChatUser>())
.Add(p => p.Messages, new List<ChatMessage>())
.Add(p => p.Placeholder, "Custom placeholder")
);
var textarea = component.Find(".rz-chat-textarea");
Assert.Equal("Custom placeholder", textarea.GetAttribute("placeholder"));
}
[Fact]
public void RadzenChat_ShouldShowStreamingIndicator()
{
var messages = new List<ChatMessage>
{
new ChatMessage { Content = "Streaming message", UserId = "user1", IsStreaming = true, Timestamp = DateTime.Now }
};
var users = new List<ChatUser>
{
new ChatUser { Id = "user1", Name = "John" }
};
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenChat>(parameters => parameters
.Add(p => p.Title, "Test Chat")
.Add(p => p.CurrentUserId, "user1")
.Add(p => p.Users, users)
.Add(p => p.Messages, messages)
);
var streamingIcon = component.Find(".rz-chat-message-streaming-icon");
Assert.NotNull(streamingIcon);
}
[Fact]
public void RadzenChat_ShouldShowMessageTimestamps()
{
var timestamp = DateTime.Now.AddHours(-1);
var messages = new List<ChatMessage>
{
new ChatMessage { Content = "Test message", UserId = "user1", Timestamp = timestamp }
};
var users = new List<ChatUser>
{
new ChatUser { Id = "user1", Name = "John" }
};
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenChat>(parameters => parameters
.Add(p => p.Title, "Test Chat")
.Add(p => p.CurrentUserId, "user1")
.Add(p => p.Users, users)
.Add(p => p.Messages, messages)
);
Assert.Contains(timestamp.ToString("HH:mm"), component.Markup);
}
}
}

View File

@@ -0,0 +1,168 @@
using Bunit;
using Xunit;
using System.Collections.Generic;
namespace Radzen.Blazor.Tests
{
public class CheckBoxListTests
{
class Item
{
public int Id { get; set; }
public string Name { get; set; }
public bool Disabled { get; set; }
}
[Fact]
public void CheckBoxList_Renders_WithClassName()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenCheckBoxList<int>>();
Assert.Contains(@"rz-checkbox-list", component.Markup);
}
[Fact]
public void CheckBoxList_Renders_WithData()
{
using var ctx = new TestContext();
var data = new List<string> { "Option 1", "Option 2", "Option 3" };
var component = ctx.RenderComponent<RadzenCheckBoxList<string>>(parameters =>
{
parameters.Add(p => p.Data, data);
});
Assert.Contains("Option 1", component.Markup);
Assert.Contains("Option 2", component.Markup);
Assert.Contains("Option 3", component.Markup);
}
[Fact]
public void CheckBoxList_Renders_WithCustomTextValueProperties()
{
using var ctx = new TestContext();
var data = new List<Item>
{
new Item { Id = 1, Name = "First" },
new Item { Id = 2, Name = "Second" }
};
var component = ctx.RenderComponent<RadzenCheckBoxList<int>>(parameters =>
{
parameters.Add(p => p.Data, data);
parameters.Add(p => p.TextProperty, "Name");
parameters.Add(p => p.ValueProperty, "Id");
});
Assert.Contains("First", component.Markup);
Assert.Contains("Second", component.Markup);
}
[Fact]
public void CheckBoxList_Renders_Orientation_Horizontal()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenCheckBoxList<int>>(parameters =>
{
parameters.Add(p => p.Orientation, Orientation.Horizontal);
});
Assert.Contains("rz-flex-row", component.Markup);
}
[Fact]
public void CheckBoxList_Renders_Orientation_Vertical()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenCheckBoxList<int>>(parameters =>
{
parameters.Add(p => p.Orientation, Orientation.Vertical);
});
Assert.Contains("rz-flex-column", component.Markup);
}
[Fact]
public void CheckBoxList_Renders_Disabled()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenCheckBoxList<int>>(parameters =>
{
parameters.Add(p => p.Disabled, true);
});
Assert.Contains("disabled", component.Markup);
Assert.Contains("rz-state-disabled", component.Markup);
}
[Fact]
public void CheckBoxList_Renders_AllowSelectAll()
{
using var ctx = new TestContext();
var data = new List<string> { "Option 1", "Option 2" };
var component = ctx.RenderComponent<RadzenCheckBoxList<string>>(parameters =>
{
parameters.Add(p => p.AllowSelectAll, true);
parameters.Add(p => p.Data, data);
});
Assert.Contains("rz-multiselect-header", component.Markup);
}
[Fact]
public void CheckBoxList_Renders_SelectAllText()
{
using var ctx = new TestContext();
var data = new List<string> { "Option 1", "Option 2" };
var component = ctx.RenderComponent<RadzenCheckBoxList<string>>(parameters =>
{
parameters.Add(p => p.AllowSelectAll, true);
parameters.Add(p => p.SelectAllText, "Select All Options");
parameters.Add(p => p.Data, data);
});
Assert.Contains("Select All Options", component.Markup);
}
[Fact]
public void CheckBoxList_Renders_CheckboxInputs()
{
using var ctx = new TestContext();
var data = new List<string> { "Option 1", "Option 2" };
var component = ctx.RenderComponent<RadzenCheckBoxList<string>>(parameters =>
{
parameters.Add(p => p.Data, data);
});
Assert.Contains("type=\"checkbox\"", component.Markup);
Assert.Contains("rz-chkbox", component.Markup);
}
[Fact]
public void CheckBoxList_Renders_DisabledItems()
{
using var ctx = new TestContext();
var data = new List<Item>
{
new Item { Id = 1, Name = "Enabled", Disabled = false },
new Item { Id = 2, Name = "Disabled", Disabled = true }
};
var component = ctx.RenderComponent<RadzenCheckBoxList<int>>(parameters =>
{
parameters.Add(p => p.Data, data);
parameters.Add(p => p.TextProperty, "Name");
parameters.Add(p => p.ValueProperty, "Id");
parameters.Add(p => p.DisabledProperty, "Disabled");
});
Assert.Contains("Enabled", component.Markup);
Assert.Contains("Disabled", component.Markup);
}
}
}

View File

@@ -0,0 +1,74 @@
using Bunit;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class ColumnTests
{
[Fact]
public void Column_Renders_WithClassName()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenColumn>();
Assert.Contains(@"rz-col", component.Markup);
}
[Fact]
public void Column_Renders_ChildContent()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenColumn>(parameters =>
{
parameters.AddChildContent("<div>Column Content</div>");
});
Assert.Contains("Column Content", component.Markup);
}
[Fact]
public void Column_Renders_SizeParameter()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenColumn>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.Size, 6));
Assert.Contains("rz-col-6", component.Markup);
}
[Fact]
public void Column_Renders_SizeMD()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenColumn>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.SizeMD, 4));
Assert.Contains("rz-col-md-4", component.Markup);
}
[Fact]
public void Column_Renders_SizeSM()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenColumn>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.SizeSM, 12));
Assert.Contains("rz-col-sm-12", component.Markup);
}
[Fact]
public void Column_Renders_Offset()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenColumn>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.Offset, 2));
Assert.Contains("rz-offset-2", component.Markup);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -732,5 +732,130 @@ namespace Radzen.Blazor.Tests
var weekNumberHeader = component.Find(".rz-calendar-view th.rz-datepicker-week-number");
Assert.Contains("Wk", weekNumberHeader.InnerHtml);
}
[Fact]
public void DatePicker_Multiple_Selects_IEnumerableDateTime()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
IEnumerable<DateTime> emitted = null;
var initial = new DateTime(2024, 1, 1);
var component = ctx.RenderComponent<RadzenDatePicker<IEnumerable<DateTime>>>(parameters =>
{
parameters.Add(p => p.Multiple, true);
parameters.Add(p => p.InitialViewDate, initial);
parameters.Add(p => p.ValueChanged, args => { emitted = args; });
});
component.InvokeAsync(() => component.FindAll("td:not(.rz-calendar-other-month) span").First(e => e.TextContent == "10").ParentElement.Click());
component.InvokeAsync(() => component.FindAll("td:not(.rz-calendar-other-month) span").First(e => e.TextContent == "12").ParentElement.Click());
Assert.NotNull(emitted);
var list = emitted.ToList();
Assert.Equal(2, list.Count);
Assert.Contains(new DateTime(2024, 1, 10), list.Select(d => d.Date));
Assert.Contains(new DateTime(2024, 1, 12), list.Select(d => d.Date));
}
[Fact]
public void DatePicker_Multiple_Selects_IEnumerableNullableDateTime()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
IEnumerable<DateTime?> emitted = null;
var initial = new DateTime(2024, 2, 1);
var component = ctx.RenderComponent<RadzenDatePicker<IEnumerable<DateTime?>>>(parameters =>
{
parameters.Add(p => p.Multiple, true);
parameters.Add(p => p.InitialViewDate, initial);
parameters.Add(p => p.ValueChanged, args => { emitted = args; });
});
component.InvokeAsync(() => component.FindAll("td:not(.rz-calendar-other-month) span").First(e => e.TextContent == "3").ParentElement.Click());
component.InvokeAsync(() => component.FindAll("td:not(.rz-calendar-other-month) span").First(e => e.TextContent == "14").ParentElement.Click());
Assert.NotNull(emitted);
var list = emitted.ToList();
Assert.Equal(2, list.Count);
Assert.Contains(new DateTime(2024, 2, 3), list.Select(d => d.Value.Date));
Assert.Contains(new DateTime(2024, 2, 14), list.Select(d => d.Value.Date));
}
[Fact]
public void DatePicker_Multiple_Emits_IEnumerableDateTimeOffsetNullable_WithUtcKind()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
IEnumerable<DateTimeOffset?> emitted = null;
var initial = new DateTime(2024, 3, 1);
var component = ctx.RenderComponent<RadzenDatePicker<IEnumerable<DateTimeOffset?>>>(parameters =>
{
parameters.Add(p => p.Multiple, true);
parameters.Add(p => p.InitialViewDate, initial);
parameters.Add(p => p.Kind, DateTimeKind.Utc);
parameters.Add(p => p.ValueChanged, args => { emitted = args; });
});
component.InvokeAsync(() => component.FindAll("td:not(.rz-calendar-other-month) span").First(e => e.TextContent == "5").ParentElement.Click());
component.InvokeAsync(() => component.FindAll("td:not(.rz-calendar-other-month) span").First(e => e.TextContent == "20").ParentElement.Click());
Assert.NotNull(emitted);
var list = emitted.ToList();
Assert.Equal(2, list.Count);
Assert.All(list, dto => Assert.Equal(TimeSpan.Zero, dto.Value.Offset));
}
[Fact]
public void DatePicker_Multiple_Emits_IEnumerableDateOnlyAndTimeOnlyNullable()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
IEnumerable<DateOnly?> emittedDates = null;
IEnumerable<TimeOnly?> emittedTimes = null;
var initial = new DateTime(2024, 4, 1);
var compDates = ctx.RenderComponent<RadzenDatePicker<IEnumerable<DateOnly?>>>(parameters =>
{
parameters.Add(p => p.Multiple, true);
parameters.Add(p => p.InitialViewDate, initial);
parameters.Add(p => p.ValueChanged, args => { emittedDates = args; });
});
compDates.InvokeAsync(() => compDates.FindAll("td:not(.rz-calendar-other-month) span").First(e => e.TextContent == "7").ParentElement.Click());
compDates.InvokeAsync(() => compDates.FindAll("td:not(.rz-calendar-other-month) span").First(e => e.TextContent == "9").ParentElement.Click());
Assert.NotNull(emittedDates);
var dateList = emittedDates.ToList();
Assert.Equal(2, dateList.Count);
Assert.Contains(new DateOnly(2024, 4, 7), dateList.Select(d => d.Value));
Assert.Contains(new DateOnly(2024, 4, 9), dateList.Select(d => d.Value));
// TimeOnly? emission should produce midnight times for selected dates
var compTimes = ctx.RenderComponent<RadzenDatePicker<IEnumerable<TimeOnly?>>>(parameters =>
{
parameters.Add(p => p.Multiple, true);
parameters.Add(p => p.InitialViewDate, initial);
parameters.Add(p => p.ValueChanged, args => { emittedTimes = args; });
});
compTimes.InvokeAsync(() => compTimes.FindAll("td:not(.rz-calendar-other-month) span").First(e => e.TextContent == "1").ParentElement.Click());
compTimes.InvokeAsync(() => compTimes.FindAll("td:not(.rz-calendar-other-month) span").First(e => e.TextContent == "2").ParentElement.Click());
Assert.NotNull(emittedTimes);
var timeList = emittedTimes.ToList();
Assert.Equal(2, timeList.Count);
Assert.All(timeList, t => Assert.Equal(new TimeOnly(0, 0, 0), t.Value));
}
}
}

View File

@@ -0,0 +1,413 @@
using Bunit;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class DialogServiceTests : ComponentBase
{
public class OpenDialogTests
{
[Fact(DisplayName = "DialogOptions default values are set correctly")]
public void DialogOptions_DefaultValues_AreSetCorrectly()
{
// Arrange
var options = new DialogOptions();
var dialogService = new DialogService(null, null);
// Act
dialogService.OpenDialog<DialogServiceTests>("Test", [], options);
// Assert
Assert.Equal("600px", options.Width);
Assert.Equal("", options.Left);
Assert.Equal("", options.Top);
Assert.Equal("", options.Bottom);
Assert.Equal("", options.Height);
Assert.Equal("", options.Style);
Assert.Equal("", options.CssClass);
Assert.Equal("", options.WrapperCssClass);
Assert.Equal("", options.ContentCssClass);
}
[Fact(DisplayName = "DialogOptions values are retained after OpenDialog call")]
public void DialogOptions_Values_AreRetained_AfterOpenDialogCall()
{
// Arrange
var options = new DialogOptions
{
Width = "800px",
Left = "10px",
Top = "20px",
Bottom = "30px",
Height = "400px",
Style = "background-color: red;",
CssClass = "custom-class",
WrapperCssClass = "wrapper-class",
ContentCssClass = "content-class"
};
var dialogService = new DialogService(null, null);
// Act
dialogService.OpenDialog<DialogServiceTests>("Test", [], options);
// Assert
Assert.Equal("800px", options.Width);
Assert.Equal("10px", options.Left);
Assert.Equal("20px", options.Top);
Assert.Equal("30px", options.Bottom);
Assert.Equal("400px", options.Height);
Assert.Equal("background-color: red;", options.Style);
Assert.Equal("custom-class", options.CssClass);
Assert.Equal("wrapper-class", options.WrapperCssClass);
Assert.Equal("content-class", options.ContentCssClass);
}
[Fact(DisplayName = "DialogOptions is null and default values are set correctly")]
public void DialogOptions_IsNull_DefaultValues_AreSetCorrectly()
{
// Arrange
DialogOptions resultingOptions = null;
var dialogService = new DialogService(null, null);
dialogService.OnOpen += (title, type, parameters, options) => resultingOptions = options;
// Act
dialogService.OpenDialog<DialogServiceTests>("Test", [], null);
// Assert
Assert.NotNull(resultingOptions);
Assert.Equal("600px", resultingOptions.Width);
Assert.Equal("", resultingOptions.Left);
Assert.Equal("", resultingOptions.Top);
Assert.Equal("", resultingOptions.Bottom);
Assert.Equal("", resultingOptions.Height);
Assert.Equal("", resultingOptions.Style);
Assert.Equal("", resultingOptions.CssClass);
Assert.Equal("", resultingOptions.WrapperCssClass);
Assert.Equal("", resultingOptions.ContentCssClass);
}
[Fact(DisplayName = "Open with dynamic component type reflective calls are resolved without exception")]
public void Open_DynamicComponentType_Reflective_Calls_Resolve()
{
// Arrange
string resultingTitle = null;
Type resultingType = null;
var dialogService = new DialogService(null, null);
dialogService.OnOpen += (title, type, _, _) =>
{
resultingTitle = title;
resultingType = type;
};
dialogService.Open("Dynamic Open", typeof(RadzenButton), []);
// Assert
Assert.Equal("Dynamic Open", resultingTitle);
Assert.Equal(typeof(RadzenButton), resultingType);
}
[Fact(DisplayName = "OpenAsync with dynamic component type reflective calls are resolved without exception")]
public async Task OpenAsync_DynamicComponentType_Reflective_Calls_Resolve()
{
// Arrange
string resultingTitle = null;
Type resultingType = null;
var dialogService = new DialogService(null, null);
dialogService.OnOpen += (title, type, _, _) =>
{
resultingTitle = title;
resultingType = type;
};
var openTask = dialogService.OpenAsync("Dynamic Open", typeof(RadzenButton), []);
dialogService.Close();
await openTask;
// Assert
Assert.Equal("Dynamic Open", resultingTitle);
Assert.Equal(typeof(RadzenButton), resultingType);
}
}
public class OpenSideDialogTests
{
[Fact(DisplayName = "SideDialogOptions resizable option is retained after OpenSideDialog call")]
public void SideDialogOptions_Resizable_AreRetained_AfterOpenSideDialogCall()
{
// Arrange
var options = new SideDialogOptions { Resizable = true };
SideDialogOptions resultingOptions = null;
var dialogService = new DialogService(null, null);
dialogService.OnSideOpen += (_, _, sideOptions) => resultingOptions = sideOptions;
// Act
dialogService.OpenSide<DialogServiceTests>("Test", [], options);
// Assert
Assert.NotNull(resultingOptions);
Assert.Same(options, resultingOptions);
Assert.True(resultingOptions.Resizable);
}
[Fact(DisplayName = "Side dialog shows resize bar when Resizable is true")]
public void SideDialog_Resizable_ShowsResizeBar()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.Services.AddScoped<DialogService>();
// Render the dialog host
var cut = ctx.RenderComponent<RadzenDialog>();
// Open a side dialog with Resizable=true
var dialogService = ctx.Services.GetRequiredService<DialogService>();
cut.InvokeAsync(() => dialogService.OpenSide("Test", typeof(RadzenButton),
new Dictionary<string, object>(), new SideDialogOptions { Resizable = true }));
// Assert: the resize bar element is present
cut.WaitForAssertion(() =>
{
var markup = cut.Markup;
Assert.Contains("rz-dialog-resize-bar", markup);
// Optionally ensure the inner handle exists too
Assert.Contains("rz-resize", markup);
});
}
[Fact(DisplayName = "Side dialog hides resize bar when Resizable is false")]
public void SideDialog_NonResizable_HidesResizeBar()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.Services.AddScoped<DialogService>();
// Render the dialog host
var cut = ctx.RenderComponent<RadzenDialog>();
// Open a side dialog with Resizable=false
var dialogService = ctx.Services.GetRequiredService<DialogService>();
cut.InvokeAsync(() => dialogService.OpenSide("Test", typeof(RadzenButton),
new Dictionary<string, object>(), new SideDialogOptions()));
// Assert: the resize bar element is not present
cut.WaitForAssertion(() =>
{
var markup = cut.Markup;
Assert.DoesNotContain("rz-dialog-resize-bar", markup);
});
}
}
public class ConfirmTests
{
[Fact(DisplayName = "ConfirmOptions is null and default values are set correctly")]
public async Task ConfirmOptions_IsNull_AreSetCorrectly()
{
// Arrange
var dialogService = new DialogService(null, null);
ConfirmOptions resultingOptions = null;
dialogService.OnOpen += (title, type, parameters, options) => resultingOptions = options as ConfirmOptions;
using var cancellationTokenSource = new CancellationTokenSource();
cancellationTokenSource.Cancel();
// Act
try
{
await dialogService.Confirm(cancellationToken: cancellationTokenSource.Token);
}
catch (TaskCanceledException)
{
// this is expected
}
// Assert
Assert.NotNull(resultingOptions);
Assert.Equal("Ok", resultingOptions.OkButtonText);
Assert.Equal("Cancel", resultingOptions.CancelButtonText);
Assert.Equal("600px", resultingOptions.Width);
Assert.Equal("", resultingOptions.Style);
Assert.Equal("rz-dialog-confirm", resultingOptions.CssClass);
Assert.Equal("rz-dialog-wrapper", resultingOptions.WrapperCssClass);
}
[Fact(DisplayName = "ConfirmOptions default values are set correctly")]
public async Task ConfirmOptions_DefaultValues_AreSetCorrectly()
{
// Arrange
var dialogService = new DialogService(null, null);
ConfirmOptions resultingOptions = null;
dialogService.OnOpen += (title, type, parameters, options) => resultingOptions = options as ConfirmOptions;
using var cancellationTokenSource = new CancellationTokenSource();
cancellationTokenSource.Cancel();
// Act
try
{
await dialogService.Confirm(options: new(), cancellationToken: cancellationTokenSource.Token);
}
catch (TaskCanceledException)
{
// this is expected
}
// Assert
Assert.NotNull(resultingOptions);
Assert.Equal("Ok", resultingOptions.OkButtonText);
Assert.Equal("Cancel", resultingOptions.CancelButtonText);
Assert.Equal("600px", resultingOptions.Width);
Assert.Equal("", resultingOptions.Style);
Assert.Equal("rz-dialog-confirm", resultingOptions.CssClass);
Assert.Equal("rz-dialog-wrapper", resultingOptions.WrapperCssClass);
}
[Fact(DisplayName = "ConfirmOptions values are retained after Confirm call")]
public async Task Confirm_ProvidedValues_AreRetained()
{
// Arrange
var dialogService = new DialogService(null, null);
var options = new ConfirmOptions
{
OkButtonText = "XXX",
CancelButtonText = "YYY",
Width = "800px",
Style = "background-color: red;",
CssClass = "custom-class",
WrapperCssClass = "wrapper-class"
};
ConfirmOptions resultingOptions = null;
dialogService.OnOpen += (title, type, parameters, options) => resultingOptions = options as ConfirmOptions;
// We break out of the dialog immediately, but the options should still be set
using var cancellationTokenSource = new CancellationTokenSource();
cancellationTokenSource.Cancel();
// Act
try
{
await dialogService.Confirm("Confirm?", "Confirm", options, cancellationToken: cancellationTokenSource.Token);
}
catch (TaskCanceledException)
{
// this is expected
}
// Assert
Assert.NotNull(resultingOptions);
Assert.Equal("XXX", resultingOptions.OkButtonText);
Assert.Equal("YYY", resultingOptions.CancelButtonText);
Assert.Equal("800px", resultingOptions.Width);
Assert.Equal("background-color: red;", resultingOptions.Style);
Assert.Equal("rz-dialog-confirm custom-class", resultingOptions.CssClass);
Assert.Equal("rz-dialog-wrapper wrapper-class", resultingOptions.WrapperCssClass);
}
}
public class AlertTests
{
[Fact(DisplayName = "AlertOptions is null and default values are set correctly")]
public async Task AlertOptions_IsNull_AreSetCorrectly()
{
// Arrange
var dialogService = new DialogService(null, null);
AlertOptions resultingOptions = null;
dialogService.OnOpen += (title, type, parameters, options) => resultingOptions = options as AlertOptions;
using var cancellationTokenSource = new CancellationTokenSource();
cancellationTokenSource.Cancel();
// Act
try
{
await dialogService.Alert(cancellationToken: cancellationTokenSource.Token);
}
catch (TaskCanceledException)
{
// this is expected
}
// Assert
Assert.NotNull(resultingOptions);
Assert.Equal("Ok", resultingOptions.OkButtonText);
Assert.Equal("600px", resultingOptions.Width);
Assert.Equal("", resultingOptions.Style);
Assert.Equal("rz-dialog-alert", resultingOptions.CssClass);
Assert.Equal("rz-dialog-wrapper", resultingOptions.WrapperCssClass);
}
[Fact(DisplayName = "AlertOptions default values are set correctly")]
public async Task AlertOptions_DefaultValues_AreSetCorrectly()
{
// Arrange
var dialogService = new DialogService(null, null);
AlertOptions resultingOptions = null;
dialogService.OnOpen += (title, type, parameters, options) => resultingOptions = options as AlertOptions;
using var cancellationTokenSource = new CancellationTokenSource();
cancellationTokenSource.Cancel();
// Act
try
{
await dialogService.Alert(options: new(), cancellationToken: cancellationTokenSource.Token);
}
catch (TaskCanceledException)
{
// this is expected
}
// Assert
Assert.NotNull(resultingOptions);
Assert.Equal("Ok", resultingOptions.OkButtonText);
Assert.Equal("600px", resultingOptions.Width);
Assert.Equal("", resultingOptions.Style);
Assert.Equal("rz-dialog-alert", resultingOptions.CssClass);
Assert.Equal("rz-dialog-wrapper", resultingOptions.WrapperCssClass);
}
[Fact(DisplayName = "AlertOptions values are retained after Alert call")]
public async Task Alert_ProvidedValues_AreRetained()
{
// Arrange
var dialogService = new DialogService(null, null);
var options = new AlertOptions
{
OkButtonText = "XXX",
Width = "800px",
Style = "background-color: red;",
CssClass = "custom-class",
WrapperCssClass = "wrapper-class"
};
AlertOptions resultingOptions = null;
dialogService.OnOpen += (title, type, parameters, options) => resultingOptions = options as AlertOptions;
// We break out of the dialog immediately, but the options should still be set
using var cancellationTokenSource = new CancellationTokenSource();
cancellationTokenSource.Cancel();
// Act
try
{
await dialogService.Alert("Alert?", "Alert", options, cancellationToken: cancellationTokenSource.Token);
}
catch (TaskCanceledException)
{
// this is expected
}
// Assert
Assert.NotNull(resultingOptions);
Assert.Equal("XXX", resultingOptions.OkButtonText);
Assert.Equal("800px", resultingOptions.Width);
Assert.Equal("background-color: red;", resultingOptions.Style);
Assert.Equal("rz-dialog-alert custom-class", resultingOptions.CssClass);
Assert.Equal("rz-dialog-wrapper wrapper-class", resultingOptions.WrapperCssClass);
}
}
}
}

View File

@@ -0,0 +1,289 @@
using Bunit;
using Xunit;
using System.Collections.Generic;
using System.Linq;
namespace Radzen.Blazor.Tests
{
public class DropDownDataGridTests
{
class Customer
{
public int Id { get; set; }
public string CompanyName { get; set; }
public string ContactName { get; set; }
}
[Fact]
public void DropDownDataGrid_Renders_WithClassName()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenDropDownDataGrid<int>>();
Assert.Contains(@"rz-dropdown", component.Markup);
}
[Fact]
public void DropDownDataGrid_Renders_DropdownTrigger()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenDropDownDataGrid<int>>();
Assert.Contains("rz-dropdown-trigger", component.Markup);
Assert.Contains("rzi-chevron-down", component.Markup);
}
[Fact]
public void DropDownDataGrid_Renders_WithData()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<string> { "Item1", "Item2", "Item3" };
var component = ctx.RenderComponent<RadzenDropDownDataGrid<string>>(parameters =>
{
parameters.Add(p => p.Data, data);
});
Assert.Contains("rz-lookup-panel", component.Markup);
}
[Fact]
public void DropDownDataGrid_Renders_WithCustomTextValueProperties()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<Customer>
{
new Customer { Id = 1, CompanyName = "Acme Corp", ContactName = "John Doe" },
new Customer { Id = 2, CompanyName = "Tech Inc", ContactName = "Jane Smith" }
};
var component = ctx.RenderComponent<RadzenDropDownDataGrid<int>>(parameters =>
{
parameters.Add(p => p.Data, data);
parameters.Add(p => p.TextProperty, "CompanyName");
parameters.Add(p => p.ValueProperty, "Id");
});
Assert.Contains("rz-lookup-panel", component.Markup);
Assert.Contains("rz-data-grid", component.Markup);
}
[Fact]
public void DropDownDataGrid_Renders_DataGrid()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<string> { "Item1" };
var component = ctx.RenderComponent<RadzenDropDownDataGrid<string>>(parameters =>
{
parameters.Add(p => p.Data, data);
});
// DropDownDataGrid embeds a DataGrid
Assert.Contains("rz-data-grid", component.Markup);
}
[Fact]
public void DropDownDataGrid_Renders_AllowFiltering()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<string> { "Item1", "Item2" };
var component = ctx.RenderComponent<RadzenDropDownDataGrid<string>>(parameters =>
{
parameters.Add(p => p.AllowFiltering, true);
parameters.Add(p => p.Data, data);
});
Assert.Contains("rz-lookup-search", component.Markup);
Assert.Contains("rz-lookup-search-input", component.Markup);
}
[Fact]
public void DropDownDataGrid_Renders_Placeholder()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenDropDownDataGrid<int>>(parameters =>
{
parameters.Add(p => p.Placeholder, "Select an item");
});
Assert.Contains("Select an item", component.Markup);
Assert.Contains("rz-placeholder", component.Markup);
}
[Fact]
public void DropDownDataGrid_Renders_AllowClear_WithValue()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<string> { "Item1" };
var component = ctx.RenderComponent<RadzenDropDownDataGrid<string>>(parameters =>
{
parameters.Add(p => p.AllowClear, true);
parameters.Add(p => p.Data, data);
parameters.Add(p => p.Value, "Item1");
});
Assert.Contains("rz-dropdown-clear-icon", component.Markup);
}
[Fact]
public void DropDownDataGrid_DoesNotRender_AllowClear_WhenNotAllowed()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<string> { "Item1" };
var component = ctx.RenderComponent<RadzenDropDownDataGrid<string>>(parameters =>
{
parameters.Add(p => p.AllowClear, false);
parameters.Add(p => p.Data, data);
parameters.Add(p => p.Value, "Item1");
});
Assert.DoesNotContain("rz-dropdown-clear-icon", component.Markup);
}
[Fact]
public void DropDownDataGrid_Renders_Disabled()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenDropDownDataGrid<int>>(parameters =>
{
parameters.Add(p => p.Disabled, true);
});
Assert.Contains("disabled", component.Markup);
Assert.Contains("rz-state-disabled", component.Markup);
}
[Fact]
public void DropDownDataGrid_Renders_Multiple_Panel()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenDropDownDataGrid<IEnumerable<int>>>(parameters =>
{
parameters.Add(p => p.Multiple, true);
});
Assert.Contains("rz-multiselect-panel", component.Markup);
}
[Fact]
public void DropDownDataGrid_Renders_Multiple_WithChips()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<string> { "Item1", "Item2" };
var selectedItems = new List<string> { "Item1" };
var component = ctx.RenderComponent<RadzenDropDownDataGrid<IEnumerable<string>>>(parameters =>
{
parameters.Add(p => p.Multiple, true);
parameters.Add(p => p.Chips, true);
parameters.Add(p => p.Data, data);
parameters.Add(p => p.Value, selectedItems);
});
Assert.Contains("rz-dropdown-chips-wrapper", component.Markup);
Assert.Contains("rz-chip", component.Markup);
}
[Fact]
public void DropDownDataGrid_Renders_AllowSorting()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<Customer>
{
new Customer { Id = 1, CompanyName = "Acme" }
};
var component = ctx.RenderComponent<RadzenDropDownDataGrid<int>>(parameters =>
{
parameters.Add(p => p.AllowSorting, true);
parameters.Add(p => p.Data, data);
parameters.Add(p => p.TextProperty, "CompanyName");
});
Assert.Contains("rz-data-grid", component.Markup);
}
[Fact]
public void DropDownDataGrid_Renders_SearchTextPlaceholder()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<string> { "Item1" };
var component = ctx.RenderComponent<RadzenDropDownDataGrid<string>>(parameters =>
{
parameters.Add(p => p.AllowFiltering, true);
parameters.Add(p => p.SearchTextPlaceholder, "Type to filter...");
parameters.Add(p => p.Data, data);
});
Assert.Contains("placeholder=\"Type to filter...\"", component.Markup);
}
[Fact]
public void DropDownDataGrid_Renders_EmptyText()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenDropDownDataGrid<string>>(parameters =>
{
parameters.Add(p => p.Data, new List<string>());
parameters.Add(p => p.EmptyText, "No items found");
});
Assert.Contains("No items found", component.Markup);
}
[Fact]
public void DropDownDataGrid_Renders_PageSize()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = Enumerable.Range(1, 20).Select(i => $"Item {i}").ToList();
var component = ctx.RenderComponent<RadzenDropDownDataGrid<string>>(parameters =>
{
parameters.Add(p => p.Data, data);
parameters.Add(p => p.PageSize, 10);
});
// DataGrid with paging should be present
Assert.Contains("rz-data-grid", component.Markup);
}
[Fact]
public void DropDownDataGrid_Renders_AllowRowSelectOnRowClick()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<string> { "Item1", "Item2" };
var component = ctx.RenderComponent<RadzenDropDownDataGrid<string>>(parameters =>
{
parameters.Add(p => p.AllowRowSelectOnRowClick, true);
parameters.Add(p => p.Data, data);
});
Assert.Contains("rz-data-grid", component.Markup);
}
}
}

View File

@@ -1,10 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AngleSharp.Dom;
using Bunit;
using Microsoft.AspNetCore.Components;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
namespace Radzen.Blazor.Tests
@@ -15,7 +16,7 @@ namespace Radzen.Blazor.Tests
{
public string Text { get; set; }
public int Id { get; set; }
public bool Disabled { get; set; } = false;
public bool Disabled { get; set; }
}
private static IRenderedComponent<RadzenDropDown<T>> DropDown<T>(TestContext ctx, Action<ComponentParameterCollectionBuilder<RadzenDropDown<T>>> configure = null)
@@ -45,6 +46,7 @@ namespace Radzen.Blazor.Tests
return component;
}
[Fact]
public async Task Dropdown_SelectItem_Method_Should_Not_Throw()
{
@@ -127,7 +129,7 @@ namespace Radzen.Blazor.Tests
List<DataItem> boundCollection = [new() { Text = "Item 2" }];
var component = DropDown<string>(ctx, parameters =>
var component = DropDown<List<DataItem>>(ctx, parameters =>
{
parameters.Add(p => p.ItemComparer, new DataItemComparer());
parameters.Add(p => p.Multiple, true);
@@ -307,7 +309,7 @@ namespace Radzen.Blazor.Tests
selectedValues.Add(data[1].Id);
}
var component = ctx.RenderComponent<RadzenDropDown<DataItem>>(parameters => parameters
var component = ctx.RenderComponent<RadzenDropDown<List<int>>>(parameters => parameters
.Add(p => p.Data, data)
.Add(p => p.Value, selectedValues)
.Add(p => p.Multiple, true)
@@ -326,6 +328,321 @@ namespace Radzen.Blazor.Tests
Assert.Equal(expectedAriaCheckedValue, selectAllCheckBox.GetAttribute("aria-checked"));
}
[Fact]
public void DropDown_ReferenceGenericCollectionAssignment_HashSet_ReferencesInstance()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var originalHashSet = new HashSet<int>();
var capturedValue = (HashSet<int>)null;
var component = DropDownWithReferenceCollection<HashSet<int>>(ctx, parameters =>
{
parameters.Add(p => p.Multiple, true);
parameters.Add(p => p.Value, originalHashSet);
parameters.Add(p => p.ValueChanged, EventCallback.Factory.Create<HashSet<int>>(this, value => capturedValue = value));
parameters.Add(p => p.ValueProperty, nameof(DataItem.Id));
});
var items = component.FindAll(".rz-multiselect-item");
// Select first item
items[0].Click();
component.Render();
// Verify the same HashSet instance is Referenced
Assert.Same(originalHashSet, capturedValue);
// Verify the item was added correctly
Assert.Single(originalHashSet);
Assert.Contains(1, originalHashSet);
}
[Fact]
public void DropDown_ReferenceGenericCollectionAssignment_HashSet_MultipleSelections()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var originalHashSet = new HashSet<int> { 2 }; // Pre-populate with Item 2
var capturedValues = new List<HashSet<int>>();
var component = DropDownWithReferenceCollection<HashSet<int>>(ctx, parameters =>
{
parameters.Add(p => p.Multiple, true);
parameters.Add(p => p.Value, originalHashSet);
parameters.Add(p => p.ValueChanged, EventCallback.Factory.Create<HashSet<int>>(this, value => capturedValues.Add(value)));
parameters.Add(p => p.ValueProperty, nameof(DataItem.Id));
});
var items = component.FindAll(".rz-multiselect-item");
// Select first item (should add to existing collection)
items[0].Click();
component.Render();
// Verify the same HashSet instance is Referenced
Assert.Single(capturedValues);
Assert.Same(originalHashSet, capturedValues[0]);
// Verify both items are now in the collection
Assert.Equal(2, originalHashSet.Count);
Assert.Contains(1, originalHashSet);
Assert.Contains(2, originalHashSet);
// Deselect second item (should remove from collection)
items = component.FindAll(".rz-multiselect-item"); // Re-find items after render
items[1].Click();
component.Render();
// Verify the same HashSet instance is still Referenced
Assert.Equal(2, capturedValues.Count);
Assert.Same(originalHashSet, capturedValues[1]);
// Verify only first item remains
Assert.Single(originalHashSet);
Assert.Contains(1, originalHashSet);
Assert.DoesNotContain(2, originalHashSet);
}
[Fact]
public void DropDown_ReferenceGenericCollectionAssignment_SortedSet_ReferencesInstance()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var originalSortedSet = new SortedSet<int>();
var capturedValue = (SortedSet<int>)null;
var component = DropDownWithReferenceCollection<SortedSet<int>>(ctx, parameters =>
{
parameters.Add(p => p.Multiple, true);
parameters.Add(p => p.Value, originalSortedSet);
parameters.Add(p => p.ValueChanged, EventCallback.Factory.Create<SortedSet<int>>(this, value => capturedValue = value));
parameters.Add(p => p.ValueProperty, nameof(DataItem.Id));
});
var items = component.FindAll(".rz-multiselect-item");
// Select both items
items[0].Click();
component.Render();
items = component.FindAll(".rz-multiselect-item"); // Re-find items after first click
items[1].Click();
component.Render();
// Verify the same SortedSet instance is Referenced
Assert.Same(originalSortedSet, capturedValue);
// Verify items are sorted correctly
Assert.Equal(2, originalSortedSet.Count);
var sortedItems = originalSortedSet.ToList();
Assert.Equal(1, sortedItems[0]);
Assert.Equal(2, sortedItems[1]);
}
[Fact]
public void DropDown_ReferenceGenericCollectionAssignment_CustomCollection_ReferencesInstance()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var originalCollection = new CustomCollection<int>();
var capturedValue = (CustomCollection<int>)null;
var component = DropDownWithReferenceCollection<CustomCollection<int>>(ctx, parameters =>
{
parameters.Add(p => p.Multiple, true);
parameters.Add(p => p.Value, originalCollection);
parameters.Add(p => p.ValueChanged, EventCallback.Factory.Create<CustomCollection<int>>(this, value => capturedValue = value));
parameters.Add(p => p.ValueProperty, nameof(DataItem.Id));
});
var items = component.FindAll(".rz-multiselect-item");
// Select first item
items[0].Click();
component.Render();
// Verify the same custom collection instance is Referenced
Assert.Same(originalCollection, capturedValue);
// Verify the item was added correctly
Assert.Single(originalCollection);
Assert.Contains(1, originalCollection);
}
[Fact]
public void DropDown_ReferenceGenericCollectionAssignment_List_ReferencesInstance()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var originalList = new List<int>();
var capturedValue = (List<int>)null;
var component = DropDownWithReferenceCollection<List<int>>(ctx, parameters =>
{
parameters.Add(p => p.Multiple, true);
parameters.Add(p => p.Value, originalList);
parameters.Add(p => p.ValueChanged, EventCallback.Factory.Create<List<int>>(this, value => capturedValue = value));
parameters.Add(p => p.ValueProperty, nameof(DataItem.Id));
});
var items = component.FindAll(".rz-multiselect-item");
// Select first item
items[0].Click();
component.Render();
// For List<T>, it should now Reference the instance since we removed the IList exclusion
// Arrays are now excluded instead
Assert.Same(originalList, capturedValue);
// And the content should be correct
Assert.Single(capturedValue);
Assert.Contains(1, capturedValue);
}
[Fact]
public void DropDown_ReferenceGenericCollectionAssignment_DisabledByDefault()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var originalList = new List<int>();
var capturedValue = (List<int>)null;
var component = DropDown<List<int>>(ctx, parameters =>
{
parameters.Add(p => p.Multiple, true);
parameters.Add(p => p.Value, originalList);
parameters.Add(p => p.ValueChanged, EventCallback.Factory.Create<List<int>>(this, value => capturedValue = value));
parameters.Add(p => p.ValueProperty, nameof(DataItem.Id));
});
var items = component.FindAll(".rz-multiselect-item");
// Select first item
items[0].Click();
component.Render();
// When ReferenceCollectionOnSelection is false (default), a new instance should be created
Assert.NotSame(originalList, capturedValue);
// But the content should still be correct
Assert.Single(capturedValue);
Assert.Contains(1, capturedValue);
}
[Fact]
public void DropDown_Reset_PreservesCollectionInstanceButClears()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var originalHashSet = new HashSet<int> { 1, 2 }; // Pre-populate
var capturedValues = new List<HashSet<int>>();
var component = DropDownWithReferenceCollection<HashSet<int>>(ctx, parameters =>
{
parameters.Add(p => p.Multiple, true);
parameters.Add(p => p.Value, originalHashSet);
parameters.Add(p => p.ValueChanged, EventCallback.Factory.Create<HashSet<int>>(this, value => capturedValues.Add(value)));
parameters.Add(p => p.ValueProperty, nameof(DataItem.Id));
});
// Verify initial state - collection should have 2 items
Assert.Equal(2, originalHashSet.Count);
Assert.Contains(1, originalHashSet);
Assert.Contains(2, originalHashSet);
// Call Reset (public method that calls ClearAll internally)
component.InvokeAsync(() => component.Instance.Reset());
component.Render();
// Verify the same HashSet instance is preserved
Assert.Single(capturedValues);
Assert.Same(originalHashSet, capturedValues[0]);
// Verify the collection is now cleared
Assert.Empty(originalHashSet);
}
[Fact]
public void DropDown_SelectAll_PreservesCollectionInstanceAndPopulates()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var originalHashSet = new HashSet<int>(); // Start empty
var capturedValues = new List<HashSet<int>>();
var component = DropDownWithReferenceCollection<HashSet<int>>(ctx, parameters =>
{
parameters.Add(p => p.Multiple, true);
parameters.Add(p => p.AllowSelectAll, true);
parameters.Add(p => p.Value, originalHashSet);
parameters.Add(p => p.ValueChanged, EventCallback.Factory.Create<HashSet<int>>(this, value => capturedValues.Add(value)));
parameters.Add(p => p.ValueProperty, nameof(DataItem.Id));
});
// Verify initial state - collection should be empty
Assert.Empty(originalHashSet);
// Find and click the "Select All" checkbox
var selectAllCheckBox = component.Find(".rz-multiselect-header input[type='checkbox']");
selectAllCheckBox.Click();
component.Render();
// Verify the same HashSet instance is preserved
Assert.Single(capturedValues);
Assert.Same(originalHashSet, capturedValues[0]);
// Verify the collection now contains both items
Assert.Equal(2, originalHashSet.Count);
Assert.Contains(1, originalHashSet);
Assert.Contains(2, originalHashSet);
}
class ReferenceCollectionDropDown<T> : Radzen.Blazor.RadzenDropDown<T>
{
protected override void OnInitialized()
{
PreserveCollectionOnSelection = true;
base.OnInitialized();
}
}
private static IRenderedComponent<ReferenceCollectionDropDown<T>> DropDownWithReferenceCollection<T>(TestContext ctx, Action<ComponentParameterCollectionBuilder<ReferenceCollectionDropDown<T>>> configure = null)
{
var data = new[] {
new DataItem { Text = "Item 1", Id = 1 },
new DataItem { Text = "Item 2", Id = 2 },
};
var component = ctx.RenderComponent<ReferenceCollectionDropDown<T>>();
component.SetParametersAndRender(parameters =>
{
parameters.Add(p => p.Data, data);
parameters.Add(p => p.TextProperty, nameof(DataItem.Text));
if (configure != null)
{
configure.Invoke(parameters);
}
else
{
parameters.Add(p => p.ValueProperty, nameof(DataItem.Id));
}
});
return component;
}
class DataItemComparer : IEqualityComparer<DataItem>, IEqualityComparer<object>
{
public bool Equals(DataItem x, DataItem y)
@@ -353,5 +670,74 @@ namespace Radzen.Blazor.Tests
}
}
class CustomCollection<T> : ICollection<T>
{
private readonly List<T> _items = new();
public int Count => _items.Count;
public bool IsReadOnly => false;
public void Add(T item) => _items.Add(item);
public void Clear() => _items.Clear();
public bool Contains(T item) => _items.Contains(item);
public void CopyTo(T[] array, int arrayIndex) => _items.CopyTo(array, arrayIndex);
public bool Remove(T item) => _items.Remove(item);
public IEnumerator<T> GetEnumerator() => _items.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
[Fact]
public void DropDown_Renders_Placeholder()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenDropDown<int>>(parameters =>
{
parameters.Add(p => p.Placeholder, "Select an option");
});
Assert.Contains("Select an option", component.Markup);
Assert.Contains("rz-placeholder", component.Markup);
}
[Fact]
public void DropDown_Renders_AllowClear_WithValue()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new[] { new DataItem { Text = "Item 1", Id = 1 } };
var component = ctx.RenderComponent<RadzenDropDown<int>>(parameters =>
{
parameters.Add(p => p.AllowClear, true);
parameters.Add(p => p.Data, data);
parameters.Add(p => p.TextProperty, nameof(DataItem.Text));
parameters.Add(p => p.ValueProperty, nameof(DataItem.Id));
parameters.Add(p => p.Value, 1);
});
Assert.Contains("rz-dropdown-clear-icon", component.Markup);
}
[Fact]
public void DropDown_DoesNotRender_AllowClear_WhenNotAllowed()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new[] { new DataItem { Text = "Item 1", Id = 1 } };
var component = ctx.RenderComponent<RadzenDropDown<int>>(parameters =>
{
parameters.Add(p => p.AllowClear, false);
parameters.Add(p => p.Data, data);
parameters.Add(p => p.TextProperty, nameof(DataItem.Text));
parameters.Add(p => p.ValueProperty, nameof(DataItem.Id));
parameters.Add(p => p.Value, 1);
});
Assert.DoesNotContain("rz-dropdown-clear-icon", component.Markup);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,323 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Linq.Expressions;
using Xunit;
namespace Radzen.Blazor.Tests
{
class TestEntity
{
public string Name { get; set; }
public int Age { get; set; }
public double Salary { get; set; }
public float Score { get; set; }
public decimal Balance { get; set; }
public short Level { get; set; }
public long Population { get; set; }
public Status AccountStatus { get; set; }
public DateTime CreatedAt { get; set; }
public DateTimeOffset LastUpdated { get; set; }
public Guid Id { get; set; }
public TimeOnly StartTime { get; set; }
public DateOnly BirthDate { get; set; }
public IEnumerable<int> Scores { get; set; }
public List<string> Tags { get; set; }
public List<TestEntity> Children { get; set; }
public Address Address { get; set; }
public double[] Salaries { get; set; }
public float[] Heights { get; set; }
public decimal[] Balances { get; set; }
public short[] Levels { get; set; }
public long[] Populations { get; set; }
public string[] Names { get; set; }
public Guid[] Ids { get; set; }
public DateTime[] CreatedDates { get; set; }
public DateTimeOffset[] UpdatedDates { get; set; }
public TimeOnly[] StartTimes { get; set; }
public DateOnly[] BirthDates { get; set; }
public Status[] Statuses { get; set; }
}
enum Status
{
Active,
Inactive,
Suspended
}
class Address
{
public string City { get; set; }
public string Country { get; set; }
}
public class ExpressionSerializerTests
{
private readonly ExpressionSerializer _serializer = new ExpressionSerializer();
[Fact]
public void Serializes_SimpleBinaryExpression()
{
Expression<Func<int, bool>> expr = e => e > 10;
Assert.Equal("e => (e > 10)", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_StringEquality()
{
Expression<Func<TestEntity, bool>> expr = e => e.Name == "John";
Assert.Equal("e => (e.Name == \"John\")", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_IntComparison()
{
Expression<Func<TestEntity, bool>> expr = e => e.Age > 18;
Assert.Equal("e => (e.Age > 18)", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_DoubleComparison()
{
Expression<Func<TestEntity, bool>> expr = e => e.Salary < 50000.50;
Assert.Equal("e => (e.Salary < 50000.5)", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_FloatComparison()
{
Expression<Func<TestEntity, bool>> expr = e => e.Score >= 85.3f;
Assert.Equal("e => (e.Score >= 85.3)", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_DecimalComparison()
{
Expression<Func<TestEntity, bool>> expr = e => e.Balance <= 1000.75m;
Assert.Equal("e => (e.Balance <= 1000.75)", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_ShortComparison()
{
Expression<Func<TestEntity, bool>> expr = e => e.Level == 3;
Assert.Equal("e => (e.Level == 3)", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_LongComparison()
{
Expression<Func<TestEntity, bool>> expr = e => e.Population > 1000000L;
Assert.Equal("e => (e.Population > 1000000)", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_EnumComparison()
{
Expression<Func<TestEntity, bool>> expr = e => e.AccountStatus == Status.Inactive;
Assert.Equal("e => (e.AccountStatus == 1)", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_ArrayContainsValue()
{
Expression<Func<TestEntity, bool>> expr = e => e.Scores.Contains(100);
Assert.Equal("e => e.Scores.Contains(100)", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_ArrayNotContainsValue()
{
Expression<Func<TestEntity, bool>> expr = e => !e.Scores.Contains(100);
Assert.Equal("e => (!(e.Scores.Contains(100)))", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_ArrayInValue()
{
Expression<Func<TestEntity, bool>> expr = e => e.Scores.Intersect(new [] { 100 }).Any();
Assert.Equal("e => e.Scores.Intersect(new [] { 100 }).Any()", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_ArrayNotInValue()
{
Expression<Func<TestEntity, bool>> expr = e => e.Scores.Except(new[] { 100 }).Any();
Assert.Equal("e => e.Scores.Except(new [] { 100 }).Any()", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_ArrayInValueOposite()
{
Expression<Func<TestEntity, bool>> expr = e => new[] { 100 }.Intersect(e.Scores).Any();
Assert.Equal("e => new [] { 100 }.Intersect(e.Scores).Any()", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_ArrayNotInValueOposite()
{
Expression<Func<TestEntity, bool>> expr = e => new[] { 100 }.Except(e.Scores).Any();
Assert.Equal("e => new [] { 100 }.Except(e.Scores).Any()", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_IntArrayInValueOposite()
{
Expression<Func<TestEntity, bool>> expr = e => new[] { 100 }.Intersect(e.Scores).Any();
Assert.Equal("e => new [] { 100 }.Intersect(e.Scores).Any()", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_IntArrayNotInValueOposite()
{
Expression<Func<TestEntity, bool>> expr = e => !new[] { 100 }.Intersect(e.Scores).Any();
Assert.Equal("e => (!(new [] { 100 }.Intersect(e.Scores).Any()))", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_DoubleArrayInValueOposite()
{
Expression<Func<TestEntity, bool>> expr = e => new[] { 99.99 }.Intersect(e.Salaries).Any();
Assert.Equal("e => new [] { 99.99 }.Intersect(e.Salaries).Any()", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_FloatArrayInValueOposite()
{
Expression<Func<TestEntity, bool>> expr = e => new[] { 5.5f }.Intersect(e.Heights).Any();
Assert.Equal("e => new [] { 5.5 }.Intersect(e.Heights).Any()", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_DecimalArrayInValueOposite()
{
Expression<Func<TestEntity, bool>> expr = e => new[] { 1000.75m }.Intersect(e.Balances).Any();
Assert.Equal("e => new [] { 1000.75 }.Intersect(e.Balances).Any()", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_ShortArrayInValueOposite()
{
Expression<Func<TestEntity, bool>> expr = e => new [] { (short)3 }.Intersect(e.Levels).Any();
Assert.Equal("e => new [] { 3 }.Intersect(e.Levels).Any()", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_LongArrayInValueOposite()
{
Expression<Func<TestEntity, bool>> expr = e => new [] { 1000000L }.Intersect(e.Populations).Any();
Assert.Equal("e => new [] { 1000000 }.Intersect(e.Populations).Any()", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_StringArrayInValueOposite()
{
Expression<Func<TestEntity, bool>> expr = e => new[] { "Alice", "Bob" }.Intersect(e.Names).Any();
Assert.Equal("e => (new [] { \"Alice\", \"Bob\" }).Intersect(e.Names).Any()", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_GuidArrayInValueOposite()
{
Expression<Func<TestEntity, bool>> expr = e => new[] { Guid.Parse("12345678-1234-1234-1234-123456789abc") }.Intersect(e.Ids).Any();
Assert.Equal("e => (new [] { Guid.Parse(\"12345678-1234-1234-1234-123456789abc\") }).Intersect(e.Ids).Any()", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_DateTimeArrayInValueOposite()
{
Expression<Func<TestEntity, bool>> expr = e => new[] { DateTime.Parse("2023-01-01T00:00:00.000Z") }.Intersect(e.CreatedDates).Any();
Assert.Equal("e => (new [] { DateTime.Parse(\"2023-01-01T00:00:00.000Z\") }).Intersect(e.CreatedDates).Any()", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_DateTimeOffsetArrayInValueOposite()
{
Expression<Func<TestEntity, bool>> expr = e => new[] { DateTimeOffset.Parse("2023-01-01T10:30:00.000+00:00") }.Intersect(e.UpdatedDates).Any();
Assert.Equal("e => (new [] { DateTimeOffset.Parse(\"2023-01-01T10:30:00.000+00:00\") }).Intersect(e.UpdatedDates).Any()", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_DateTimeWithRoundtripKind()
{
Expression<Func<TestEntity, bool>> expr = e =>
DateTime.Parse("2023-01-01T00:00:00.000Z", null, DateTimeStyles.RoundtripKind) > e.CreatedAt;
Assert.Equal(
"e => (DateTime.Parse(\"2023-01-01T00:00:00.000Z\", null, (System.Globalization.DateTimeStyles)128) > e.CreatedAt)",
_serializer.Serialize(expr));
}
[Fact]
public void Serializes_TimeOnlyArrayInValueOposite()
{
Expression<Func<TestEntity, bool>> expr = e => new[] { TimeOnly.Parse("12:00:00") }.Intersect(e.StartTimes).Any();
Assert.Equal("e => (new [] { TimeOnly.Parse(\"12:00:00\") }).Intersect(e.StartTimes).Any()", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_DateOnlyArrayInValueOposite()
{
Expression<Func<TestEntity, bool>> expr = e => new[] { DateOnly.Parse("2000-01-01") }.Intersect(e.BirthDates).Any();
Assert.Equal("e => (new [] { DateOnly.Parse(\"2000-01-01\") }).Intersect(e.BirthDates).Any()", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_EnumArrayInValueOposite()
{
Expression<Func<TestEntity, bool>> expr = e => new[] { Status.Active, Status.Inactive }.Intersect(e.Statuses).Any();
Assert.Equal("e => (new [] { (Radzen.Blazor.Tests.Status)0, (Radzen.Blazor.Tests.Status)1 }).Intersect(e.Statuses).Any()", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_ListContainsValue()
{
Expression<Func<TestEntity, bool>> expr = e => e.Tags.Contains("VIP");
Assert.Equal("e => e.Tags.Contains(\"VIP\")", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_ListNotContainsValue()
{
Expression<Func<TestEntity, bool>> expr = e => !e.Tags.Contains("VIP");
Assert.Equal("e => (!(e.Tags.Contains(\"VIP\")))", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_ListAnyCheck()
{
Expression<Func<TestEntity, bool>> expr = e => e.Children.Any(c => c.Age > 18);
Assert.Equal("e => e.Children.Any(c => (c.Age > 18))", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_ListNotAnyCheck()
{
Expression<Func<TestEntity, bool>> expr = e => !e.Children.Any(c => c.Age > 18);
Assert.Equal("e => (!(e.Children.Any(c => (c.Age > 18))))", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_EntitySubPropertyCheck()
{
Expression<Func<TestEntity, bool>> expr = e => e.Address.City == "New York";
Assert.Equal("e => (e.Address.City == \"New York\")", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_ComplexExpressionWithProperties()
{
Expression<Func<TestEntity, bool>> expr = e => e.Age > 18 && e.Tags.Contains("Member") || e.Address.City == "London";
Assert.Equal("e => (((e.Age > 18) && e.Tags.Contains(\"Member\")) || (e.Address.City == \"London\"))", _serializer.Serialize(expr));
}
[Fact]
public void Serializes_NotContains()
{
Expression<Func<TestEntity, bool>> expr = e => !e.Tags.Contains("Member");
Assert.Equal("e => (!(e.Tags.Contains(\"Member\")))", _serializer.Serialize(expr));
}
}
}

View File

@@ -184,13 +184,13 @@ namespace Radzen.Blazor.Tests
Assert.Contains("SummaryContent", component.Markup);
Assert.Equal(
"",
component.Find(".rz-fieldset-content-summary").ParentElement.Attributes.First(attr => attr.Name == "style").Value
"false",
component.Find(".rz-fieldset-content-summary").ParentElement.ParentElement.Attributes.First(attr => attr.Name == "aria-hidden").Value
);
}
[Fact]
public void Fieldset_DontRenders_SummaryWhenOpen()
public void Fieldset_DoesNotRender_SummaryWhenOpen()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenFieldset>();
@@ -210,8 +210,8 @@ namespace Radzen.Blazor.Tests
Assert.Contains("SummaryContent", component.Markup);
Assert.Equal(
"display: none",
component.Find(".rz-fieldset-content-summary").ParentElement.Attributes.First(attr => attr.Name == "style").Value
"true",
component.Find(".rz-fieldset-content-summary").ParentElement.ParentElement.Attributes.First(attr => attr.Name == "aria-hidden").Value
);
}
}

View File

@@ -0,0 +1,182 @@
using Bunit;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class FileInputTests
{
[Fact]
public void FileInput_Renders_WithClassName()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenFileInput<string>>();
Assert.Contains(@"rz-fileupload", component.Markup);
}
[Fact]
public void FileInput_Renders_ChooseButton()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenFileInput<string>>();
Assert.Contains("rz-fileupload-choose", component.Markup);
Assert.Contains("rz-button", component.Markup);
}
[Fact]
public void FileInput_Renders_ChooseText()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenFileInput<string>>(parameters =>
{
parameters.Add(p => p.ChooseText, "Select File");
});
Assert.Contains("Select File", component.Markup);
}
[Fact]
public void FileInput_Renders_DefaultChooseText()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenFileInput<string>>();
Assert.Contains("Choose", component.Markup);
}
[Fact]
public void FileInput_Renders_Disabled()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenFileInput<string>>(parameters =>
{
parameters.Add(p => p.Disabled, true);
});
Assert.Contains("rz-state-disabled", component.Markup);
Assert.Contains("disabled", component.Markup);
}
[Fact]
public void FileInput_Renders_Accept()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenFileInput<string>>(parameters =>
{
parameters.Add(p => p.Accept, "application/pdf");
});
Assert.Contains("accept=\"application/pdf\"", component.Markup);
}
[Fact]
public void FileInput_Renders_DefaultAccept()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenFileInput<string>>();
Assert.Contains("accept=\"image/*\"", component.Markup);
}
[Fact]
public void FileInput_Renders_FileInputElement()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenFileInput<string>>();
Assert.Contains("type=\"file\"", component.Markup);
}
[Fact]
public void FileInput_Renders_Title_WhenSet()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenFileInput<string>>(parameters =>
{
parameters.Add(p => p.Title, "MyDocument.pdf");
parameters.Add(p => p.Value, "data:application/pdf;base64,test");
});
Assert.Contains("MyDocument.pdf", component.Markup);
}
[Fact]
public void FileInput_Renders_FileName_WhenTitleNotSet()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenFileInput<string>>(parameters =>
{
parameters.Add(p => p.FileName, "document.pdf");
parameters.Add(p => p.Value, "data:application/pdf;base64,test");
});
Assert.Contains("document.pdf", component.Markup);
}
[Fact]
public void FileInput_Renders_DeleteButton_WhenValueSet()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenFileInput<string>>(parameters =>
{
parameters.Add(p => p.Value, "data:text/plain;base64,test");
});
Assert.Contains("rz-icon-trash", component.Markup);
}
[Fact]
public void FileInput_Renders_CustomDeleteText()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenFileInput<string>>(parameters =>
{
parameters.Add(p => p.DeleteText, "Remove File");
parameters.Add(p => p.Value, "data:text/plain;base64,test");
});
Assert.Contains("title=\"Remove File\"", component.Markup);
}
[Fact]
public void FileInput_Renders_ImagePreview_ForImageFile()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenFileInput<string>>(parameters =>
{
parameters.Add(p => p.Value, "data:image/png;base64,test");
});
Assert.Contains("<img", component.Markup);
}
[Fact]
public void FileInput_Renders_ImageAlternateText()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenFileInput<string>>(parameters =>
{
parameters.Add(p => p.ImageAlternateText, "User Photo");
parameters.Add(p => p.Value, "data:image/png;base64,test");
});
Assert.Contains("alt=\"User Photo\"", component.Markup);
}
}
}

View File

@@ -0,0 +1,163 @@
using Bunit;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class FormFieldTests
{
[Fact]
public void FormField_Renders_WithClassName()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenFormField>();
Assert.Contains(@"rz-form-field", component.Markup);
}
[Fact]
public void FormField_Renders_Text()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenFormField>(parameters =>
{
parameters.Add(p => p.Text, "Email Address");
});
Assert.Contains("Email Address", component.Markup);
Assert.Contains("rz-form-field-label", component.Markup);
}
[Fact]
public void FormField_Renders_Variant_Outlined()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenFormField>(parameters =>
{
parameters.Add(p => p.Variant, Variant.Outlined);
});
Assert.Contains("rz-variant-outlined", component.Markup);
}
[Fact]
public void FormField_Renders_Variant_Filled()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenFormField>(parameters =>
{
parameters.Add(p => p.Variant, Variant.Filled);
});
Assert.Contains("rz-variant-filled", component.Markup);
}
[Fact]
public void FormField_Renders_Variant_Flat()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenFormField>(parameters =>
{
parameters.Add(p => p.Variant, Variant.Flat);
});
Assert.Contains("rz-variant-flat", component.Markup);
}
[Fact]
public void FormField_Renders_Variant_Text()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenFormField>(parameters =>
{
parameters.Add(p => p.Variant, Variant.Text);
});
Assert.Contains("rz-variant-text", component.Markup);
}
[Fact]
public void FormField_Renders_AllowFloatingLabel_True()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenFormField>(parameters =>
{
parameters.Add(p => p.AllowFloatingLabel, true);
});
Assert.Contains("rz-floating-label", component.Markup);
}
[Fact]
public void FormField_Renders_AllowFloatingLabel_False()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenFormField>(parameters =>
{
parameters.Add(p => p.AllowFloatingLabel, false);
});
Assert.DoesNotContain("rz-floating-label", component.Markup);
}
[Fact]
public void FormField_Renders_Component_Attribute()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenFormField>(parameters =>
{
parameters.Add(p => p.Component, "email-input");
});
Assert.Contains("for=\"email-input\"", component.Markup);
}
[Fact]
public void FormField_Renders_Helper()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenFormField>(parameters =>
{
parameters.Add(p => p.Helper, builder => builder.AddContent(0, "Enter your email address"));
});
Assert.Contains("rz-form-field-helper", component.Markup);
Assert.Contains("Enter your email address", component.Markup);
}
[Fact]
public void FormField_Renders_Start()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenFormField>(parameters =>
{
parameters.Add(p => p.Start, builder => builder.AddMarkupContent(0, "<span>Start</span>"));
});
Assert.Contains("rz-form-field-start", component.Markup);
Assert.Contains("Start", component.Markup);
}
[Fact]
public void FormField_Renders_End()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenFormField>(parameters =>
{
parameters.Add(p => p.End, builder => builder.AddMarkupContent(0, "<span>End</span>"));
});
Assert.Contains("rz-form-field-end", component.Markup);
Assert.Contains("End", component.Markup);
}
[Fact]
public void FormField_Renders_FormFieldContent()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenFormField>();
Assert.Contains("rz-form-field-content", component.Markup);
}
}
}

View File

@@ -0,0 +1,103 @@
using Bunit;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class HeadingTests
{
[Fact]
public void Heading_Renders_WithClassName()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenHeading>();
Assert.Contains(@"rz-heading", component.Markup);
}
[Fact]
public void Heading_Renders_TextParameter()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenHeading>();
var text = "Test Heading";
component.SetParametersAndRender(parameters => parameters.Add(p => p.Text, text));
Assert.Contains(text, component.Markup);
}
[Fact]
public void Heading_Renders_H1_ByDefault()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenHeading>();
var text = "Heading Text";
component.SetParametersAndRender(parameters => parameters.Add(p => p.Text, text));
Assert.Contains("<h1", component.Markup);
}
[Fact]
public void Heading_Renders_H2_Size()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenHeading>();
var text = "Heading 2";
component.SetParametersAndRender(parameters =>
{
parameters.Add(p => p.Text, text);
parameters.Add(p => p.Size, "H2");
});
Assert.Contains("<h2", component.Markup);
Assert.Contains(text, component.Markup);
}
[Fact]
public void Heading_Renders_H3_Size()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenHeading>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.Size, "H3"));
Assert.Contains("<h3", component.Markup);
}
[Fact]
public void Heading_Renders_H4_Size()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenHeading>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.Size, "H4"));
Assert.Contains("<h4", component.Markup);
}
[Fact]
public void Heading_Renders_H5_Size()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenHeading>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.Size, "H5"));
Assert.Contains("<h5", component.Markup);
}
[Fact]
public void Heading_Renders_H6_Size()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenHeading>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.Size, "H6"));
Assert.Contains("<h6", component.Markup);
}
}
}

View File

@@ -0,0 +1,104 @@
using Bunit;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class HtmlEditorTests
{
[Fact]
public void HtmlEditor_Renders_WithClassName()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.Services.AddScoped<DialogService>();
var component = ctx.RenderComponent<RadzenHtmlEditor>();
Assert.Contains(@"rz-html-editor", component.Markup);
}
[Fact]
public void HtmlEditor_Renders_ShowToolbar_True()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.Services.AddScoped<DialogService>();
var component = ctx.RenderComponent<RadzenHtmlEditor>(parameters =>
{
parameters.Add(p => p.ShowToolbar, true);
});
Assert.Contains("rz-html-editor-toolbar", component.Markup);
}
[Fact]
public void HtmlEditor_Renders_ShowToolbar_False()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.Services.AddScoped<DialogService>();
var component = ctx.RenderComponent<RadzenHtmlEditor>(parameters =>
{
parameters.Add(p => p.ShowToolbar, false);
});
Assert.DoesNotContain("rz-html-editor-toolbar", component.Markup);
}
[Fact]
public void HtmlEditor_Renders_Mode_Design()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.Services.AddScoped<DialogService>();
var component = ctx.RenderComponent<RadzenHtmlEditor>(parameters =>
{
parameters.Add(p => p.Mode, HtmlEditorMode.Design);
});
// Design mode shows the content editable div
Assert.Contains("contenteditable", component.Markup);
}
[Fact]
public void HtmlEditor_Renders_Mode_Source()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.Services.AddScoped<DialogService>();
var component = ctx.RenderComponent<RadzenHtmlEditor>(parameters =>
{
parameters.Add(p => p.Mode, HtmlEditorMode.Source);
});
// Source mode shows the textarea for HTML editing
Assert.Contains("rz-html-editor-source", component.Markup);
}
[Fact]
public void HtmlEditor_Renders_Disabled_Attribute()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.Services.AddScoped<DialogService>();
var component = ctx.RenderComponent<RadzenHtmlEditor>(parameters =>
{
parameters.Add(p => p.Disabled, true);
});
Assert.Contains("disabled", component.Markup);
}
[Fact]
public void HtmlEditor_Renders_ContentArea()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.Services.AddScoped<DialogService>();
var component = ctx.RenderComponent<RadzenHtmlEditor>();
Assert.Contains("rz-html-editor-content", component.Markup);
}
}
}

View File

@@ -0,0 +1,197 @@
using Bunit;
using Xunit;
using System.Collections.Generic;
namespace Radzen.Blazor.Tests
{
public class ListBoxTests
{
class Item
{
public int Id { get; set; }
public string Name { get; set; }
}
[Fact]
public void ListBox_Renders_WithClassName()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenListBox<int>>();
Assert.Contains(@"rz-listbox", component.Markup);
}
[Fact]
public void ListBox_Renders_WithData_SimpleList()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<string> { "Apple", "Banana", "Cherry" };
var component = ctx.RenderComponent<RadzenListBox<string>>(parameters =>
{
parameters.Add(p => p.Data, data);
});
Assert.Contains("Apple", component.Markup);
Assert.Contains("Banana", component.Markup);
Assert.Contains("Cherry", component.Markup);
}
[Fact]
public void ListBox_Renders_WithData_CustomTextValueProperties()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<Item>
{
new Item { Id = 1, Name = "First Item" },
new Item { Id = 2, Name = "Second Item" }
};
var component = ctx.RenderComponent<RadzenListBox<int>>(parameters =>
{
parameters.Add(p => p.Data, data);
parameters.Add(p => p.TextProperty, "Name");
parameters.Add(p => p.ValueProperty, "Id");
});
Assert.Contains("First Item", component.Markup);
Assert.Contains("Second Item", component.Markup);
}
[Fact]
public void ListBox_Renders_AllowFiltering()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenListBox<int>>(parameters =>
{
parameters.Add(p => p.AllowFiltering, true);
parameters.Add(p => p.Data, new List<string> { "Item1", "Item2" });
});
Assert.Contains("rz-listbox-filter", component.Markup);
Assert.Contains("rz-listbox-header", component.Markup);
}
[Fact]
public void ListBox_Renders_Disabled_Attribute()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenListBox<int>>(parameters =>
{
parameters.Add(p => p.Disabled, true);
});
Assert.Contains("disabled", component.Markup);
}
[Fact]
public void ListBox_Renders_Multiple_WithSelectAll()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenListBox<IEnumerable<int>>>(parameters =>
{
parameters.Add(p => p.Multiple, true);
parameters.Add(p => p.SelectAllText, "Select All Items");
parameters.Add(p => p.Data, new List<string> { "Item1", "Item2" });
});
Assert.Contains("Select All Items", component.Markup);
Assert.Contains("rz-chkbox", component.Markup);
}
[Fact]
public void ListBox_Renders_FilterPlaceholder()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenListBox<int>>(parameters =>
{
parameters.Add(p => p.Placeholder, "Select an item");
parameters.Add(p => p.AllowFiltering, true);
parameters.Add(p => p.Data, new List<string> { "Item1", "Item2" });
});
Assert.Contains("Select an item", component.Markup);
}
[Fact]
public void ListBox_Renders_Multiple_WithCheckboxes()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<string> { "Item1", "Item2" };
var component = ctx.RenderComponent<RadzenListBox<IEnumerable<string>>>(parameters =>
{
parameters.Add(p => p.Multiple, true);
parameters.Add(p => p.Data, data);
});
// Multiple selection shows checkboxes in header
Assert.Contains("rz-listbox-header-w-checkbox", component.Markup);
}
[Fact]
public void ListBox_Renders_ReadOnly()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenListBox<int>>(parameters =>
{
parameters.Add(p => p.ReadOnly, true);
});
Assert.Contains("readonly", component.Markup);
}
[Fact]
public void ListBox_Renders_TabIndex()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenListBox<int>>();
Assert.Contains("tabindex=", component.Markup);
}
[Fact]
public void ListBox_Renders_ListWrapper()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<string> { "Item1" };
var component = ctx.RenderComponent<RadzenListBox<string>>(parameters =>
{
parameters.Add(p => p.Data, data);
});
Assert.Contains("rz-listbox-list-wrapper", component.Markup);
Assert.Contains("rz-listbox-list", component.Markup);
}
[Fact]
public void ListBox_Renders_SearchAriaLabel()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenListBox<int>>(parameters =>
{
parameters.Add(p => p.AllowFiltering, true);
parameters.Add(p => p.SearchAriaLabel, "Search items");
parameters.Add(p => p.Data, new List<string> { "Item1" });
});
Assert.Contains("aria-label=\"Search items\"", component.Markup);
}
}
}

View File

@@ -11,6 +11,17 @@ public class EmphasisTests
}
[Theory]
[InlineData(@"**foo** bar
baz",@"<document>
<paragraph>
<strong>
<text>foo</text>
</strong>
<text> bar</text>
<softbreak />
<text>baz</text>
</paragraph>
</document>")]
[InlineData("*foo bar*",
@"<document>
<paragraph>

View File

@@ -141,4 +141,28 @@ foo <!---> foo -->
{
Assert.Equal(expected, ToXml(markdown));
}
[Theory]
[InlineData("***foo bar***", @"<document>
<paragraph>
<emph>
<strong>
<text>foo bar</text>
</strong>
</emph>
</paragraph>
</document>")]
[InlineData("___foo bar___", @"<document>
<paragraph>
<emph>
<strong>
<text>foo bar</text>
</strong>
</emph>
</paragraph>
</document>")]
public void Parse_BoldAndItalic_ShouldNotThrowException(string markdown, string expected)
{
Assert.Equal(expected, ToXml(markdown));
}
}

View File

@@ -354,6 +354,15 @@ bar)", @"<document>
</link>
</paragraph>
</document>")]
[InlineData(@"[![alt](img)](url)", @"<document>
<paragraph>
<link destination=""url"" title="""">
<image destination=""img"" title="""">
<text>alt</text>
</image>
</link>
</paragraph>
</document>")]
public void Parse_LinkTextIsInlineContent(string markdown, string expected)
{

View File

@@ -135,6 +135,28 @@ bar | baz", @"<document>
<cell />
</row>
</table>
</document>")]
[InlineData(@"| abc | def |
| --- | --- |
c:\\foo", @"<document>
<table>
<header>
<cell>
<text>abc</text>
</cell>
<cell>
<text>def</text>
</cell>
</header>
<row>
<cell>
<text>c:</text>
<text>\</text>
<text>foo</text>
</cell>
<cell />
</row>
</table>
</document>")]
public void Parse_Table(string markdown, string expected)
{

View File

@@ -0,0 +1,65 @@
using Bunit;
using Microsoft.AspNetCore.Components;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class MediaQueryTests
{
[Fact]
public void MediaQuery_Renders()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenMediaQuery>(parameters =>
{
parameters.Add(p => p.Query, "(max-width: 768px)");
});
Assert.NotNull(component.Instance);
}
[Fact]
public void MediaQuery_HasQueryParameter()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var query = "(max-width: 1024px)";
var component = ctx.RenderComponent<RadzenMediaQuery>(parameters =>
{
parameters.Add(p => p.Query, query);
});
Assert.Equal(query, component.Instance.Query);
}
[Fact]
public void MediaQuery_InvokesChangeCallback()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
bool changeInvoked = false;
bool matchResult = false;
var component = ctx.RenderComponent<RadzenMediaQuery>(parameters =>
{
parameters.Add(p => p.Query, "(max-width: 768px)");
parameters.Add(p => p.Change, EventCallback.Factory.Create<bool>(this, (matches) =>
{
changeInvoked = true;
matchResult = matches;
}));
});
// Invoke the JSInvokable method directly
component.Instance.OnChange(true);
Assert.True(changeInvoked);
Assert.True(matchResult);
}
}
}

View File

@@ -0,0 +1,58 @@
using Bunit;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class MenuTests
{
[Fact]
public void Menu_Renders_WithClassName()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenMenu>();
Assert.Contains(@"rz-menu", component.Markup);
}
[Fact]
public void Menu_Renders_Responsive_True()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenMenu>(parameters =>
{
parameters.Add(p => p.Responsive, true);
});
Assert.Contains("rz-menu-closed", component.Markup);
Assert.Contains("rz-menu-toggle", component.Markup);
}
[Fact]
public void Menu_Renders_Responsive_False()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenMenu>(parameters =>
{
parameters.Add(p => p.Responsive, false);
});
Assert.DoesNotContain("rz-menu-toggle", component.Markup);
Assert.DoesNotContain("rz-menu-closed", component.Markup);
}
[Fact]
public void Menu_Renders_CustomToggleAriaLabel()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenMenu>(parameters =>
{
parameters.Add(p => p.Responsive, true);
parameters.Add(p => p.ToggleAriaLabel, "Open navigation");
});
Assert.Contains("Open navigation", component.Markup);
}
}
}

View File

@@ -16,7 +16,7 @@ namespace Radzen.Blazor.Tests
public string Name { get; set; }
public FieldIdentifier FieldIdentifier => throw new System.NotImplementedException();
public FieldIdentifier FieldIdentifier { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public object GetValue()
{

View File

@@ -1,8 +1,9 @@
using Bunit;
using Bunit.TestDoubles;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.Extensions.DependencyInjection.Extensions;
using System.Collections.Generic;
using System.Linq;
using Xunit;
namespace Radzen.Blazor.Tests
@@ -22,6 +23,9 @@ namespace Radzen.Blazor.Tests
}
private static string CreatePanelMenu(string currentAbsoluteUrl, NavLinkMatch match, params string[] urls)
=> CreatePanelMenu(currentAbsoluteUrl, match, new Dictionary<string, bool>(urls.Select(url => new KeyValuePair<string, bool>(url, false))));
private static string CreatePanelMenu(string currentAbsoluteUrl, NavLinkMatch match, Dictionary<string, bool> urls)
{
using var ctx = new TestContext();
@@ -30,12 +34,13 @@ namespace Radzen.Blazor.Tests
var component = ctx.RenderComponent<RadzenPanelMenu>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.Match, match).AddChildContent(builder =>
component.SetParametersAndRender(parameters => parameters.Add(p => p.Match, match).AddChildContent(builder =>
{
foreach (var url in urls)
{
builder.OpenComponent<RadzenPanelMenuItem>(0);
builder.AddAttribute(1, nameof(RadzenPanelMenuItem.Path), url);
builder.AddAttribute(1, nameof(RadzenPanelMenuItem.Path), url.Key);
builder.AddAttribute(2, nameof(RadzenPanelMenuItem.Disabled), url.Value);
builder.CloseComponent();
}
}));
@@ -55,6 +60,19 @@ namespace Radzen.Blazor.Tests
Assert.Equal(firstIndex, lastIndex);
}
[Fact]
public void RadzenPanelMenu_CanDisableMenuItem()
{
var urls = new Dictionary<string, bool>
{
{"/datagrid", false},
{"/disabled-url", true}
};
var component = CreatePanelMenu("http://www.example.com/", NavLinkMatch.All, urls);
Assert.Contains("rz-state-disabled", component);
}
[Fact]
public void RadzenPanelMenu_MatchesQueryStringParameters()
{

View File

@@ -198,14 +198,10 @@ namespace Radzen.Blazor.Tests
});
Assert.Contains("SummaryContent", component.Markup);
Assert.Equal(
"display: block",
component.Find(".rz-panel-content-summary").ParentElement.Attributes.First(attr => attr.Name == "style").Value
);
}
[Fact]
public void Panel_DontRenders_SummaryWhenOpen()
public void Panel_DoesNotRender_SummaryWhenOpen()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenPanel>();
@@ -225,8 +221,8 @@ namespace Radzen.Blazor.Tests
Assert.Contains("SummaryContent", component.Markup);
Assert.Equal(
"display: none",
component.Find(".rz-panel-content-summary").ParentElement.Attributes.First(attr => attr.Name == "style").Value
"true",
component.Find(".rz-panel-content-summary").ParentElement.ParentElement.Attributes.First(attr => attr.Name == "aria-hidden").Value
);
}
}

View File

@@ -171,24 +171,49 @@ namespace Radzen.Blazor.Tests
Assert.Contains(@$"autofocus", component.Markup);
}
[Fact]
public void Password_Raises_ChangedEvent()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenPassword>();
var raised = false;
var hasRaised = false;
var value = "Test";
object newValue = null;
component.SetParametersAndRender(parameters => parameters.Add(p => p.Change, args => { raised = true; newValue = args; }));
var component = ctx.RenderComponent<RadzenPassword>(parameters =>
{
parameters.Add(p => p.Change, args => { hasRaised = true; newValue = args; });
parameters.Add(p => p.Immediate, false);
});
component.Find("input").Change(value);
var inputElement = component.Find("input");
inputElement.Change(value);
Assert.True(raised);
Assert.True(object.Equals(value, newValue));
Assert.DoesNotContain("oninput", inputElement.ToMarkup());
Assert.True(hasRaised);
Assert.Equal(value, newValue);
}
[Fact]
public void Password_Raises_InputEvent()
{
using var ctx = new TestContext();
var hasRaised = false;
var value = "Test";
object newValue = null;
var component = ctx.RenderComponent<RadzenPassword>(parameters =>
{
parameters.Add(p => p.Change, args => { hasRaised = true; newValue = args; });
parameters.Add(p => p.Immediate, true);
});
var inputElement = component.Find("input");
inputElement.Input(value);
Assert.DoesNotContain("onchange", inputElement.ToMarkup());
Assert.True(hasRaised);
Assert.Equal(value, newValue);
}
[Fact]

View File

@@ -0,0 +1,220 @@
using Bunit;
using Xunit;
using System.Collections.Generic;
using System.Linq;
namespace Radzen.Blazor.Tests
{
public class PickListTests
{
class Item
{
public int Id { get; set; }
public string Name { get; set; }
}
[Fact]
public void PickList_Renders_WithClassName()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenPickList<Item>>();
Assert.Contains(@"rz-picklist", component.Markup);
}
[Fact]
public void PickList_Renders_SourceAndTargetLists()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenPickList<Item>>();
Assert.Contains("rz-picklist-source-wrapper", component.Markup);
Assert.Contains("rz-picklist-target-wrapper", component.Markup);
}
[Fact]
public void PickList_Renders_TransferButtons()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenPickList<Item>>();
Assert.Contains("rz-picklist-buttons", component.Markup);
}
[Fact]
public void PickList_Renders_Orientation_Horizontal()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenPickList<Item>>(parameters =>
{
parameters.Add(p => p.Orientation, Orientation.Horizontal);
});
Assert.Contains("rz-flex-row", component.Markup);
}
[Fact]
public void PickList_Renders_Orientation_Vertical()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenPickList<Item>>(parameters =>
{
parameters.Add(p => p.Orientation, Orientation.Vertical);
});
Assert.Contains("rz-flex-column", component.Markup);
}
[Fact]
public void PickList_Renders_AllowFiltering()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<Item>
{
new Item { Id = 1, Name = "Item 1" }
};
var component = ctx.RenderComponent<RadzenPickList<Item>>(parameters =>
{
parameters.Add(p => p.AllowFiltering, true);
parameters.Add(p => p.Source, data);
parameters.Add(p => p.TextProperty, "Name");
});
Assert.Contains("rz-listbox-filter", component.Markup);
}
[Fact]
public void PickList_Renders_SourceData()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<Item>
{
new Item { Id = 1, Name = "Source Item 1" },
new Item { Id = 2, Name = "Source Item 2" }
};
var component = ctx.RenderComponent<RadzenPickList<Item>>(parameters =>
{
parameters.Add(p => p.Source, data);
parameters.Add(p => p.TextProperty, "Name");
});
Assert.Contains("Source Item 1", component.Markup);
Assert.Contains("Source Item 2", component.Markup);
}
[Fact]
public void PickList_Renders_ShowHeader()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenPickList<Item>>(parameters =>
{
parameters.Add(p => p.ShowHeader, true);
parameters.Add(p => p.SourceHeader, builder => builder.AddContent(0, "Available Items"));
parameters.Add(p => p.TargetHeader, builder => builder.AddContent(0, "Selected Items"));
});
Assert.Contains("Available Items", component.Markup);
Assert.Contains("Selected Items", component.Markup);
}
[Fact]
public void PickList_Renders_AllowMoveAll_Buttons()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<Item> { new Item { Id = 1, Name = "Item" } };
var component = ctx.RenderComponent<RadzenPickList<Item>>(parameters =>
{
parameters.Add(p => p.AllowMoveAll, true);
parameters.Add(p => p.Source, data);
});
// Should have 4 buttons when AllowMoveAll is true
var buttonCount = System.Text.RegularExpressions.Regex.Matches(component.Markup, "rz-button").Count;
Assert.True(buttonCount >= 4);
}
[Fact]
public void PickList_Renders_Disabled()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenPickList<Item>>(parameters =>
{
parameters.Add(p => p.Disabled, true);
});
Assert.Contains("disabled", component.Markup);
}
[Fact]
public void PickList_GetSelectedSources_Respects_ValueProperty_Single()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<Item>
{
new Item { Id = 1, Name = "A" },
new Item { Id = 2, Name = "B" }
};
var component = ctx.RenderComponent<RadzenPickList<Item>>(parameters =>
{
parameters.Add(p => p.Source, data);
parameters.Add(p => p.TextProperty, "Name");
parameters.Add(p => p.ValueProperty, "Id");
parameters.Add(p => p.Multiple, false);
});
// Simulate ListBox selection when ValueProperty is set: selectedSourceItems becomes the value (Id)
var field = typeof(RadzenPickList<Item>).GetField("selectedSourceItems", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
field.SetValue(component.Instance, 2);
var selected = component.Instance.GetSelectedSources();
Assert.Single(selected);
Assert.Equal(2, selected.First().Id);
}
[Fact]
public void PickList_GetSelectedSources_Respects_ValueProperty_Multiple()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var data = new List<Item>
{
new Item { Id = 1, Name = "A" },
new Item { Id = 2, Name = "B" },
new Item { Id = 3, Name = "C" }
};
var component = ctx.RenderComponent<RadzenPickList<Item>>(parameters =>
{
parameters.Add(p => p.Source, data);
parameters.Add(p => p.TextProperty, "Name");
parameters.Add(p => p.ValueProperty, "Id");
parameters.Add(p => p.Multiple, true);
});
// Simulate ListBox selection when ValueProperty is set: selectedSourceItems becomes IEnumerable of values (Ids)
var field = typeof(RadzenPickList<Item>).GetField("selectedSourceItems", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
field.SetValue(component.Instance, new[] { 1, 3 });
var selected = component.Instance.GetSelectedSources().Select(i => i.Id).OrderBy(i => i).ToArray();
Assert.Equal(new[] { 1, 3 }, selected);
}
}
}

View File

@@ -0,0 +1,644 @@
using Bunit;
using Microsoft.AspNetCore.Components;
using Radzen;
using Radzen.Blazor;
using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class PivotDataGridTests
{
private static readonly List<SalesData> SampleData = new()
{
new SalesData { Region = "North", Category = "Electronics", Product = "Laptop", Amount = 1000, Year = 2023 },
new SalesData { Region = "North", Category = "Electronics", Product = "Laptop", Amount = 1500, Year = 2024 },
new SalesData { Region = "South", Category = "Home", Product = "Vacuum", Amount = 500, Year = 2023 }
};
public class SalesData
{
public string Region { get; set; }
public string Category { get; set; }
public string Product { get; set; }
public double Amount { get; set; }
public int Year { get; set; }
}
[Fact]
public void PivotDataGrid_Renders_CssClasses()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx);
component.WaitForAssertion(() =>
{
Assert.Contains("rz-pivot-data-grid", component.Markup);
Assert.Contains("rz-pivot-table", component.Markup);
});
}
[Fact]
public void PivotDataGrid_Renders_RowAndColumnHeaders()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx);
component.WaitForAssertion(() =>
{
var table = component.Find(".rz-pivot-content .rz-pivot-table");
var headers = table.GetElementsByClassName("rz-pivot-header-text").Select(h => h.TextContent.Trim()).ToList();
var aggregateHeaders = table.GetElementsByClassName("rz-pivot-aggregate-header").Select(h => h.TextContent.Trim()).ToList();
Assert.Contains("Region", headers);
Assert.Contains("2023", headers);
Assert.Contains("Sales", aggregateHeaders);
});
}
[Fact]
public void PivotDataGrid_AllowSorting_RendersSortableClass()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx, parameters =>
{
parameters.Add(p => p.AllowSorting, true);
});
component.WaitForAssertion(() =>
{
var sortableHeaders = component.FindAll(".rz-pivot-header-content.rz-sortable");
Assert.NotEmpty(sortableHeaders);
});
}
[Fact]
public void PivotDataGrid_AllowFiltering_RendersFilterIcon()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx, parameters =>
{
parameters.Add(p => p.AllowFiltering, true);
});
component.WaitForAssertion(() =>
{
var filterIcons = component.FindAll(".rz-grid-filter-icon");
Assert.NotEmpty(filterIcons);
});
}
[Fact]
public void PivotDataGrid_Renders_AggregateValues()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx);
component.WaitForAssertion(() =>
{
Assert.Contains("1000", component.Markup);
Assert.Contains("1500", component.Markup);
Assert.Contains("500", component.Markup);
});
}
[Fact]
public void PivotDataGrid_DisallowFiltering_HidesFilterIcon()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx, parameters =>
{
parameters.Add(p => p.AllowFiltering, false);
});
component.WaitForAssertion(() =>
{
var filterIcons = component.FindAll(".rz-grid-filter-icon");
Assert.Empty(filterIcons);
});
}
[Fact]
public void PivotDataGrid_DisallowSorting_HidesSortableClass()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx, parameters =>
{
parameters.Add(p => p.AllowSorting, false);
});
component.WaitForAssertion(() =>
{
var sortableHeaders = component.FindAll(".rz-pivot-header-content.rz-sortable");
Assert.Empty(sortableHeaders);
});
}
[Fact]
public void PivotDataGrid_ShowColumnsTotals_RendersFooter()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx, parameters =>
{
parameters.Add(p => p.ShowColumnsTotals, true);
});
component.WaitForAssertion(() =>
{
var footer = component.FindAll(".rz-pivot-footer");
Assert.NotEmpty(footer);
});
}
[Fact]
public void PivotDataGrid_HideColumnsTotals_NoFooter()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx, parameters =>
{
parameters.Add(p => p.ShowColumnsTotals, false);
});
component.WaitForAssertion(() =>
{
var footer = component.FindAll(".rz-pivot-footer");
Assert.Empty(footer);
});
}
[Fact]
public void PivotDataGrid_Renders_DefaultEmptyText()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = ctx.RenderComponent<RadzenPivotDataGrid<SalesData>>(parameters =>
{
parameters.Add(p => p.Data, new List<SalesData>());
parameters.Add(p => p.AllowFieldsPicking, false);
});
component.WaitForAssertion(() =>
{
Assert.Contains("No records to display.", component.Markup);
});
}
[Fact]
public void PivotDataGrid_Renders_CustomEmptyText()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = ctx.RenderComponent<RadzenPivotDataGrid<SalesData>>(parameters =>
{
parameters.Add(p => p.Data, new List<SalesData>());
parameters.Add(p => p.EmptyText, "No data available");
parameters.Add(p => p.AllowFieldsPicking, false);
});
component.WaitForAssertion(() =>
{
Assert.Contains("No data available", component.Markup);
});
}
[Fact]
public void PivotDataGrid_AllowPaging_RendersPager()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx, parameters =>
{
parameters.Add(p => p.AllowPaging, true);
parameters.Add(p => p.PageSize, 2);
});
component.WaitForAssertion(() =>
{
Assert.Contains("rz-pager", component.Markup);
});
}
[Fact]
public void PivotDataGrid_DisallowPaging_HidesPager()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx, parameters =>
{
parameters.Add(p => p.AllowPaging, false);
});
component.WaitForAssertion(() =>
{
Assert.DoesNotContain("rz-pager", component.Markup);
});
}
[Fact]
public void PivotDataGrid_PagerPosition_Top()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx, parameters =>
{
parameters.Add(p => p.AllowPaging, true);
parameters.Add(p => p.PagerPosition, PagerPosition.Top);
parameters.Add(p => p.PageSize, 2);
});
component.WaitForAssertion(() =>
{
Assert.Contains("rz-pager", component.Markup);
});
}
[Fact]
public void PivotDataGrid_PagerPosition_TopAndBottom()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx, parameters =>
{
parameters.Add(p => p.AllowPaging, true);
parameters.Add(p => p.PagerPosition, PagerPosition.TopAndBottom);
parameters.Add(p => p.PageSize, 2);
});
component.WaitForAssertion(() =>
{
var pagers = component.FindAll(".rz-pager");
Assert.True(pagers.Count >= 1); // Should have at least one pager
});
}
[Fact]
public void PivotDataGrid_Density_Compact()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx, parameters =>
{
parameters.Add(p => p.AllowPaging, true);
parameters.Add(p => p.PageSize, 1); // Force pager to show with small page size
parameters.Add(p => p.AllowFieldsPicking, false);
parameters.Add(p => p.Density, Density.Compact);
});
component.WaitForAssertion(() =>
{
Assert.Contains("rz-density-compact", component.Markup);
});
}
[Fact]
public void PivotDataGrid_AllowAlternatingRows_True()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx, parameters =>
{
parameters.Add(p => p.AllowAlternatingRows, true);
});
component.WaitForAssertion(() =>
{
Assert.Contains("rz-grid-table-striped", component.Markup);
});
}
[Fact]
public void PivotDataGrid_AllowAlternatingRows_False()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx, parameters =>
{
parameters.Add(p => p.AllowAlternatingRows, false);
});
component.WaitForAssertion(() =>
{
Assert.DoesNotContain("rz-grid-table-striped", component.Markup);
});
}
[Fact]
public void PivotDataGrid_AllowFieldsPicking_ShowsPanel()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx, parameters =>
{
parameters.Add(p => p.AllowFieldsPicking, true);
});
component.WaitForAssertion(() =>
{
Assert.Contains("rz-panel", component.Markup);
});
}
[Fact]
public void PivotDataGrid_AllowFieldsPicking_False_HidesPanel()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx, parameters =>
{
parameters.Add(p => p.AllowFieldsPicking, false);
});
component.WaitForAssertion(() =>
{
Assert.DoesNotContain("rz-panel", component.Markup);
});
}
[Fact]
public void PivotDataGrid_Renders_AllowDrillDown()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx, parameters =>
{
parameters.Add(p => p.AllowDrillDown, true);
});
component.WaitForAssertion(() =>
{
// Should render pivot content
Assert.Contains("rz-pivot-content", component.Markup);
});
}
[Fact]
public void PivotDataGrid_Renders_RowValues()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx);
component.WaitForAssertion(() =>
{
var cells = component.FindAll(".rz-pivot-row-header");
var cellTexts = cells.Select(c => c.TextContent.Trim()).ToList();
Assert.Contains("North", cellTexts);
Assert.Contains("South", cellTexts);
});
}
[Fact]
public void PivotDataGrid_Renders_MultipleRows()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = ctx.RenderComponent<RadzenPivotDataGrid<SalesData>>(parameters =>
{
parameters.Add(p => p.Data, SampleData);
parameters.Add<RenderFragment>(p => p.Rows, builder =>
{
builder.OpenComponent<RadzenPivotRow<SalesData>>(0);
builder.AddAttribute(1, nameof(RadzenPivotRow<SalesData>.Property), nameof(SalesData.Region));
builder.AddAttribute(2, nameof(RadzenPivotRow<SalesData>.Title), "Region");
builder.CloseComponent();
builder.OpenComponent<RadzenPivotRow<SalesData>>(2);
builder.AddAttribute(3, nameof(RadzenPivotRow<SalesData>.Property), nameof(SalesData.Category));
builder.AddAttribute(4, nameof(RadzenPivotRow<SalesData>.Title), "Category");
builder.CloseComponent();
});
parameters.Add<RenderFragment>(p => p.Columns, builder =>
{
builder.OpenComponent<RadzenPivotColumn<SalesData>>(0);
builder.AddAttribute(1, nameof(RadzenPivotColumn<SalesData>.Property), nameof(SalesData.Year));
builder.AddAttribute(2, nameof(RadzenPivotColumn<SalesData>.Title), "Year");
builder.CloseComponent();
});
parameters.Add<RenderFragment>(p => p.Aggregates, builder =>
{
builder.OpenComponent<RadzenPivotAggregate<SalesData>>(0);
builder.AddAttribute(1, nameof(RadzenPivotAggregate<SalesData>.Property), nameof(SalesData.Amount));
builder.AddAttribute(2, nameof(RadzenPivotAggregate<SalesData>.Title), "Sales");
builder.AddAttribute(3, nameof(RadzenPivotAggregate<SalesData>.Aggregate), AggregateFunction.Sum);
builder.CloseComponent();
});
});
component.WaitForAssertion(() =>
{
var headers = component.FindAll(".rz-pivot-header-text").Select(h => h.TextContent.Trim()).ToList();
Assert.Contains("Region", headers);
Assert.Contains("Category", headers);
});
}
[Fact]
public void PivotDataGrid_Renders_MultipleAggregates()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = ctx.RenderComponent<RadzenPivotDataGrid<SalesData>>(parameters =>
{
parameters.Add(p => p.Data, SampleData);
parameters.Add<RenderFragment>(p => p.Rows, builder =>
{
builder.OpenComponent<RadzenPivotRow<SalesData>>(0);
builder.AddAttribute(1, nameof(RadzenPivotRow<SalesData>.Property), nameof(SalesData.Region));
builder.AddAttribute(2, nameof(RadzenPivotRow<SalesData>.Title), "Region");
builder.CloseComponent();
});
parameters.Add<RenderFragment>(p => p.Columns, builder =>
{
builder.OpenComponent<RadzenPivotColumn<SalesData>>(0);
builder.AddAttribute(1, nameof(RadzenPivotColumn<SalesData>.Property), nameof(SalesData.Year));
builder.AddAttribute(2, nameof(RadzenPivotColumn<SalesData>.Title), "Year");
builder.CloseComponent();
});
parameters.Add<RenderFragment>(p => p.Aggregates, builder =>
{
builder.OpenComponent<RadzenPivotAggregate<SalesData>>(0);
builder.AddAttribute(1, nameof(RadzenPivotAggregate<SalesData>.Property), nameof(SalesData.Amount));
builder.AddAttribute(2, nameof(RadzenPivotAggregate<SalesData>.Title), "Total Sales");
builder.AddAttribute(3, nameof(RadzenPivotAggregate<SalesData>.Aggregate), AggregateFunction.Sum);
builder.CloseComponent();
builder.OpenComponent<RadzenPivotAggregate<SalesData>>(4);
builder.AddAttribute(5, nameof(RadzenPivotAggregate<SalesData>.Property), nameof(SalesData.Amount));
builder.AddAttribute(6, nameof(RadzenPivotAggregate<SalesData>.Title), "Count Sales");
builder.AddAttribute(7, nameof(RadzenPivotAggregate<SalesData>.Aggregate), AggregateFunction.Count);
builder.CloseComponent();
});
});
component.WaitForAssertion(() =>
{
var aggregateHeaders = component.FindAll(".rz-pivot-aggregate-header").Select(h => h.TextContent.Trim()).ToList();
Assert.Contains("Total Sales", aggregateHeaders);
Assert.Contains("Count Sales", aggregateHeaders);
});
}
[Fact]
public void PivotDataGrid_Renders_AlternatingRowClasses()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = RenderPivotDataGrid(ctx, parameters =>
{
parameters.Add(p => p.AllowAlternatingRows, true);
});
component.WaitForAssertion(() =>
{
Assert.Contains("rz-pivot-row-even", component.Markup);
Assert.Contains("rz-pivot-row-odd", component.Markup);
});
}
[Fact]
public void PivotDataGrid_PageSize_DefaultsTo10()
{
var grid = new RadzenPivotDataGrid<SalesData>();
Assert.Equal(10, grid.PageSize);
}
[Fact]
public void PivotDataGrid_AllowSorting_DefaultsToTrue()
{
var grid = new RadzenPivotDataGrid<SalesData>();
Assert.True(grid.AllowSorting);
}
[Fact]
public void PivotDataGrid_AllowFiltering_DefaultsToTrue()
{
var grid = new RadzenPivotDataGrid<SalesData>();
Assert.True(grid.AllowFiltering);
}
[Fact]
public void PivotDataGrid_AllowAlternatingRows_DefaultsToTrue()
{
var grid = new RadzenPivotDataGrid<SalesData>();
Assert.True(grid.AllowAlternatingRows);
}
[Fact]
public void PivotDataGrid_AllowDrillDown_DefaultsToTrue()
{
var grid = new RadzenPivotDataGrid<SalesData>();
Assert.True(grid.AllowDrillDown);
}
[Fact]
public void PivotDataGrid_AllowFieldsPicking_DefaultsToTrue()
{
var grid = new RadzenPivotDataGrid<SalesData>();
Assert.True(grid.AllowFieldsPicking);
}
private static IRenderedComponent<RadzenPivotDataGrid<SalesData>> RenderPivotDataGrid(TestContext ctx, Action<ComponentParameterCollectionBuilder<RadzenPivotDataGrid<SalesData>>> configure = null)
{
return ctx.RenderComponent<RadzenPivotDataGrid<SalesData>>(parameters =>
{
parameters.Add(p => p.Data, SampleData);
parameters.Add<RenderFragment>(p => p.Rows, builder =>
{
builder.OpenComponent<RadzenPivotRow<SalesData>>(0);
builder.AddAttribute(1, nameof(RadzenPivotRow<SalesData>.Property), nameof(SalesData.Region));
builder.AddAttribute(2, nameof(RadzenPivotRow<SalesData>.Title), "Region");
builder.CloseComponent();
});
parameters.Add<RenderFragment>(p => p.Columns, builder =>
{
builder.OpenComponent<RadzenPivotColumn<SalesData>>(0);
builder.AddAttribute(1, nameof(RadzenPivotColumn<SalesData>.Property), nameof(SalesData.Year));
builder.AddAttribute(2, nameof(RadzenPivotColumn<SalesData>.Title), "Year");
builder.CloseComponent();
});
parameters.Add<RenderFragment>(p => p.Aggregates, builder =>
{
builder.OpenComponent<RadzenPivotAggregate<SalesData>>(0);
builder.AddAttribute(1, nameof(RadzenPivotAggregate<SalesData>.Property), nameof(SalesData.Amount));
builder.AddAttribute(2, nameof(RadzenPivotAggregate<SalesData>.Title), "Sales");
builder.AddAttribute(3, nameof(RadzenPivotAggregate<SalesData>.Aggregate), AggregateFunction.Sum);
builder.CloseComponent();
});
configure?.Invoke(parameters);
});
}
}
}

View File

@@ -0,0 +1,120 @@
using Bunit;
using Microsoft.AspNetCore.Components;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class ProfileMenuItemTests
{
[Fact]
public void ProfileMenuItem_Renders_TextParameter()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenProfileMenu>(parameters =>
{
parameters.Add(p => p.ChildContent, builder =>
{
builder.OpenComponent<RadzenProfileMenuItem>(0);
builder.AddAttribute(1, "Text", "Profile");
builder.CloseComponent();
});
});
Assert.Contains("Profile", component.Markup);
}
[Fact]
public void ProfileMenuItem_Renders_IconParameter()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenProfileMenu>(parameters =>
{
parameters.Add(p => p.ChildContent, builder =>
{
builder.OpenComponent<RadzenProfileMenuItem>(0);
builder.AddAttribute(1, "Icon", "account_circle");
builder.AddAttribute(2, "Text", "Profile");
builder.CloseComponent();
});
});
Assert.Contains("account_circle", component.Markup);
}
[Fact]
public void ProfileMenuItem_Template_OverridesText()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenProfileMenu>(parameters =>
{
parameters.Add(p => p.ChildContent, builder =>
{
builder.OpenComponent<RadzenProfileMenuItem>(0);
builder.AddAttribute(1, "Text", "This should not appear");
builder.AddAttribute(2, "Template", (RenderFragment)((templateBuilder) =>
{
templateBuilder.OpenElement(0, "span");
templateBuilder.AddAttribute(1, "class", "template-content");
templateBuilder.AddContent(2, "Template Content");
templateBuilder.CloseElement();
}));
builder.CloseComponent();
});
});
// Template should be rendered
Assert.Contains("template-content", component.Markup);
// Text should not be rendered in navigation-item-text span when Template is present
Assert.DoesNotContain("<span class=\"rz-navigation-item-text\">This should not appear</span>", component.Markup);
}
[Fact]
public void ProfileMenuItem_Renders_TemplateWithSwitch()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenProfileMenu>(parameters =>
{
parameters.Add(p => p.ChildContent, builder =>
{
builder.OpenComponent<RadzenProfileMenuItem>(0);
builder.AddAttribute(1, "Icon", "settings");
builder.AddAttribute(2, "Template", (RenderFragment)((templateBuilder) =>
{
templateBuilder.OpenComponent<RadzenSwitch>(0);
templateBuilder.CloseComponent();
}));
builder.CloseComponent();
});
});
// Icon should still be rendered
Assert.Contains("settings", component.Markup);
// Switch should be rendered from template
Assert.Contains("rz-switch", component.Markup);
}
[Fact]
public void ProfileMenuItem_Renders_PathParameter()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenProfileMenu>(parameters =>
{
parameters.Add(p => p.ChildContent, builder =>
{
builder.OpenComponent<RadzenProfileMenuItem>(0);
builder.AddAttribute(1, "Text", "Settings");
builder.AddAttribute(2, "Path", "/settings");
builder.CloseComponent();
});
});
Assert.Contains("href=\"/settings\"", component.Markup);
}
}
}

View File

@@ -142,5 +142,45 @@ namespace Radzen.Blazor.Tests
component.SetParametersAndRender(parameters => parameters.Add(p => p.Mode, ProgressBarMode.Indeterminate));
Assert.Contains(@$"rz-progressbar-info", component.Markup);
}
[Fact]
public void ProgressBar_Renders_ShowValue_True()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenProgressBar>(parameters =>
{
parameters.Add(p => p.ShowValue, true);
parameters.Add(p => p.Value, 50);
});
Assert.Contains("rz-progressbar-label", component.Markup);
Assert.Contains("50%", component.Markup);
}
[Fact]
public void ProgressBar_Renders_ShowValue_False()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenProgressBar>(parameters =>
{
parameters.Add(p => p.ShowValue, false);
parameters.Add(p => p.Value, 50);
});
Assert.DoesNotContain("rz-progressbar-label", component.Markup);
}
[Fact]
public void ProgressBar_Renders_Template()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenProgressBar>(parameters =>
{
parameters.Add(p => p.Value, 75);
parameters.Add(p => p.Template, builder => builder.AddContent(0, "Custom: 75%"));
});
Assert.Contains("Custom: 75%", component.Markup);
}
}
}

View File

@@ -113,5 +113,43 @@ namespace Radzen.Blazor.Tests
{
public List<string> Values { get; set; }
}
[Fact]
public void GetProperty_Should_Resolve_DescriptionProperty()
{
var descriptionProperty = PropertyAccess.GetProperty(typeof(ISimpleInterface), nameof(ISimpleInterface.Description));
Assert.NotNull(descriptionProperty);
}
[Fact]
public void GetProperty_Should_Resolve_NameProperty()
{
var nameProperty = PropertyAccess.GetProperty(typeof(ISimpleInterface), nameof(ISimpleInterface.Name));
Assert.NotNull(nameProperty);
}
[Fact]
public void GetProperty_Should_Resolve_IdProperty()
{
var idProperty = PropertyAccess.GetProperty(typeof(ISimpleInterface), nameof(ISimpleBaseInterface.Id));
Assert.NotNull(idProperty);
}
interface ISimpleInterface : ISimpleNestedInterface
{
string Description { get; set; }
}
interface ISimpleNestedInterface : ISimpleBaseInterface
{
string Name { get; set; }
}
interface ISimpleBaseInterface
{
int Id { get; set; }
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,62 @@
using Bunit;
using System.Collections.Generic;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class RadioButtonListTests
{
[Fact]
public void RadioButtonList_Renders_WithClassName()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenRadioButtonList<int>>();
Assert.Contains(@"rz-radio-button-list", component.Markup);
}
[Fact]
public void RadioButtonList_Renders_Orientation()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenRadioButtonList<int>>(parameters =>
{
parameters.Add(p => p.Items, builder =>
{
builder.OpenComponent<RadzenRadioButtonListItem<int>>(0);
builder.AddAttribute(1, "Text", "Option 1");
builder.AddAttribute(2, "Value", 1);
builder.CloseComponent();
});
});
component.SetParametersAndRender(parameters => parameters.Add(p => p.Orientation, Orientation.Horizontal));
// Orientation is applied via RadzenStack which uses flex-direction
Assert.Contains("rz-flex-row", component.Markup);
component.SetParametersAndRender(parameters => parameters.Add(p => p.Orientation, Orientation.Vertical));
Assert.Contains("rz-flex-column", component.Markup);
}
[Fact]
public void RadioButtonList_Renders_Disabled()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenRadioButtonList<int>>(parameters =>
{
parameters.Add(p => p.Disabled, true);
parameters.Add(p => p.Items, builder =>
{
builder.OpenComponent<RadzenRadioButtonListItem<int>>(0);
builder.AddAttribute(1, "Text", "Option 1");
builder.AddAttribute(2, "Value", 1);
builder.CloseComponent();
});
});
// Disabled class is on the radio button items
Assert.Contains("rz-state-disabled", component.Markup);
}
}
}

View File

@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>disable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageReference Include="bunit.web" Version="1.36.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">

View File

@@ -0,0 +1,82 @@
using Bunit;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class RatingTests
{
[Fact]
public void Rating_Renders_WithClassName()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenRating>();
Assert.Contains(@"rz-rating", component.Markup);
}
[Fact]
public void Rating_Renders_Stars()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenRating>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.Stars, 5));
// Should render 5 star icons (rzi-star or rzi-star-o) + 1 clear button icon = 6 total
var starCount = System.Text.RegularExpressions.Regex.Matches(component.Markup, "rz-rating-icon").Count;
Assert.Equal(6, starCount); // 5 stars + 1 clear button
}
[Fact]
public void Rating_Renders_CustomStarCount()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenRating>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.Stars, 10));
var starCount = System.Text.RegularExpressions.Regex.Matches(component.Markup, "rz-rating-icon").Count;
Assert.Equal(11, starCount); // 10 stars + 1 clear button
}
[Fact]
public void Rating_Renders_Value()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenRating>();
component.SetParametersAndRender(parameters =>
{
parameters.Add(p => p.Value, 3);
parameters.Add(p => p.Stars, 5);
});
// Should have 3 filled stars (rzi-star) and 2 outline stars (rzi-star-o)
var filledStars = System.Text.RegularExpressions.Regex.Matches(component.Markup, "rzi-star\"").Count;
Assert.Equal(3, filledStars);
}
[Fact]
public void Rating_Renders_ReadOnly()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenRating>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.ReadOnly, true));
Assert.Contains("rz-state-readonly", component.Markup);
}
[Fact]
public void Rating_Renders_Disabled()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenRating>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.Disabled, true));
Assert.Contains("rz-state-disabled", component.Markup);
}
}
}

View File

@@ -0,0 +1,63 @@
using Bunit;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class RowTests
{
[Fact]
public void Row_Renders_WithClassName()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenRow>();
Assert.Contains(@"rz-row", component.Markup);
}
[Fact]
public void Row_Renders_ChildContent()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenRow>(parameters =>
{
parameters.AddChildContent("<div>Row Content</div>");
});
Assert.Contains("Row Content", component.Markup);
}
[Fact]
public void Row_Renders_Gap()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenRow>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.Gap, "2rem"));
Assert.Contains("--rz-gap:2rem", component.Markup);
}
[Fact]
public void Row_Renders_RowGap()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenRow>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.RowGap, "1.5rem"));
Assert.Contains("--rz-row-gap:1.5rem", component.Markup);
}
[Fact]
public void Row_Renders_ColumnGap()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenRow>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.Gap, "1rem"));
Assert.Contains("--rz-gap:1rem", component.Markup);
}
}
}

View File

@@ -0,0 +1,63 @@
using Bunit;
using Microsoft.JSInterop;
using Microsoft.Extensions.DependencyInjection;
using Radzen.Blazor;
using Radzen.Blazor.Rendering;
using Radzen;
using System;
using System.Collections.Generic;
using System.Globalization;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class SchedulerYearRangeTests
{
class Appointment
{
public DateTime Start { get; set; }
public DateTime End { get; set; }
public string Text { get; set; } = "";
}
[Fact]
public void YearView_StartMonthJanuary_IncludesLastDaysOfYear_WhenYearStartsOnFirstDayOfWeek()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.Services.AddScoped<DialogService>();
ctx.JSInterop.Setup<Rect>("Radzen.createScheduler", _ => true)
.SetResult(new Rect { Left = 0, Top = 0, Width = 200, Height = 200 });
// Make the first day of week Monday and use a year where Jan 1 is Monday (2024-01-01).
var culture = (CultureInfo)CultureInfo.InvariantCulture.Clone();
culture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Monday;
var appointments = new List<Appointment>
{
new() { Start = new DateTime(2024, 12, 31), End = new DateTime(2025, 1, 1), Text = "Year end" }
};
var cut = ctx.RenderComponent<RadzenScheduler<Appointment>>(p =>
{
p.Add(x => x.Culture, culture);
p.Add(x => x.Date, new DateTime(2024, 6, 1));
p.Add(x => x.Data, appointments);
p.Add(x => x.StartProperty, nameof(Appointment.Start));
p.Add(x => x.EndProperty, nameof(Appointment.End));
p.Add(x => x.TextProperty, nameof(Appointment.Text));
p.AddChildContent<RadzenYearView>(v => v.Add(x => x.StartMonth, Radzen.Month.January));
});
var view = Assert.IsType<RadzenYearView>(cut.Instance.SelectedView);
// View should start on 2023-12-25 (one extra week above since 2024-01-01 is Monday).
Assert.Equal(new DateTime(2023, 12, 25), view.StartDate.Date);
// View end must include 2024-12-31 (it should extend to end-of-week containing the real year end).
Assert.True(view.EndDate.Date >= new DateTime(2024, 12, 31), $"EndDate was {view.EndDate:yyyy-MM-dd}");
}
}
}

View File

@@ -0,0 +1,45 @@
using Bunit;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class SecurityCodeTests
{
[Fact]
public void SecurityCode_Renders_WithClassName()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenSecurityCode>();
Assert.Contains(@"rz-security-code", component.Markup);
}
[Fact]
public void SecurityCode_Renders_Count()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenSecurityCode>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.Count, 6));
// Should render 6 input boxes + 1 hidden input for form submission = 7 total
var inputCount = System.Text.RegularExpressions.Regex.Matches(component.Markup, "<input").Count;
Assert.Equal(7, inputCount);
}
[Fact]
public void SecurityCode_Renders_Disabled()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
var component = ctx.RenderComponent<RadzenSecurityCode>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.Disabled, true));
Assert.Contains("disabled", component.Markup);
}
}
}

View File

@@ -0,0 +1,83 @@
using Bunit;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class SelectBarTests
{
[Fact]
public void SelectBar_Renders_WithClassName()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenSelectBar<int>>();
Assert.Contains(@"rz-selectbar", component.Markup);
}
[Fact]
public void SelectBar_Renders_Orientation()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenSelectBar<int>>(parameters =>
{
parameters.Add(p => p.Items, builder =>
{
builder.OpenComponent<RadzenSelectBarItem>(0);
builder.AddAttribute(1, "Text", "Option 1");
builder.AddAttribute(2, "Value", 1);
builder.CloseComponent();
});
});
component.SetParametersAndRender(parameters => parameters.Add(p => p.Orientation, Orientation.Horizontal));
Assert.Contains("rz-selectbar-horizontal", component.Markup);
component.SetParametersAndRender(parameters => parameters.Add(p => p.Orientation, Orientation.Vertical));
Assert.Contains("rz-selectbar-vertical", component.Markup);
}
[Fact]
public void SelectBar_Renders_Multiple()
{
using var ctx = new TestContext();
// When Multiple is true, TValue should be IEnumerable<T>
var component = ctx.RenderComponent<RadzenSelectBar<System.Collections.Generic.IEnumerable<int>>>(parameters =>
{
parameters.Add(p => p.Multiple, true);
parameters.Add(p => p.Items, builder =>
{
builder.OpenComponent<RadzenSelectBarItem>(0);
builder.AddAttribute(1, "Text", "Option 1");
builder.AddAttribute(2, "Value", 1);
builder.CloseComponent();
});
});
Assert.NotNull(component.Instance);
Assert.True(component.Instance.Multiple);
}
[Fact]
public void SelectBar_Renders_Size()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenSelectBar<int>>(parameters =>
{
parameters.Add(p => p.Items, builder =>
{
builder.OpenComponent<RadzenSelectBarItem>(0);
builder.AddAttribute(1, "Text", "Option 1");
builder.AddAttribute(2, "Value", 1);
builder.CloseComponent();
});
});
component.SetParametersAndRender(parameters => parameters.Add(p => p.Size, ButtonSize.Small));
Assert.Contains("rz-button-sm", component.Markup);
component.SetParametersAndRender(parameters => parameters.Add(p => p.Size, ButtonSize.Large));
Assert.Contains("rz-button-lg", component.Markup);
}
}
}

View File

@@ -0,0 +1,65 @@
using Bunit;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class SidebarToggleTests
{
[Fact]
public void SidebarToggle_Renders_WithClassName()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenSidebarToggle>();
Assert.Contains(@"rz-sidebar-toggle", component.Markup);
}
[Fact]
public void SidebarToggle_Renders_DefaultIcon()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenSidebarToggle>();
Assert.Contains("menu", component.Markup);
}
[Fact]
public void SidebarToggle_Renders_CustomIcon()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenSidebarToggle>();
var icon = "close";
component.SetParametersAndRender(parameters => parameters.Add(p => p.Icon, icon));
Assert.Contains(icon, component.Markup);
}
[Fact]
public void SidebarToggle_Renders_AriaLabel()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenSidebarToggle>();
var ariaLabel = "Toggle Navigation";
component.SetParametersAndRender(parameters => parameters.Add(p => p.ToggleAriaLabel, ariaLabel));
Assert.Contains($"aria-label=\"{ariaLabel}\"", component.Markup);
}
[Fact]
public void SidebarToggle_Raises_ClickEvent()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenSidebarToggle>();
var clicked = false;
component.SetParametersAndRender(parameters => parameters.Add(p => p.Click, args => { clicked = true; }));
component.Find("button").Click();
Assert.True(clicked);
}
}
}

View File

@@ -0,0 +1,158 @@
using Bunit;
using Radzen.Blazor.Rendering;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class SkeletonTests
{
[Fact]
public void Skeleton_Renders_CssClass()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = ctx.RenderComponent<RadzenSkeleton>();
Assert.Contains("rz-skeleton", component.Markup);
Assert.Contains("rz-skeleton-text", component.Markup);
}
[Fact]
public void Skeleton_Renders_TypeParameter()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = ctx.RenderComponent<RadzenSkeleton>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.Variant, SkeletonVariant.Circular));
Assert.Contains("rz-skeleton", component.Markup);
Assert.Contains("rz-skeleton-circular", component.Markup);
}
[Theory]
[InlineData(SkeletonVariant.Text, "rz-skeleton-text")]
[InlineData(SkeletonVariant.Circular, "rz-skeleton-circular")]
[InlineData(SkeletonVariant.Rectangular, "rz-skeleton-rectangular")]
public void Skeleton_Renders_AllTypes(SkeletonVariant type, string expectedClass)
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = ctx.RenderComponent<RadzenSkeleton>(parameters => parameters.Add(p => p.Variant, type));
Assert.Contains("rz-skeleton", component.Markup);
Assert.Contains(expectedClass, component.Markup);
}
[Fact]
public void Skeleton_Renders_AnimationParameter()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = ctx.RenderComponent<RadzenSkeleton>();
component.SetParametersAndRender(parameters => parameters.Add(p => p.Animation, SkeletonAnimation.Wave));
Assert.Contains("rz-skeleton", component.Markup);
Assert.Contains("rz-skeleton-wave", component.Markup);
}
[Theory]
[InlineData(SkeletonAnimation.Wave, "rz-skeleton-wave")]
[InlineData(SkeletonAnimation.Pulse, "rz-skeleton-pulse")]
public void Skeleton_Renders_AllAnimations(SkeletonAnimation animation, string expectedClass)
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = ctx.RenderComponent<RadzenSkeleton>(parameters => parameters.Add(p => p.Animation, animation));
Assert.Contains("rz-skeleton", component.Markup);
Assert.Contains(expectedClass, component.Markup);
}
[Fact]
public void Skeleton_Renders_StyleParameter()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = ctx.RenderComponent<RadzenSkeleton>();
var style = "width: 200px; height: 20px;";
component.SetParametersAndRender(parameters => parameters.Add(p => p.Style, style));
Assert.Contains($"style=\"{style}\"", component.Markup);
}
[Fact]
public void Skeleton_Renders_VisibleParameter()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = ctx.RenderComponent<RadzenSkeleton>();
// Should be visible by default
Assert.Contains("rz-skeleton", component.Markup);
component.SetParametersAndRender(parameters => parameters.Add(p => p.Visible, false));
// Should not render when not visible
Assert.DoesNotContain("rz-skeleton", component.Markup);
}
[Fact]
public void Skeleton_Renders_UnmatchedParameter()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = ctx.RenderComponent<RadzenSkeleton>();
component.SetParametersAndRender(parameters => parameters.AddUnmatched("data-testid", "skeleton-test"));
Assert.Contains("data-testid=\"skeleton-test\"", component.Markup);
}
[Fact]
public void Skeleton_DefaultType_IsText()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = ctx.RenderComponent<RadzenSkeleton>();
// Should render with text type by default
Assert.Contains("rz-skeleton-text", component.Markup);
}
[Fact]
public void Skeleton_DefaultAnimation_IsNone()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = ctx.RenderComponent<RadzenSkeleton>();
// Should not render animation classes by default
Assert.DoesNotContain("rz-skeleton-wave", component.Markup);
Assert.DoesNotContain("rz-skeleton-pulse", component.Markup);
}
}
}

View File

@@ -89,5 +89,71 @@ namespace Radzen.Blazor.Tests
Assert.Contains(@$"autofocus", component.Markup);
}
[Fact]
public void Slider_Renders_Orientation_Vertical()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = ctx.RenderComponent<RadzenSlider<int>>(parameters =>
{
parameters.Add(p => p.Orientation, Orientation.Vertical);
});
Assert.Contains("rz-slider-vertical", component.Markup);
}
[Fact]
public void Slider_Renders_Disabled()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = ctx.RenderComponent<RadzenSlider<int>>(parameters =>
{
parameters.Add(p => p.Disabled, true);
});
Assert.Contains("rz-state-disabled", component.Markup);
}
[Fact]
public void Slider_Renders_SliderHandle()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = ctx.RenderComponent<RadzenSlider<int>>();
Assert.Contains("rz-slider-handle", component.Markup);
}
[Fact]
public void Slider_Renders_SliderRange()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = ctx.RenderComponent<RadzenSlider<int>>();
Assert.Contains("rz-slider-range", component.Markup);
}
[Fact]
public void Slider_Renders_TabIndex()
{
using var ctx = new TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.JSInterop.SetupModule("_content/Radzen.Blazor/Radzen.Blazor.js");
var component = ctx.RenderComponent<RadzenSlider<int>>();
Assert.Contains("tabindex=\"0\"", component.Markup);
}
}
}

View File

@@ -0,0 +1,42 @@
using Bunit;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class SplitterTests
{
[Fact]
public void Splitter_Renders_WithClassName()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenSplitter>();
Assert.Contains(@"rz-splitter", component.Markup);
}
[Fact]
public void Splitter_Renders_Orientation_Horizontal()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenSplitter>(parameters =>
{
parameters.Add(p => p.Orientation, Orientation.Horizontal);
});
Assert.Contains("rz-splitter-horizontal", component.Markup);
}
[Fact]
public void Splitter_Renders_Orientation_Vertical()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenSplitter>(parameters =>
{
parameters.Add(p => p.Orientation, Orientation.Vertical);
});
Assert.Contains("rz-splitter-vertical", component.Markup);
}
}
}

View File

@@ -0,0 +1,49 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class AggregateFunctionTests
{
readonly Sheet sheet = new(15, 5);
void SeedWithErrors()
{
sheet.Cells["A1"].Formula = "=A2/0"; // #DIV/0!
sheet.Cells["A2"].Value = 82;
sheet.Cells["A3"].Value = 72;
sheet.Cells["A4"].Value = 65;
sheet.Cells["A5"].Value = 30;
sheet.Cells["A6"].Value = 95;
sheet.Cells["A7"].Formula = "=0/0"; // #DIV/0!
sheet.Cells["A8"].Value = 63;
sheet.Cells["A9"].Value = 31;
sheet.Cells["A10"].Value = 53;
sheet.Cells["A11"].Value = 96;
}
[Fact]
public void ShouldComputeMaxIgnoringErrors()
{
SeedWithErrors();
sheet.Cells["B1"].Formula = "=AGGREGATE(4,6,A1:A11)"; // MAX ignoring errors
Assert.Equal(96d, sheet.Cells["B1"].Value);
}
[Fact]
public void ShouldComputeLargeIgnoringErrors()
{
SeedWithErrors();
sheet.Cells["B1"].Formula = "=AGGREGATE(14,6,A1:A11,3)"; // LARGE k=3 ignoring errors
Assert.Equal(82d, sheet.Cells["B1"].Value);
}
[Fact]
public void ShouldReturnValueErrorWhenKMissingForSmall()
{
SeedWithErrors();
sheet.Cells["B1"].Formula = "=AGGREGATE(15,6,A1:A11)"; // SMALL requires k
Assert.Equal(CellError.Value, sheet.Cells["B1"].Value);
}
}

View File

@@ -0,0 +1,160 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class AndFunctionTests
{
readonly Sheet sheet = new(5, 5);
[Fact]
public void ShouldEvaluateAndFunctionWithAllTrueValues()
{
sheet.Cells["A1"].Value = true;
sheet.Cells["A2"].Value = true;
sheet.Cells["A3"].Formula = "=AND(A1,A2)";
Assert.Equal(true, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateAndFunctionWithOneFalseValue()
{
sheet.Cells["A1"].Value = true;
sheet.Cells["A2"].Value = false;
sheet.Cells["A3"].Formula = "=AND(A1,A2)";
Assert.Equal(false, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateAndFunctionWithAllFalseValues()
{
sheet.Cells["A1"].Value = false;
sheet.Cells["A2"].Value = false;
sheet.Cells["A3"].Formula = "=AND(A1,A2)";
Assert.Equal(false, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateAndFunctionWithNumericValues()
{
sheet.Cells["A1"].Value = 5;
sheet.Cells["A2"].Value = 10;
sheet.Cells["A3"].Formula = "=AND(A1>1,A2<100)";
Assert.Equal(true, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateAndFunctionWithZeroAsFalse()
{
sheet.Cells["A1"].Value = 0;
sheet.Cells["A2"].Value = 1;
sheet.Cells["A3"].Formula = "=AND(A1,A2)";
Assert.Equal(false, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateAndFunctionWithNonZeroAsTrue()
{
sheet.Cells["A1"].Value = 5;
sheet.Cells["A2"].Value = 10;
sheet.Cells["A3"].Formula = "=AND(A1,A2)";
Assert.Equal(true, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateAndFunctionWithStringValues()
{
sheet.Cells["A1"].Value = "test";
sheet.Cells["A2"].Value = "hello";
sheet.Cells["A3"].Formula = "=AND(A1,A2)";
Assert.Equal(CellError.Value, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateAndFunctionWithEmptyStringAsFalse()
{
sheet.Cells["A2"].Value = "hello";
sheet.Cells["A3"].Formula = "=AND(A1,A2)";
Assert.Equal(CellError.Value, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateAndFunctionWithMultipleArguments()
{
sheet.Cells["A1"].Value = true;
sheet.Cells["A2"].Value = true;
sheet.Cells["A3"].Value = true;
sheet.Cells["A4"].Formula = "=AND(A1,A2,A3)";
Assert.Equal(true, sheet.Cells["A4"].Value);
}
[Fact]
public void ShouldEvaluateAndFunctionWithOneFalseInMultipleArguments()
{
sheet.Cells["A1"].Value = true;
sheet.Cells["A2"].Value = false;
sheet.Cells["A3"].Value = true;
sheet.Cells["A4"].Formula = "=AND(A1,A2,A3)";
Assert.Equal(false, sheet.Cells["A4"].Value);
}
[Fact]
public void ShouldReturnValueErrorForEmptyAndFunction()
{
sheet.Cells["A1"].Formula = "=AND()";
Assert.Equal(CellError.Value, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldEvaluateAndFunctionWithRangeExpression()
{
sheet.Cells["A1"].Value = true;
sheet.Cells["A2"].Value = true;
sheet.Cells["A3"].Formula = "=AND(A1:A2)";
Assert.Equal(true, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateAndFunctionWithMixedTypes()
{
sheet.Cells["A1"].Value = 5;
sheet.Cells["A2"].Value = "3";
sheet.Cells["A3"].Value = true;
sheet.Cells["A4"].Formula = "=AND(A1,A2,A3)";
Assert.Equal(true, sheet.Cells["A4"].Value);
}
[Fact]
public void ShouldEvaluateAndFunctionInIfStatement()
{
sheet.Cells["A1"].Value = 5;
sheet.Cells["A2"].Value = 10;
sheet.Cells["A3"].Formula = "=IF(AND(A1>1,A2<100),A1,\"Out of range\")";
Assert.Equal(5d, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateAndFunctionInIfStatementWithFalseCondition()
{
sheet.Cells["A1"].Value = 5;
sheet.Cells["A2"].Value = 150;
sheet.Cells["A3"].Formula = "=IF(AND(A1>1,A2<100),A1,\"Out of range\")";
Assert.Equal("Out of range", sheet.Cells["A3"].Value);
}
}

View File

@@ -0,0 +1,105 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class AutoFilterTests
{
private readonly Sheet sheet = new(10, 10);
[Fact]
public void Should_ToggleSheetAutoFilter()
{
// Initially no auto filter
Assert.Null(sheet.AutoFilter);
// Apply auto filter to range A1:C5
var range = RangeRef.Parse("A1:C5");
var command = new SheetAutoFilterCommand(sheet, range);
command.Execute();
// Auto filter should be applied
Assert.NotNull(sheet.AutoFilter);
Assert.Equal(range, sheet.AutoFilter.Range);
// Undo the command
command.Unexecute();
// Auto filter should be removed
Assert.Null(sheet.AutoFilter);
}
[Fact]
public void Should_ToggleDataTableFilterButton()
{
// Add a data table
var range = RangeRef.Parse("A1:C5");
sheet.AddTable(range);
var table = sheet.Tables[0];
// Initially ShowFilterButton should be true
Assert.True(table.ShowFilterButton);
// Toggle filter button off
var command = new TableFilterCommand(sheet, 0);
command.Execute();
// ShowFilterButton should be false
Assert.False(table.ShowFilterButton);
// Undo the command
command.Unexecute();
// ShowFilterButton should be true again
Assert.True(table.ShowFilterButton);
}
[Fact]
public void Should_HandleMultipleDataTables()
{
// Add two data tables
sheet.AddTable(RangeRef.Parse("A1:C5"));
sheet.AddTable(RangeRef.Parse("E1:G5"));
var table1 = sheet.Tables[0];
var table2 = sheet.Tables[1];
// Initially both should have ShowFilterButton = true
Assert.True(table1.ShowFilterButton);
Assert.True(table2.ShowFilterButton);
// Toggle filter button for first data table
var command1 = new TableFilterCommand(sheet, 0);
command1.Execute();
// Only first data table should be affected
Assert.False(table1.ShowFilterButton);
Assert.True(table2.ShowFilterButton);
// Toggle filter button for second data table
var command2 = new TableFilterCommand(sheet, 1);
command2.Execute();
// Both should be affected
Assert.False(table1.ShowFilterButton);
Assert.False(table2.ShowFilterButton);
// Undo second command
command2.Unexecute();
// Only second data table should be restored
Assert.False(table1.ShowFilterButton);
Assert.True(table2.ShowFilterButton);
}
[Fact]
public void Should_HandleInvalidDataTableIndex()
{
// Try to toggle filter button for non-existent data table
var command = new TableFilterCommand(sheet, 0);
// Should not throw exception
var result = command.Execute();
Assert.True(result);
}
}

View File

@@ -0,0 +1,114 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class AverageFunctionTests
{
readonly Sheet sheet = new(5, 5);
[Fact]
public void ShouldEvaluateAverageFunctionWithTwoArguments()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 15;
sheet.Cells["A3"].Formula = "=AVERAGE(A1,A2)";
Assert.Equal(12.5, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateAverageFunctionWithEmptyCells()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A3"].Formula = "=AVERAGE(A1,A2)";
Assert.Equal(10.0, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateAverageFunctionWithMultipleArguments()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 15;
sheet.Cells["A3"].Value = 20;
sheet.Cells["A4"].Formula = "=AVERAGE(A1,A2,A3)";
Assert.Equal(15.0, sheet.Cells["A4"].Value);
}
[Fact]
public void ShouldReturnDiv0ErrorForEmptyAverageFunction()
{
sheet.Cells["A1"].Formula = "=AVERAGE()";
Assert.Equal(CellError.Div0, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldReturnDiv0ErrorForAverageFunctionWithNoNumericValues()
{
sheet.Cells["A1"].Value = "text";
sheet.Cells["A2"].Value = "";
sheet.Cells["A3"].Formula = "=AVERAGE(A1,A2)";
Assert.Equal(CellError.Div0, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateAverageFunctionWithRange()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 15;
sheet.Cells["A3"].Formula = "=AVERAGE(A1:A2)";
Assert.Equal(12.5, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateAverageFunctionWithMixedTypes()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 15.5;
sheet.Cells["A3"].Formula = "=AVERAGE(A1,A2)";
Assert.Equal(12.75, sheet.Cells["A3"].Value);
sheet.Cells["A4"].Value = 2.5;
sheet.Cells["A5"].Formula = "=AVERAGE(A4,A1)";
Assert.Equal(6.25, sheet.Cells["A5"].Value);
}
[Fact]
public void ShouldEvaluateAverageFunctionIgnoringTextAndLogicalValues()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = "text";
sheet.Cells["A3"].Value = true;
sheet.Cells["A4"].Value = 20;
sheet.Cells["A5"].Formula = "=AVERAGE(A1,A2,A3,A4)";
Assert.Equal(15.0, sheet.Cells["A5"].Value);
}
[Fact]
public void ShouldEvaluateAverageFunctionIncludingZeroValues()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 0;
sheet.Cells["A3"].Value = 20;
sheet.Cells["A4"].Formula = "=AVERAGE(A1,A2,A3)";
Assert.Equal(10.0, sheet.Cells["A4"].Value);
}
[Fact]
public void ShouldCreateRefErrorWhenAverageRangeOutOfBounds()
{
sheet.Cells["A1"].Formula = "=AVERAGE(A2:A6)";
Assert.Equal(CellError.Ref, sheet.Cells["A1"].Value);
}
}

View File

@@ -0,0 +1,261 @@
using Bunit;
using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class CellSelectionTests : TestContext
{
private readonly Sheet sheet = new (4,4);
[Fact]
public void CellSelection_RendersWithCorrectClasses()
{
// Arrange
var cell = new CellRef(0, 0);
sheet.Selection.Select(new RangeRef(cell, cell));
var context = new MockVirtualGridContext();
// Act
var cut = RenderComponent<CellSelection>(parameters => parameters
.Add(p => p.Cell, cell)
.Add(p => p.Sheet, sheet)
.Add(p => p.Context, context));
// Assert
var element = cut.Find(".rz-spreadsheet-selection-cell");
Assert.NotNull(element);
Assert.Contains("rz-spreadsheet-selection-cell", element.ClassName);
Assert.Contains("rz-spreadsheet-selection-cell-top", element.ClassName);
Assert.Contains("rz-spreadsheet-selection-cell-left", element.ClassName);
Assert.Contains("rz-spreadsheet-selection-cell-bottom", element.ClassName);
Assert.Contains("rz-spreadsheet-selection-cell-right", element.ClassName);
}
[Fact]
public void CellSelection_AppliesFrozenColumnClass()
{
// Arrange
var cell = new CellRef(0, 0);
sheet.Columns.Frozen = 1;
sheet.Selection.Select(new RangeRef(cell, cell));
var context = new MockVirtualGridContext();
// Act
var cut = RenderComponent<CellSelection>(parameters => parameters
.Add(p => p.Cell, cell)
.Add(p => p.Sheet, sheet)
.Add(p => p.Context, context));
// Assert
var element = cut.Find(".rz-spreadsheet-selection-cell");
Assert.Contains("rz-spreadsheet-frozen-column", element.ClassName);
}
[Fact]
public void CellSelection_AppliesFrozenRowClass()
{
// Arrange
var cell = new CellRef(0, 0);
var context = new MockVirtualGridContext();
sheet.Rows.Frozen = 1;
sheet.Selection.Select(new RangeRef(cell, cell));
// Act
var cut = RenderComponent<CellSelection>(parameters => parameters
.Add(p => p.Cell, cell)
.Add(p => p.Sheet, sheet)
.Add(p => p.Context, context));
// Assert
var element = cut.Find(".rz-spreadsheet-selection-cell");
Assert.Contains("rz-spreadsheet-frozen-row", element.ClassName);
}
[Fact]
public void CellSelection_CalculatesStyle()
{
// Arrange
var cell = new CellRef(0, 0);
sheet.Selection.Select(new RangeRef(cell, cell));
var context = new MockVirtualGridContext();
// Act
var cut = RenderComponent<CellSelection>(parameters => parameters
.Add(p => p.Cell, cell)
.Add(p => p.Sheet, sheet)
.Add(p => p.Context, context));
// Assert
var element = cut.Find(".rz-spreadsheet-selection-cell");
Assert.Equal("transform: translate(0px, 0px); width: 100px; height: 24px", element.GetAttribute("style"));
}
[Fact]
public void CellSelection_SplitsMergedCell_WhenIntersectingFrozenRow()
{
// Arrange
sheet.Rows.Frozen = 1;
var range = new RangeRef(new CellRef(0, 0), new CellRef(2, 0));
sheet.MergedCells.Add(range);
sheet.Selection.Select(range);
var context = new MockVirtualGridContext();
// Act
var cut = RenderComponent<CellSelection>(parameters => parameters
.Add(p => p.Cell, new CellRef(0, 0))
.Add(p => p.Sheet, sheet)
.Add(p => p.Context, context));
// Assert
var elements = cut.FindAll(".rz-spreadsheet-selection-cell");
Assert.Equal(2, elements.Count);
var frozen = cut.Find(".rz-spreadsheet-frozen-row");
Assert.NotNull(frozen);
// First element (frozen)
Assert.Equal("transform: translate(0px, 0px); width: 100px; height: 24px", frozen.GetAttribute("style"));
Assert.Contains("rz-spreadsheet-selection-cell-top", frozen.ClassName);
Assert.Contains("rz-spreadsheet-selection-cell-left", frozen.ClassName);
Assert.Contains("rz-spreadsheet-selection-cell-right", frozen.ClassName);
Assert.DoesNotContain("rz-spreadsheet-selection-cell-bottom", frozen.ClassName);
var unfrozen = elements.Where(e => e != frozen).FirstOrDefault();
Assert.NotNull(unfrozen);
// Second element (non-frozen)
Assert.Equal("transform: translate(0px, 24px); width: 100px; height: 48px", unfrozen.GetAttribute("style"));
Assert.DoesNotContain("rz-spreadsheet-selection-cell-top", unfrozen.ClassName);
Assert.Contains("rz-spreadsheet-selection-cell-left", unfrozen.ClassName);
Assert.Contains("rz-spreadsheet-selection-cell-right", unfrozen.ClassName);
Assert.Contains("rz-spreadsheet-selection-cell-bottom", unfrozen.ClassName);
}
[Fact]
public void CellSelection_SplitsMergedCell_WhenIntersectingFrozenColumn()
{
// Arrange
sheet.Columns.Frozen = 1;
var range = new RangeRef(new CellRef(0, 0), new CellRef(0, 2));
sheet.MergedCells.Add(range);
sheet.Selection.Select(range);
var context = new MockVirtualGridContext();
// Act
var cut = RenderComponent<CellSelection>(parameters => parameters
.Add(p => p.Cell, new CellRef(0, 0))
.Add(p => p.Sheet, sheet)
.Add(p => p.Context, context));
// Assert
var elements = cut.FindAll(".rz-spreadsheet-selection-cell");
Assert.Equal(2, elements.Count);
var frozen = cut.Find(".rz-spreadsheet-frozen-column");
Assert.NotNull(frozen);
// First element (frozen)
Assert.Contains("rz-spreadsheet-frozen-column", frozen.ClassName);
Assert.Equal("transform: translate(0px, 0px); width: 100px; height: 24px", frozen.GetAttribute("style"));
Assert.Contains("rz-spreadsheet-selection-cell-top", frozen.ClassName);
Assert.Contains("rz-spreadsheet-selection-cell-left", frozen.ClassName);
Assert.Contains("rz-spreadsheet-selection-cell-bottom", frozen.ClassName);
Assert.DoesNotContain("rz-spreadsheet-selection-cell-right", frozen.ClassName);
var unfrozen = elements.Where(e => e != frozen).FirstOrDefault();
Assert.NotNull(unfrozen);
// Second element (non-frozen)
Assert.Equal("transform: translate(100px, 0px); width: 200px; height: 24px", unfrozen.GetAttribute("style"));
Assert.Contains("rz-spreadsheet-selection-cell-top", unfrozen.ClassName);
Assert.DoesNotContain("rz-spreadsheet-selection-cell-left", unfrozen.ClassName);
Assert.Contains("rz-spreadsheet-selection-cell-bottom", unfrozen.ClassName);
Assert.Contains("rz-spreadsheet-selection-cell-right", unfrozen.ClassName);
}
[Fact]
public void CellSelection_SplitsMergedCell_WhenIntersectingBothFrozen()
{
// Arrange
sheet.Rows.Frozen = 1;
sheet.Columns.Frozen = 1;
var range = new RangeRef(new CellRef(0, 0), new CellRef(2, 2));
sheet.MergedCells.Add(range);
sheet.Selection.Select(range);
var context = new MockVirtualGridContext();
// Act
var cut = RenderComponent<CellSelection>(parameters => parameters
.Add(p => p.Cell, new CellRef(0, 0))
.Add(p => p.Sheet, sheet)
.Add(p => p.Context, context));
// Assert
var elements = cut.FindAll(".rz-spreadsheet-selection-cell");
Assert.Equal(4, elements.Count);
// Top-left element (both frozen)
var both = cut.Find(".rz-spreadsheet-frozen-row.rz-spreadsheet-frozen-column");
Assert.NotNull(both);
Assert.Contains("rz-spreadsheet-frozen-row", both.ClassName);
Assert.Contains("rz-spreadsheet-frozen-column", both.ClassName);
Assert.Equal("transform: translate(0px, 0px); width: 100px; height: 24px", both.GetAttribute("style"));
Assert.Contains("rz-spreadsheet-selection-cell-top", both.ClassName);
Assert.Contains("rz-spreadsheet-selection-cell-left", both.ClassName);
Assert.DoesNotContain("rz-spreadsheet-selection-cell-bottom", both.ClassName);
Assert.DoesNotContain("rz-spreadsheet-selection-cell-right", both.ClassName);
// Bottom-left element (column frozen)
var frozenColumn = cut.Find(".rz-spreadsheet-frozen-column:not(.rz-spreadsheet-frozen-row)");
Assert.NotNull(frozenColumn);
Assert.DoesNotContain("rz-spreadsheet-frozen-row", frozenColumn.ClassName);
Assert.Contains("rz-spreadsheet-frozen-column", frozenColumn.ClassName);
Assert.Equal("transform: translate(0px, 24px); width: 100px; height: 48px", frozenColumn.GetAttribute("style"));
Assert.DoesNotContain("rz-spreadsheet-selection-cell-top", frozenColumn.ClassName);
Assert.Contains("rz-spreadsheet-selection-cell-left", frozenColumn.ClassName);
Assert.Contains("rz-spreadsheet-selection-cell-bottom", frozenColumn.ClassName);
Assert.DoesNotContain("rz-spreadsheet-selection-cell-right", frozenColumn.ClassName);
// Top-right element (row frozen)
var frozenRow = cut.Find(".rz-spreadsheet-frozen-row:not(.rz-spreadsheet-frozen-column)");
Assert.NotNull(frozenRow);
Assert.Contains("rz-spreadsheet-frozen-row", frozenRow.ClassName);
Assert.DoesNotContain("rz-spreadsheet-frozen-column", frozenRow.ClassName);
Assert.Equal("transform: translate(100px, 0px); width: 200px; height: 24px", frozenRow.GetAttribute("style"));
Assert.Contains("rz-spreadsheet-selection-cell-top", frozenRow.ClassName);
Assert.DoesNotContain("rz-spreadsheet-selection-cell-left", frozenRow.ClassName);
Assert.DoesNotContain("rz-spreadsheet-selection-cell-bottom", frozenRow.ClassName);
Assert.Contains("rz-spreadsheet-selection-cell-right", frozenRow.ClassName);
// Bottom-right element (neither frozen)
var neither = elements.FirstOrDefault(e => e != both && e != frozenColumn && e != frozenRow);
Assert.NotNull(neither);
Assert.DoesNotContain("rz-spreadsheet-frozen-row", neither.ClassName);
Assert.DoesNotContain("rz-spreadsheet-frozen-column", neither.ClassName);
Assert.Equal("transform: translate(100px, 24px); width: 200px; height: 48px", neither.GetAttribute("style"));
Assert.DoesNotContain("rz-spreadsheet-selection-cell-top", neither.ClassName);
Assert.DoesNotContain("rz-spreadsheet-selection-cell-left", neither.ClassName);
Assert.Contains("rz-spreadsheet-selection-cell-bottom", neither.ClassName);
Assert.Contains("rz-spreadsheet-selection-cell-right", neither.ClassName);
}
}
public class MockVirtualGridContext : IVirtualGridContext
{
private readonly Dictionary<(int Row, int Column), PixelRectangle> rectangle = [];
public void SetupRectangle(int row, int column, PixelRectangle rectangle)
{
this.rectangle[(row, column)] = rectangle;
}
public PixelRectangle GetRectangle(int row, int column) => throw new NotImplementedException();
public PixelRectangle GetRectangle(int top, int left, int bottom, int right) => new(new (left * 100, (right + 1) * 100), new (top*24, (bottom + 1)*24));
}

View File

@@ -0,0 +1,69 @@
using System;
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class CellStoreTests
{
readonly CellStore cellStore = new(new Sheet(5, 5));
[Fact]
public void CellStore_ShouldReturnNewCell_WhenCellDoesNotExist()
{
var cell = cellStore[0, 0];
Assert.NotNull(cell);
}
[Fact]
public void CellStore_ShouldThrowArgumentOutOfRangeException_WhenRowExceedsMax()
{
Assert.Throws<ArgumentOutOfRangeException>(() => cellStore[5, 0]);
}
[Fact]
public void CellStore_ShouldThrowArgumentOutOfRangeException_WhenColumnExceedsMax()
{
Assert.Throws<ArgumentOutOfRangeException>(() => cellStore[0, 5]);
}
[Fact]
public void CellStore_ShouldReturnExistingCell_WhenCellExists()
{
var expectedCell = new Cell(cellStore.Sheet, new CellRef(0, 0));
cellStore[0, 0] = expectedCell;
var cell = cellStore[0, 0];
Assert.Same(expectedCell, cell);
}
[Fact]
public void CellStore_ShouldReturnExistingCell_ViaA1Notation()
{
var expectedCell = new Cell(cellStore.Sheet, new CellRef(0, 0));
cellStore[0, 0] = expectedCell;
var cell = cellStore["A1"];
Assert.Same(expectedCell, cell);
}
[Fact]
public void CellStore_ShouldThrowException_WhenInvalidA1Notation()
{
Assert.Throws<ArgumentException>(() => cellStore["Invalid"]);
}
[Fact]
public void CellStore_ShouldSupport_MultipleLettersInA1Notation()
{
var cellStore = new CellStore(new Sheet(5, 30));
var expectedCell = new Cell(cellStore.Sheet, new CellRef(0, 26));
cellStore[0, 26] = expectedCell;
var cell = cellStore["AA1"];
Assert.Same(expectedCell, cell);
}
}

View File

@@ -0,0 +1,34 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class ChooseFunctionTests
{
readonly Sheet sheet = new(10, 10);
[Fact]
public void ShouldPickScalarByIndex()
{
sheet.Cells["A1"].Formula = "=CHOOSE(3,\"Wide\",115,\"world\",8)";
Assert.Equal("world", sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldPickCellReferenceByIndex()
{
sheet.Cells["A2"].Value = "1st";
sheet.Cells["A3"].Value = "2nd";
sheet.Cells["A4"].Value = "3rd";
sheet.Cells["A5"].Value = "Finished";
sheet.Cells["B1"].Formula = "=CHOOSE(2,A2,A3,A4,A5)";
Assert.Equal("2nd", sheet.Cells["B1"].Value);
}
[Fact]
public void ShouldReturnValueErrorWhenIndexOutOfRange()
{
sheet.Cells["A1"].Formula = "=CHOOSE(5,1,2,3)";
Assert.Equal(CellError.Value, sheet.Cells["A1"].Value);
}
}

View File

@@ -0,0 +1,40 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class ColumnFunctionTests
{
[Fact]
public void Column_OmittedReference_ReturnsCurrentColumn()
{
var sheet = new Sheet(20, 10);
sheet.Cells["C10"].Formula = "=COLUMN()";
Assert.Equal(3d, sheet.Cells["C10"].Data.Value);
}
[Fact]
public void Column_SingleCellReference_ReturnsThatColumn()
{
var sheet = new Sheet(20, 10);
sheet.Cells["A1"].Formula = "=COLUMN(C10)";
Assert.Equal(3d, sheet.Cells["A1"].Data.Value);
}
[Fact]
public void Column_RangeReference_SingleRow_ReturnsLeftmostColumn()
{
var sheet = new Sheet(20, 10);
sheet.Cells["B2"].Formula = "=COLUMN(C10:E10)";
Assert.Equal(3d, sheet.Cells["B2"].Data.Value);
}
[Fact]
public void Column_RangeReference_MultiRowAndColumn_IsError()
{
var sheet = new Sheet(20, 10);
sheet.Cells["B2"].Formula = "=COLUMN(C10:D20)";
Assert.Equal(CellError.Value, sheet.Cells["B2"].Data.Value);
}
}

View File

@@ -0,0 +1,30 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class ColumnsFunctionTests
{
[Fact]
public void Columns_Range_ReturnsColumnCount()
{
var sheet = new Sheet(50, 20);
sheet.Cells["A1"].Formula = "=COLUMNS(C1:E4)";
Assert.Equal(3d, sheet.Cells["A1"].Data.Value);
}
[Fact]
public void Columns_SingleCell_ReturnsOne()
{
var sheet = new Sheet(50, 20);
sheet.Cells["A1"].Formula = "=COLUMNS(C10)";
Assert.Equal(1d, sheet.Cells["A1"].Data.Value);
}
[Fact]
public void Columns_SingleColumnRange_ReturnsOne()
{
var sheet = new Sheet(50, 20);
sheet.Cells["A1"].Formula = "=COLUMNS(C10:C20)";
Assert.Equal(1d, sheet.Cells["A1"].Data.Value);
}
}

View File

@@ -0,0 +1,44 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class ConcatFunctionTests
{
[Fact]
public void Concat_Literals_Works()
{
var sheet = new Sheet(20, 10);
sheet.Cells["A1"].Formula = "=CONCAT(\"The\",\" \",\"sun\",\" \",\"will\",\" \",\"come\",\" \",\"up\",\" \",\"tomorrow.\")";
Assert.Equal("The sun will come up tomorrow.", sheet.Cells["A1"].Data.Value);
}
[Fact]
public void Concat_SingleRange_LinearizesRowMajor()
{
var sheet = new Sheet(20, 10);
sheet.Cells["B2"].Value = "a1";
sheet.Cells["C2"].Value = "b1";
sheet.Cells["B3"].Value = "a2";
sheet.Cells["C3"].Value = "b2";
sheet.Cells["B4"].Value = "a4";
sheet.Cells["C4"].Value = "b4";
sheet.Cells["B5"].Value = "a5";
sheet.Cells["C5"].Value = "b5";
sheet.Cells["B6"].Value = "a6";
sheet.Cells["C6"].Value = "b6";
sheet.Cells["B7"].Value = "a7";
sheet.Cells["C7"].Value = "b7";
sheet.Cells["A1"].Formula = "=CONCAT(B2:C7)";
Assert.Equal("a1b1a2b2a4b4a5b5a6b6a7b7", sheet.Cells["A1"].Data.Value);
}
[Fact]
public void Concat_MixedArgs_RangeAndLiterals()
{
var sheet = new Sheet(10, 10);
sheet.Cells["B2"].Value = "Andreas";
sheet.Cells["C2"].Value = "Hauser";
sheet.Cells["A1"].Formula = "=CONCAT(B2,\" \",C2)";
Assert.Equal("Andreas Hauser", sheet.Cells["A1"].Data.Value);
}
}

View File

@@ -0,0 +1,150 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class CountAllFunctionTests
{
readonly Sheet sheet = new(5, 5);
[Fact]
public void ShouldEvaluateCountaFunctionWithTwoArguments()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 15;
sheet.Cells["A3"].Formula = "=COUNTA(A1,A2)";
Assert.Equal(2.0, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateCountaFunctionWithEmptyCells()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A3"].Formula = "=COUNTA(A1,A2)";
Assert.Equal(1.0, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateCountaFunctionWithMultipleArguments()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 15;
sheet.Cells["A3"].Value = 20;
sheet.Cells["A4"].Formula = "=COUNTA(A1,A2,A3)";
Assert.Equal(3.0, sheet.Cells["A4"].Value);
}
[Fact]
public void ShouldReturnZeroForEmptyCountaFunction()
{
sheet.Cells["A1"].Formula = "=COUNTA()";
Assert.Equal(0.0, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldEvaluateCountaFunctionWithRange()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 15;
sheet.Cells["A3"].Formula = "=COUNTA(A1:A2)";
Assert.Equal(2.0, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateCountaFunctionIncludingTextValues()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = "text";
sheet.Cells["A3"].Value = 20;
sheet.Cells["A4"].Formula = "=COUNTA(A1,A2,A3)";
Assert.Equal(3.0, sheet.Cells["A4"].Value);
}
[Fact]
public void ShouldEvaluateCountaFunctionIncludingLogicalValues()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = true;
sheet.Cells["A3"].Value = false;
sheet.Cells["A4"].Value = 20;
sheet.Cells["A5"].Formula = "=COUNTA(A1,A2,A3,A4)";
Assert.Equal(4.0, sheet.Cells["A5"].Value);
}
[Fact]
public void ShouldEvaluateCountaFunctionIncludingEmptyStrings()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = "";
sheet.Cells["A3"].Value = 20;
sheet.Cells["A4"].Formula = "=COUNTA(A1,A2,A3)";
Assert.Equal(3.0, sheet.Cells["A4"].Value);
}
[Fact]
public void ShouldEvaluateCountaFunctionIgnoringTrulyEmptyCells()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = "text";
sheet.Cells["A4"].Value = 20;
sheet.Cells["A5"].Formula = "=COUNTA(A1,A2,A3,A4)";
Assert.Equal(3.0, sheet.Cells["A5"].Value);
}
[Fact]
public void ShouldEvaluateCountaFunctionWithAllNumericValues()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 20;
sheet.Cells["A3"].Value = 30;
sheet.Cells["A4"].Formula = "=COUNTA(A1,A2,A3)";
Assert.Equal(3.0, sheet.Cells["A4"].Value);
}
[Fact]
public void ShouldShowDifferenceBetweenCountAndCounta()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = "text";
sheet.Cells["A3"].Value = true;
sheet.Cells["A4"].Value = "";
sheet.Cells["A5"].Value = 20;
sheet.Cells["B1"].Formula = "=COUNT(A1,A2,A3,A4,A5)";
sheet.Cells["B2"].Formula = "=COUNTA(A1,A2,A3,A4,A5)";
Assert.Equal(3.0, sheet.Cells["B1"].Value);
Assert.Equal(5.0, sheet.Cells["B2"].Value);
}
[Fact]
public void ShouldEvaluateCountaFunctionWithMixedTypes()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = "text";
sheet.Cells["A3"].Value = true;
sheet.Cells["A4"].Value = "";
sheet.Cells["A5"].Value = 3.14;
sheet.Cells["B1"].Formula = "=COUNTA(A1,A2,A3,A4,A5)";
Assert.Equal(5.0, sheet.Cells["B1"].Value);
}
[Fact]
public void ShouldCreateRefErrorWhenCountaRangeOutOfBounds()
{
sheet.Cells["A1"].Formula = "=COUNTA(A2:A6)";
Assert.Equal(CellError.Ref, sheet.Cells["A1"].Value);
}
}

View File

@@ -0,0 +1,139 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class CountFunctionTests
{
readonly Sheet sheet = new(5, 5);
[Fact]
public void ShouldEvaluateCountFunctionWithTwoArguments()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 15;
sheet.Cells["A3"].Formula = "=COUNT(A1,A2)";
Assert.Equal(2.0, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateCountFunctionWithEmptyCells()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A3"].Formula = "=COUNT(A1,A2)";
Assert.Equal(1.0, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateCountFunctionWithMultipleArguments()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 15;
sheet.Cells["A3"].Value = 20;
sheet.Cells["A4"].Formula = "=COUNT(A1,A2,A3)";
Assert.Equal(3.0, sheet.Cells["A4"].Value);
}
[Fact]
public void ShouldReturnZeroForEmptyCountFunction()
{
sheet.Cells["A1"].Formula = "=COUNT()";
Assert.Equal(0.0, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldEvaluateCountFunctionWithRange()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 15;
sheet.Cells["A3"].Formula = "=COUNT(A1:A2)";
Assert.Equal(2.0, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateCountFunctionWithMixedTypes()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 15.5;
sheet.Cells["A3"].Formula = "=COUNT(A1,A2)";
Assert.Equal(2.0, sheet.Cells["A3"].Value);
sheet.Cells["A4"].Value = 2.5;
sheet.Cells["A5"].Formula = "=COUNT(A4,A1)";
Assert.Equal(2.0, sheet.Cells["A5"].Value);
}
[Fact]
public void ShouldEvaluateCountFunctionIncludingLogicalValues()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = true;
sheet.Cells["A3"].Value = false;
sheet.Cells["A4"].Value = 20;
sheet.Cells["A5"].Formula = "=COUNT(A1,A2,A3,A4)";
Assert.Equal(4.0, sheet.Cells["A5"].Value);
}
[Fact]
public void ShouldEvaluateCountFunctionIncludingTextRepresentationsOfNumbers()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = "15";
sheet.Cells["A3"].Value = "text";
sheet.Cells["A4"].Value = "3.14";
sheet.Cells["A5"].Formula = "=COUNT(A1,A2,A3,A4)";
Assert.Equal(3.0, sheet.Cells["A5"].Value);
}
[Fact]
public void ShouldEvaluateCountFunctionIgnoringTextAndEmptyCells()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = "text";
sheet.Cells["A3"].Value = "";
sheet.Cells["A4"].Value = 20;
sheet.Cells["A5"].Formula = "=COUNT(A1,A2,A3,A4)";
Assert.Equal(2.0, sheet.Cells["A5"].Value);
}
[Fact]
public void ShouldEvaluateCountFunctionIncludingZeroValues()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 0;
sheet.Cells["A3"].Value = 20;
sheet.Cells["A4"].Formula = "=COUNT(A1,A2,A3)";
Assert.Equal(3.0, sheet.Cells["A4"].Value);
}
[Fact]
public void ShouldEvaluateCountFunctionWithAllNumericValues()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 20;
sheet.Cells["A3"].Value = 30;
sheet.Cells["A4"].Formula = "=COUNT(A1,A2,A3)";
Assert.Equal(3.0, sheet.Cells["A4"].Value);
}
[Fact]
public void ShouldCreateRefErrorWhenCountRangeOutOfBounds()
{
sheet.Cells["A1"].Formula = "=COUNT(A2:A6)";
Assert.Equal(CellError.Ref, sheet.Cells["A1"].Value);
}
}

View File

@@ -0,0 +1,32 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class DayFunctionTests
{
[Fact]
public void Day_FromDateSerial_ReturnsDay()
{
var sheet = new Sheet(10, 10);
// Using DATEVALUE via VALUE on a date string to get a serial
sheet.Cells["A1"].Formula = "=DAY(VALUE(\"2011-04-15\"))";
Assert.Equal(15, sheet.Cells["A1"].Data.GetValueOrDefault<double>());
}
[Fact]
public void Day_FromDateValue_ReturnsDay()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A1"].Data = CellData.FromDate(new System.DateTime(2011, 4, 15));
sheet.Cells["B1"].Formula = "=DAY(A1)";
Assert.Equal(15, sheet.Cells["B1"].Data.GetValueOrDefault<double>());
}
[Fact]
public void Day_InvalidText_ReturnsValueError()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A1"].Formula = "=DAY(\"abc\")";
Assert.Equal(CellError.Value, sheet.Cells["A1"].Data.GetValueOrDefault<CellError>());
}
}

View File

@@ -0,0 +1,81 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class DeleteRowColumnTests
{
[Fact]
public void DeleteColumn_ShiftsDataAndDecreasesColumnCount()
{
var sheet = new Sheet(3, 4);
sheet.Cells[0, 0].Value = "A";
sheet.Cells[0, 1].Value = "B";
sheet.Cells[0, 2].Value = "C";
sheet.Cells[0, 3].Value = "D";
sheet.DeleteColumn(1); // delete column B
Assert.Equal(3, sheet.ColumnCount);
Assert.Equal("A", sheet.Cells[0, 0].Value);
Assert.Equal("C", sheet.Cells[0, 1].Value);
Assert.Equal("D", sheet.Cells[0, 2].Value);
}
[Fact]
public void DeleteRow_ShiftsDataAndDecreasesRowCount()
{
var sheet = new Sheet(4, 2);
sheet.Cells[0, 0].Value = "R1";
sheet.Cells[1, 0].Value = "R2";
sheet.Cells[2, 0].Value = "R3";
sheet.Cells[3, 0].Value = "R4";
sheet.DeleteRow(1); // delete row 2
Assert.Equal(3, sheet.RowCount);
Assert.Equal("R1", sheet.Cells[0, 0].Value);
Assert.Equal("R3", sheet.Cells[1, 0].Value);
Assert.Equal("R4", sheet.Cells[2, 0].Value);
}
[Fact]
public void DeleteColumn_DoesNotAdjustFormulas_RefsBecomeError()
{
var sheet = new Sheet(5, 5);
sheet.Cells[0, 0].Value = 1; // A1
sheet.Cells[0, 1].Value = 2; // B1
sheet.Cells[0, 2].Value = 3; // C1
// Formula in B2 references A1 and C1
sheet.Cells[1, 1].Formula = "=A1+C1";
Assert.Equal(4d, sheet.Cells[1, 1].Value);
// Delete referenced column A -> A1 becomes invalid => #REF!
sheet.DeleteColumn(0);
Assert.Equal(CellError.Ref, sheet.Cells[1, 0].Value);
Assert.Equal("=#REF!+C1", sheet.Cells[1, 0].Formula);
}
[Fact]
public void DeleteRow_DoesNotAdjustFormulas_RefsBecomeError()
{
var sheet = new Sheet(5, 5);
sheet.Cells[0, 0].Value = 1; // A1
sheet.Cells[1, 0].Value = 2; // A2
sheet.Cells[2, 0].Value = 3; // A3
// Formula in B2 references A1 and A3
sheet.Cells[1, 1].Formula = "=A1+A3";
Assert.Equal(4d, sheet.Cells[1, 1].Value);
// Delete referenced row 1 -> A1 becomes invalid => #REF!
sheet.DeleteRow(0);
Assert.Equal(CellError.Ref, sheet.Cells[0, 1].Value);
Assert.Equal("=#REF!+A3", sheet.Cells[0, 1].Formula);
}
}

View File

@@ -0,0 +1,146 @@
using System;
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class FilterCommandTests
{
private readonly Sheet sheet = new(10, 10);
[Fact]
public void Should_AddFilterWithCommand()
{
// Initially no filters
Assert.Empty(sheet.Filters);
// Create a filter
var filter = new SheetFilter(
new EqualToCriterion { Column = 0, Value = "Test" },
RangeRef.Parse("A1:A5")
);
// Execute the command
var command = new FilterCommand(sheet, filter);
var result = command.Execute();
// Command should succeed
Assert.True(result);
// Filter should be added
Assert.Single(sheet.Filters);
Assert.Contains(filter, sheet.Filters);
}
[Fact]
public void Should_UndoFilterCommand()
{
// Initially no filters
Assert.Empty(sheet.Filters);
// Create a filter
var filter = new SheetFilter(
new EqualToCriterion { Column = 0, Value = "Test" },
RangeRef.Parse("A1:A5")
);
// Execute the command
var command = new FilterCommand(sheet, filter);
command.Execute();
// Filter should be added
Assert.Single(sheet.Filters);
// Undo the command
command.Unexecute();
// Filter should be removed
Assert.Empty(sheet.Filters);
}
[Fact]
public void Should_WorkWithUndoRedoStack()
{
// Initially no filters
Assert.Empty(sheet.Filters);
// Create a filter
var filter = new SheetFilter(
new EqualToCriterion { Column = 0, Value = "Test" },
RangeRef.Parse("A1:A5")
);
// Execute the command through the undo/redo stack
var command = new FilterCommand(sheet, filter);
var result = sheet.Commands.Execute(command);
// Command should succeed
Assert.True(result);
// Filter should be added
Assert.Single(sheet.Filters);
// Undo should be available
Assert.True(sheet.Commands.CanUndo);
// Undo the command
sheet.Commands.Undo();
// Filter should be removed
Assert.Empty(sheet.Filters);
// Redo should be available
Assert.True(sheet.Commands.CanRedo);
// Redo the command
sheet.Commands.Redo();
// Filter should be added again
Assert.Single(sheet.Filters);
}
[Fact]
public void Should_HandleMultipleFilters()
{
// Initially no filters
Assert.Empty(sheet.Filters);
// Create multiple filters
var filter1 = new SheetFilter(
new EqualToCriterion { Column = 0, Value = "Test1" },
RangeRef.Parse("A1:A5")
);
var filter2 = new SheetFilter(
new EqualToCriterion { Column = 1, Value = "Test2" },
RangeRef.Parse("B1:B5")
);
// Execute commands through the undo/redo stack
var command1 = new FilterCommand(sheet, filter1);
var command2 = new FilterCommand(sheet, filter2);
sheet.Commands.Execute(command1);
sheet.Commands.Execute(command2);
// Both filters should be added
Assert.Equal(2, sheet.Filters.Count);
Assert.Contains(filter1, sheet.Filters);
Assert.Contains(filter2, sheet.Filters);
// Undo both commands
sheet.Commands.Undo(); // Undo filter2
sheet.Commands.Undo(); // Undo filter1
// No filters should remain
Assert.Empty(sheet.Filters);
// Redo both commands
sheet.Commands.Redo(); // Redo filter1
sheet.Commands.Redo(); // Redo filter2
// Both filters should be back
Assert.Equal(2, sheet.Filters.Count);
Assert.Contains(filter1, sheet.Filters);
Assert.Contains(filter2, sheet.Filters);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,51 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class FindFunctionTests
{
[Fact]
public void Find_CaseSensitive_MatchesUppercase()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A2"].Value = "Miriam McGovern";
sheet.Cells["B1"].Formula = "=FIND(\"M\",A2)";
Assert.Equal(1d, sheet.Cells["B1"].Data.Value);
}
[Fact]
public void Find_CaseSensitive_MatchesLowercase()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A2"].Value = "Miriam McGovern";
sheet.Cells["B1"].Formula = "=FIND(\"m\",A2)";
Assert.Equal(6d, sheet.Cells["B1"].Data.Value);
}
[Fact]
public void Find_WithStartNum()
{
var sheet = new Sheet(10, 30);
sheet.Cells["A1"].Value = "AYF0093.YoungMensApparel";
sheet.Cells["B1"].Formula = "=FIND(\"Y\",A1,8)";
Assert.Equal(9d, sheet.Cells["B1"].Data.Value);
}
[Fact]
public void Find_EmptyFindText_ReturnsStart()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A1"].Value = "abc";
sheet.Cells["B1"].Formula = "=FIND(\"\",A1,2)";
Assert.Equal(2d, sheet.Cells["B1"].Data.Value);
}
[Fact]
public void Find_NotFound_ReturnsValue()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A1"].Value = "abc";
sheet.Cells["B1"].Formula = "=FIND(\"z\",A1)";
Assert.Equal(CellError.Value, sheet.Cells["B1"].Data.GetValueOrDefault<CellError>());
}
}

View File

@@ -0,0 +1,298 @@
using System;
using System.Linq.Expressions;
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class FormulaEvaluationTests
{
readonly Sheet sheet = new(5, 5);
[Fact]
public void ShouldEvaluateFormulaAfterSettingIt()
{
sheet.Cells["A1"].Value = 1;
sheet.Cells["A2"].Formula = "=A1+1";
Assert.Equal(2d, sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateFormulaAfterSettingValue()
{
sheet.Cells["A1"].Formula = "=A2+1";
sheet.Cells["A2"].Value = 1;
Assert.Equal(2d, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldNotEvaluateFormulaIfEditing()
{
sheet.BeginUpdate();
sheet.Cells["A1"].Formula = "=A2+1";
sheet.Cells["A2"].Value = 1;
Assert.Null(sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldEvaluateFormulaAfterEndingEdit()
{
sheet.BeginUpdate();
sheet.Cells["A1"].Formula = "=A2+1";
sheet.Cells["A2"].Value = 1;
sheet.EndUpdate();
Assert.Equal(2d, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldSetCellValueToErrorValueIfStringIsUsedInBinaryOperation()
{
sheet.Cells["A1"].Formula = "=A2+1";
sheet.Cells["A2"].Value = "test";
Assert.Equal(CellError.Value, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldSetCellValueToErrorNameIfInvalidFunctionIsUsedInFormula()
{
sheet.Cells["A1"].Formula = "=INVALID_FUNCTION()";
sheet.Cells["A2"].Value = "test";
Assert.Equal(CellError.Name, sheet.Cells["A1"].Value);
}
[Theory]
[InlineData("=SUM(")]
[InlineData("=SUM(A2,")]
[InlineData("=SUM(A2:A2")]
public void ShouldSetCellValueToErrorNameIfIncompleteFunctionIsUsedInFormula(string formula)
{
sheet.Cells["A1"].Formula = formula;
sheet.Cells["A2"].Value = "test";
Assert.Equal(CellError.Name, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldSetCellValueToEqualsIfOnlyEqualsIsSetAsFormula()
{
sheet.Cells["A1"].SetValue("=");
Assert.Equal("=", sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldEvaluateFormulaWhenDependencyIsChanged()
{
sheet.Cells["A1"].Formula = "=A2+1";
sheet.Cells["A2"].Formula = "=A3+1";
sheet.Cells["A3"].Value = 1;
Assert.Equal(3d, sheet.Cells["A1"].Value);
Assert.Equal(2d, sheet.Cells["A2"].Value);
Assert.Equal(1d, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateFormulaWhenDependencyIsChangedAndEndEditIsCalled()
{
sheet.BeginUpdate();
sheet.Cells["A1"].Formula = "=A2+1";
sheet.Cells["A2"].Formula = "=A3+1";
sheet.Cells["A3"].Value = 1;
sheet.EndUpdate();
Assert.Equal(3d, sheet.Cells["A1"].Value);
Assert.Equal(2d, sheet.Cells["A2"].Value);
Assert.Equal(1d, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldTreatEmptyValueAsZeroInFormula()
{
sheet.Cells["A1"].Formula = "=A2+1";
Assert.Equal(1d, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldHandleSelfReferencingFormulas()
{
sheet.Cells["A1"].Formula = "=A1+1";
// Setting a value should not cause infinite recursion
sheet.Cells["A1"].Value = 1;
// The value should be stable and not cause infinite recursion
Assert.NotNull(sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldSetDiv0ErrorWhenDividingByZero()
{
sheet.Cells["A1"].Formula = "=A2/A3";
sheet.Cells["A2"].Value = 1;
sheet.Cells["A3"].Value = 0;
Assert.Equal(CellError.Div0, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldSetErrorToCircularWhenCellFormulasReferenceEachOther()
{
sheet.Cells["A1"].Formula = "=A2+1";
sheet.Cells["A2"].Formula = "=A1+1";
// The value should be an error
Assert.Equal(CellError.Circular, sheet.Cells["A1"].Value);
Assert.Equal(CellError.Circular, sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldReturnNameErrorForUnknownFunction()
{
sheet.Cells["A1"].Formula = "=UNKNOWN()";
Assert.Equal(CellError.Name, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldCreateRefErrorWhenOutOfBounds()
{
sheet.Cells["A1"].Formula = "=A6";
Assert.Equal(CellError.Ref, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldCreateRefErrorWhenRangeOutOfBounds()
{
sheet.Cells["A1"].Formula = "=SUM(A2:A6)";
Assert.Equal(CellError.Ref, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldCreateRefErrorWhenCountRangeOutOfBounds()
{
sheet.Cells["A1"].Formula = "=COUNT(A2:A6)";
Assert.Equal(CellError.Ref, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldCreateRefErrorWhenCountaRangeOutOfBounds()
{
sheet.Cells["A1"].Formula = "=COUNTA(A2:A6)";
Assert.Equal(CellError.Ref, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldEvaluateIfFunctionWithDecimalValues()
{
sheet.Cells["A1"].Value = 0.5m;
sheet.Cells["A2"].Formula = "=IF(A1,\"True\",\"False\")";
Assert.Equal("True", sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldReturnNameErrorForUnknownFunctionUppercase()
{
sheet.Cells["A1"].Formula = "=UNKNOWNFUNCTION(1,2,3)";
Assert.Equal(CellError.Name, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldReturnNameErrorForUnknownFunctionWithMixedCase()
{
sheet.Cells["A1"].Formula = "=UnknownFunction(1,2,3)";
Assert.Equal(CellError.Name, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldReturnNameErrorForUnknownFunctionWithLowercase()
{
sheet.Cells["A1"].Formula = "=unknownfunction(1,2,3)";
Assert.Equal(CellError.Name, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldEvaluateAndFunctionInIfStatementWithFalseCondition()
{
sheet.Cells["A1"].Value = 5;
sheet.Cells["A2"].Value = 150;
sheet.Cells["A3"].Formula = "=IF(AND(A1>1,A2<100),A1,\"Out of range\")";
Assert.Equal("Out of range", sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateOrFunctionWithProvidedExample3()
{
sheet.Cells["A2"].Value = 75;
sheet.Cells["A3"].Formula = "=IF(OR(A2<0,A2>50),A2,\"The value is out of range\")";
Assert.Equal(75d, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateNotFunctionWithOrFunction()
{
sheet.Cells["A1"].Value = false;
sheet.Cells["A2"].Value = false;
sheet.Cells["A3"].Formula = "=NOT(OR(A1,A2))";
Assert.Equal(true, sheet.Cells["A3"].Value);
}
// IFERROR function tests are in IfErrorFunctionTests.cs
[Fact]
public void ShouldEvaluateSimpleDivisionByZero()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Formula = "=A1/0";
Assert.Equal(CellError.Div0, sheet.Cells["A2"].Value);
}
[Fact]
public void Evaluator_ShouldResolveCrossSheetCellReference()
{
var wb = new Workbook();
var s1 = wb.AddSheet("Sheet1", 5, 5);
var s2 = wb.AddSheet("Sheet2", 5, 5);
s2.Cells[0, 2].Value = 42; // C1 on Sheet2
s1.Cells[0, 0].Formula = "=Sheet2!C1"; // A1 on Sheet1 refers to Sheet2!C1
Assert.Equal(42d, s1.Cells[0, 0].Data.GetValueOrDefault<double>());
}
[Fact]
public void Evaluator_ShouldResolveCrossSheetRangeInFunction()
{
var wb = new Workbook();
var s1 = wb.AddSheet("Sheet1", 5, 5);
var s2 = wb.AddSheet("Sheet2", 5, 5);
s2.Cells[0, 0].Value = 1; // A1
s2.Cells[0, 1].Value = 2; // B1
s2.Cells[1, 0].Value = 3; // A2
s2.Cells[1, 1].Value = 4; // B2
s1.Cells[0, 0].Formula = "=SUM(Sheet2!A1:Sheet2!B2)";
Assert.Equal(10d, s1.Cells[0, 0].Data.GetValueOrDefault<double>());
}
}

View File

@@ -0,0 +1,143 @@
namespace Radzen.Blazor.Spreadsheet.Tests;
using System;
using Xunit;
public class FormulaLexerTests
{
[Fact]
public void FormulaLexer_ShouldParseCellIdentifier()
{
var tokens = FormulaLexer.Scan("=A1");
Assert.Equal(FormulaTokenType.Equals, tokens[0].Type);
Assert.Equal(0, tokens[0].Start);
Assert.Equal(1, tokens[0].End);
Assert.Equal(FormulaTokenType.CellIdentifier, tokens[1].Type);
Assert.Equal("A1", tokens[1].Address.ToString());
Assert.Equal(1, tokens[1].Start);
Assert.Equal(3, tokens[1].End);
}
[Fact]
public void FormulaLexer_ShouldParseSimpleFormula()
{
var tokens = FormulaLexer.Scan("=A1+b2");
Assert.Equal(FormulaTokenType.Equals, tokens[0].Type);
Assert.Equal(0, tokens[0].Start);
Assert.Equal(1, tokens[0].End);
Assert.Equal(FormulaTokenType.CellIdentifier, tokens[1].Type);
Assert.Equal("A1", tokens[1].Value);
Assert.Equal(1, tokens[1].Start);
Assert.Equal(3, tokens[1].End);
Assert.Equal(FormulaTokenType.Plus, tokens[2].Type);
Assert.Equal(3, tokens[2].Start);
Assert.Equal(4, tokens[2].End);
Assert.Equal(FormulaTokenType.CellIdentifier, tokens[3].Type);
Assert.Equal("b2", tokens[3].Value);
Assert.Equal(4, tokens[3].Start);
Assert.Equal(6, tokens[3].End);
}
[Fact]
public void FormulaLexer_ShouldPreserveWhitespaceAsTrivia()
{
var tokens = FormulaLexer.Scan("= A1 + b2 ");
// Check that whitespace is preserved as trivia
Assert.Equal(FormulaTokenType.Equals, tokens[0].Type);
Assert.Empty(tokens[0].LeadingTrivia);
Assert.Single(tokens[0].TrailingTrivia);
Assert.Equal(FormulaTokenTriviaKind.Whitespace, tokens[0].TrailingTrivia[0].Kind);
Assert.Equal(" ", tokens[0].TrailingTrivia[0].Text);
Assert.Equal(0, tokens[0].Start);
Assert.Equal(2, tokens[0].End);
Assert.Equal(FormulaTokenType.CellIdentifier, tokens[1].Type);
Assert.Empty(tokens[1].LeadingTrivia);
Assert.Single(tokens[1].TrailingTrivia);
Assert.Equal(FormulaTokenTriviaKind.Whitespace, tokens[1].TrailingTrivia[0].Kind);
Assert.Equal(" ", tokens[1].TrailingTrivia[0].Text);
Assert.Equal(2, tokens[1].Start);
Assert.Equal(5, tokens[1].End);
Assert.Equal(FormulaTokenType.Plus, tokens[2].Type);
Assert.Empty(tokens[2].LeadingTrivia);
Assert.Single(tokens[2].TrailingTrivia);
Assert.Equal(FormulaTokenTriviaKind.Whitespace, tokens[2].TrailingTrivia[0].Kind);
Assert.Equal(" ", tokens[2].TrailingTrivia[0].Text);
Assert.Equal(5, tokens[2].Start);
Assert.Equal(7, tokens[2].End);
Assert.Equal(FormulaTokenType.CellIdentifier, tokens[3].Type);
Assert.Empty(tokens[3].LeadingTrivia);
Assert.Single(tokens[3].TrailingTrivia);
Assert.Equal(FormulaTokenTriviaKind.Whitespace, tokens[3].TrailingTrivia[0].Kind);
Assert.Equal(" ", tokens[3].TrailingTrivia[0].Text);
Assert.Equal(7, tokens[3].Start);
Assert.Equal(10, tokens[3].End);
}
[Fact]
public void FormulaLexer_ShouldPreserveMultipleWhitespaceAsTrivia()
{
var tokens = FormulaLexer.Scan("= A1 + b2 ");
// Check that multiple whitespace characters are preserved
Assert.Equal(FormulaTokenType.Equals, tokens[0].Type);
Assert.Single(tokens[0].TrailingTrivia);
Assert.Equal(" ", tokens[0].TrailingTrivia[0].Text);
Assert.Equal(0, tokens[0].Start);
Assert.Equal(3, tokens[0].End);
Assert.Equal(FormulaTokenType.CellIdentifier, tokens[1].Type);
Assert.Single(tokens[1].TrailingTrivia);
Assert.Equal(" ", tokens[1].TrailingTrivia[0].Text);
Assert.Equal(3, tokens[1].Start);
Assert.Equal(7, tokens[1].End);
Assert.Equal(FormulaTokenType.Plus, tokens[2].Type);
Assert.Single(tokens[2].TrailingTrivia);
Assert.Equal(" ", tokens[2].TrailingTrivia[0].Text);
Assert.Equal(7, tokens[2].Start);
Assert.Equal(10, tokens[2].End);
Assert.Equal(FormulaTokenType.CellIdentifier, tokens[3].Type);
Assert.Single(tokens[3].TrailingTrivia);
Assert.Equal(" ", tokens[3].TrailingTrivia[0].Text);
Assert.Equal(10, tokens[3].Start);
Assert.Equal(14, tokens[3].End);
}
[Fact]
public void FormulaLexer_ShouldPreserveLineEndingsAsTrivia()
{
var tokens = FormulaLexer.Scan("=A1\n+b2");
// Check that line endings are preserved as trivia
Assert.Equal(FormulaTokenType.Equals, tokens[0].Type);
Assert.Empty(tokens[0].LeadingTrivia);
Assert.Empty(tokens[0].TrailingTrivia);
Assert.Equal(0, tokens[0].Start);
Assert.Equal(1, tokens[0].End);
Assert.Equal(FormulaTokenType.CellIdentifier, tokens[1].Type);
Assert.Empty(tokens[1].LeadingTrivia);
Assert.Single(tokens[1].TrailingTrivia);
Assert.Equal(FormulaTokenTriviaKind.EndOfLine, tokens[1].TrailingTrivia[0].Kind);
Assert.Equal("\n", tokens[1].TrailingTrivia[0].Text);
Assert.Equal(1, tokens[1].Start);
Assert.Equal(4, tokens[1].End);
Assert.Equal(FormulaTokenType.Plus, tokens[2].Type);
Assert.Empty(tokens[2].LeadingTrivia);
Assert.Empty(tokens[2].TrailingTrivia);
Assert.Equal(4, tokens[2].Start);
Assert.Equal(5, tokens[2].End);
Assert.Equal(expected: FormulaTokenType.CellIdentifier, tokens[3].Type);
Assert.Empty(tokens[3].LeadingTrivia);
Assert.Empty(tokens[3].TrailingTrivia);
Assert.Equal(5, tokens[3].Start);
Assert.Equal(7, tokens[3].End);
}
}

View File

@@ -0,0 +1,644 @@
namespace Radzen.Blazor.Spreadsheet.Tests;
using System;
using Xunit;
public class FormulaParserTests
{
[Fact]
public void FormulaParser_ShouldRequireEqualsAtStart()
{
var formula = "A1";
var syntaxTree = FormulaParser.Parse(formula);
Assert.NotEmpty(syntaxTree.Errors);
Assert.Contains("Unexpected token", syntaxTree.Errors[0]);
}
[Fact]
public void FormulaParser_ShouldParseNumberLiteral()
{
var formula = "=123";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
Assert.IsType<NumberLiteralSyntaxNode>(syntaxTree.Root);
var numberNode = (NumberLiteralSyntaxNode)syntaxTree.Root;
Assert.Equal(123, numberNode.Token.IntValue);
}
[Fact]
public void FormulaParser_ShouldParseAdditionOfTwoNumberLiterals()
{
var formula = "=123+456";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
Assert.IsType<BinaryExpressionSyntaxNode>(syntaxTree.Root);
var binaryNode = (BinaryExpressionSyntaxNode)syntaxTree.Root;
Assert.Equal(BinaryOperator.Plus, binaryNode.Operator);
Assert.IsType<NumberLiteralSyntaxNode>(binaryNode.Left);
Assert.IsType<NumberLiteralSyntaxNode>(binaryNode.Right);
Assert.Equal(123, ((NumberLiteralSyntaxNode)binaryNode.Left).Token.IntValue);
Assert.Equal(456, ((NumberLiteralSyntaxNode)binaryNode.Right).Token.IntValue);
}
[Fact]
public void FormulaParser_ShouldParseAdditionOfMultipleNumberLiterals()
{
var formula = "=123+456+789";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<BinaryExpressionSyntaxNode>(node);
var binaryNode = (BinaryExpressionSyntaxNode)node;
Assert.Equal(BinaryOperator.Plus, binaryNode.Operator);
Assert.IsType<BinaryExpressionSyntaxNode>(binaryNode.Left);
var leftBinaryNode = (BinaryExpressionSyntaxNode)binaryNode.Left;
Assert.Equal(BinaryOperator.Plus, leftBinaryNode.Operator);
Assert.Equal(123, ((NumberLiteralSyntaxNode)leftBinaryNode.Left).Token.IntValue);
Assert.Equal(456, ((NumberLiteralSyntaxNode)leftBinaryNode.Right).Token.IntValue);
Assert.Equal(789, ((NumberLiteralSyntaxNode)binaryNode.Right).Token.IntValue);
}
[Fact]
public void FormulaParser_ShouldParseSubtractionOfTwoNumberLiterals()
{
var formula = "=123-456";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<BinaryExpressionSyntaxNode>(node);
var binaryNode = (BinaryExpressionSyntaxNode)node;
Assert.Equal(BinaryOperator.Minus, binaryNode.Operator);
Assert.IsType<NumberLiteralSyntaxNode>(binaryNode.Left);
Assert.IsType<NumberLiteralSyntaxNode>(binaryNode.Right);
Assert.Equal(123, ((NumberLiteralSyntaxNode)binaryNode.Left).Token.IntValue);
Assert.Equal(456, ((NumberLiteralSyntaxNode)binaryNode.Right).Token.IntValue);
}
[Fact]
public void FormulaParser_ShouldParseUnaryNegativeNumber()
{
var formula = "=-123";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
Assert.IsType<UnaryExpressionSyntaxNode>(syntaxTree.Root);
var unary = (UnaryExpressionSyntaxNode)syntaxTree.Root;
Assert.Equal(UnaryOperator.Negate, unary.Operator);
Assert.IsType<NumberLiteralSyntaxNode>(unary.Operand);
Assert.Equal(123, ((NumberLiteralSyntaxNode)unary.Operand).Token.IntValue);
}
[Fact]
public void FormulaParser_ShouldParseUnaryPlusNumber()
{
var formula = "=+123";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
Assert.IsType<UnaryExpressionSyntaxNode>(syntaxTree.Root);
var unary = (UnaryExpressionSyntaxNode)syntaxTree.Root;
Assert.Equal(UnaryOperator.Plus, unary.Operator);
Assert.IsType<NumberLiteralSyntaxNode>(unary.Operand);
Assert.Equal(123, ((NumberLiteralSyntaxNode)unary.Operand).Token.IntValue);
}
[Fact]
public void FormulaParser_ShouldParseUnaryPlusInFunctionArgument()
{
var formula = "=LEFT(A1,+1)";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
Assert.IsType<FunctionSyntaxNode>(syntaxTree.Root);
var fn = (FunctionSyntaxNode)syntaxTree.Root;
Assert.Equal("LEFT", fn.Name);
Assert.IsType<UnaryExpressionSyntaxNode>(fn.Arguments[1]);
}
[Fact]
public void FormulaParser_ShouldParseMultipleUnaryOperators()
{
var formula = "=-+-+3";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
// Expect nested unary nodes: - ( + ( - ( + 3 ) ) )
var node = syntaxTree.Root;
Assert.IsType<UnaryExpressionSyntaxNode>(node);
var u1 = (UnaryExpressionSyntaxNode)node; // '-'
Assert.Equal(UnaryOperator.Negate, u1.Operator);
Assert.IsType<UnaryExpressionSyntaxNode>(u1.Operand);
var u2 = (UnaryExpressionSyntaxNode)u1.Operand; // '+'
Assert.Equal(UnaryOperator.Plus, u2.Operator);
Assert.IsType<UnaryExpressionSyntaxNode>(u2.Operand);
var u3 = (UnaryExpressionSyntaxNode)u2.Operand; // '-'
Assert.Equal(UnaryOperator.Negate, u3.Operator);
Assert.IsType<UnaryExpressionSyntaxNode>(u3.Operand);
var u4 = (UnaryExpressionSyntaxNode)u3.Operand; // '+'
Assert.Equal(UnaryOperator.Plus, u4.Operator);
Assert.IsType<NumberLiteralSyntaxNode>(u4.Operand);
Assert.Equal(3, ((NumberLiteralSyntaxNode)u4.Operand).Token.IntValue);
}
[Fact]
public void FormulaParser_ShouldParseUnaryNegativeInFunctionArgument()
{
var formula = "=LEFT(A1,-1)";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
Assert.IsType<FunctionSyntaxNode>(syntaxTree.Root);
var fn = (FunctionSyntaxNode)syntaxTree.Root;
Assert.Equal("LEFT", fn.Name);
Assert.Equal(2, fn.Arguments.Count);
Assert.IsType<CellSyntaxNode>(fn.Arguments[0]);
Assert.IsType<UnaryExpressionSyntaxNode>(fn.Arguments[1]);
}
[Fact]
public void FormulaParser_ShouldParseSubtractionOfMultipleNumberLiterals()
{
var formula = "=123-456-789";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<BinaryExpressionSyntaxNode>(node);
var binaryNode = (BinaryExpressionSyntaxNode)node;
Assert.Equal(BinaryOperator.Minus, binaryNode.Operator);
Assert.IsType<BinaryExpressionSyntaxNode>(binaryNode.Left);
var leftBinaryNode = (BinaryExpressionSyntaxNode)binaryNode.Left;
Assert.Equal(BinaryOperator.Minus, leftBinaryNode.Operator);
Assert.Equal(123, ((NumberLiteralSyntaxNode)leftBinaryNode.Left).Token.IntValue);
Assert.Equal(456, ((NumberLiteralSyntaxNode)leftBinaryNode.Right).Token.IntValue);
Assert.Equal(789, ((NumberLiteralSyntaxNode)binaryNode.Right).Token.IntValue);
}
[Fact]
public void FormulaParser_ShouldParseMultiplicationOfTwoNumberLiterals()
{
var formula = "=123*456";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<BinaryExpressionSyntaxNode>(node);
var binaryNode = (BinaryExpressionSyntaxNode)node;
Assert.Equal(BinaryOperator.Multiply, binaryNode.Operator);
Assert.IsType<NumberLiteralSyntaxNode>(binaryNode.Left);
Assert.IsType<NumberLiteralSyntaxNode>(binaryNode.Right);
Assert.Equal(123, ((NumberLiteralSyntaxNode)binaryNode.Left).Token.IntValue);
Assert.Equal(456, ((NumberLiteralSyntaxNode)binaryNode.Right).Token.IntValue);
}
[Fact]
public void FormulaParse_MultiplicationPrecedence()
{
var formula = "=123+456*789";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<BinaryExpressionSyntaxNode>(node);
var binaryNode = (BinaryExpressionSyntaxNode)node;
Assert.Equal(BinaryOperator.Plus, binaryNode.Operator);
Assert.IsType<NumberLiteralSyntaxNode>(binaryNode.Left);
Assert.IsType<BinaryExpressionSyntaxNode>(binaryNode.Right);
var rightBinaryNode = (BinaryExpressionSyntaxNode)binaryNode.Right;
Assert.Equal(BinaryOperator.Multiply, rightBinaryNode.Operator);
Assert.Equal(456, ((NumberLiteralSyntaxNode)rightBinaryNode.Left).Token.IntValue);
Assert.Equal(789, ((NumberLiteralSyntaxNode)rightBinaryNode.Right).Token.IntValue);
}
[Fact]
public void FormulaParser_ShouldParseDivisionOfTwoNumberLiterals()
{
var formula = "=123/456";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<BinaryExpressionSyntaxNode>(node);
var binaryNode = (BinaryExpressionSyntaxNode)node;
Assert.Equal(BinaryOperator.Divide, binaryNode.Operator);
Assert.IsType<NumberLiteralSyntaxNode>(binaryNode.Left);
Assert.IsType<NumberLiteralSyntaxNode>(binaryNode.Right);
Assert.Equal(123, ((NumberLiteralSyntaxNode)binaryNode.Left).Token.IntValue);
Assert.Equal(456, ((NumberLiteralSyntaxNode)binaryNode.Right).Token.IntValue);
}
[Fact]
public void FormulaParser_ShouldParseParentheses()
{
var formula = "=(123+456)*789";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<BinaryExpressionSyntaxNode>(node);
var binaryNode = (BinaryExpressionSyntaxNode)node;
Assert.Equal(BinaryOperator.Multiply, binaryNode.Operator);
Assert.IsType<BinaryExpressionSyntaxNode>(binaryNode.Left);
Assert.IsType<NumberLiteralSyntaxNode>(binaryNode.Right);
var leftBinaryNode = (BinaryExpressionSyntaxNode)binaryNode.Left;
Assert.Equal(789, ((NumberLiteralSyntaxNode)binaryNode.Right).Token.IntValue);
Assert.Equal(BinaryOperator.Plus, leftBinaryNode.Operator);
Assert.Equal(123, ((NumberLiteralSyntaxNode)leftBinaryNode.Left).Token.IntValue);
Assert.Equal(456, ((NumberLiteralSyntaxNode)leftBinaryNode.Right).Token.IntValue);
}
[Fact]
public void FormulaParser_ShouldParseNestedParentheses()
{
var formula = "=((123+456)*789)/101112";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<BinaryExpressionSyntaxNode>(node);
var binaryNode = (BinaryExpressionSyntaxNode)node;
Assert.Equal(BinaryOperator.Divide, binaryNode.Operator);
Assert.IsType<BinaryExpressionSyntaxNode>(binaryNode.Left);
Assert.IsType<NumberLiteralSyntaxNode>(binaryNode.Right);
var leftBinaryNode = (BinaryExpressionSyntaxNode)binaryNode.Left;
Assert.Equal(101112, ((NumberLiteralSyntaxNode)binaryNode.Right).Token.IntValue);
Assert.Equal(BinaryOperator.Multiply, leftBinaryNode.Operator);
Assert.IsType<BinaryExpressionSyntaxNode>(leftBinaryNode.Left);
var leftLeftBinaryNode = (BinaryExpressionSyntaxNode)leftBinaryNode.Left;
Assert.Equal(123, ((NumberLiteralSyntaxNode)leftLeftBinaryNode.Left).Token.IntValue);
Assert.Equal(456, ((NumberLiteralSyntaxNode)leftLeftBinaryNode.Right).Token.IntValue);
Assert.Equal(789, ((NumberLiteralSyntaxNode)leftBinaryNode.Right).Token.IntValue);
}
[Fact]
public void FormulaParser_ShouldParseCellIndentifer()
{
var formula = "=A1";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<CellSyntaxNode>(node);
var cellIdentifierNode = (CellSyntaxNode)node;
Assert.Equal("A1", cellIdentifierNode.Token.Address.ToString());
}
[Fact]
public void FormulaParser_ShouldParseSheetQualifiedCellIdentifier()
{
var formula = "=Sheet2!C1";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<CellSyntaxNode>(node);
var cellIdentifierNode = (CellSyntaxNode)node;
Assert.Equal("C1", cellIdentifierNode.Token.Address.ToString());
Assert.Equal("Sheet2", cellIdentifierNode.Token.Address.Sheet);
}
[Fact]
public void FormulaParser_ShouldParseFunction()
{
var formula = "=SUM(A1,1)";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<FunctionSyntaxNode>(node);
var functionNode = (FunctionSyntaxNode)node;
Assert.Equal("SUM", functionNode.Name);
Assert.Equal(2, functionNode.Arguments.Count);
Assert.IsType<CellSyntaxNode>(functionNode.Arguments[0]);
Assert.IsType<NumberLiteralSyntaxNode>(functionNode.Arguments[1]);
var cellIdentifierNode = (CellSyntaxNode)functionNode.Arguments[0];
Assert.Equal("A1", cellIdentifierNode.Token.Address.ToString());
var numberLiteralNode = (NumberLiteralSyntaxNode)functionNode.Arguments[1];
Assert.Equal(1, numberLiteralNode.Token.IntValue);
}
[Fact]
public void FormulaParser_ShouldParseNestedFunctions()
{
var formula = "=SUM(A1,MAX(B1,C1))";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<FunctionSyntaxNode>(node);
var functionNode = (FunctionSyntaxNode)node;
Assert.Equal("SUM", functionNode.Name);
Assert.Equal(2, functionNode.Arguments.Count);
Assert.IsType<CellSyntaxNode>(functionNode.Arguments[0]);
Assert.IsType<FunctionSyntaxNode>(functionNode.Arguments[1]);
var cellIdentifierNode = (CellSyntaxNode)functionNode.Arguments[0];
Assert.Equal("A1", cellIdentifierNode.Token.Address.ToString());
var nestedFunctionNode = (FunctionSyntaxNode)functionNode.Arguments[1];
Assert.Equal("MAX", nestedFunctionNode.Name);
Assert.Equal(2, nestedFunctionNode.Arguments.Count);
Assert.IsType<CellSyntaxNode>(nestedFunctionNode.Arguments[0]);
Assert.IsType<CellSyntaxNode>(nestedFunctionNode.Arguments[1]);
var firstCellIdentifierNode = (CellSyntaxNode)nestedFunctionNode.Arguments[0];
var secondCellIdentifierNode = (CellSyntaxNode)nestedFunctionNode.Arguments[1];
Assert.Equal("B1", firstCellIdentifierNode.Token.Address.ToString());
Assert.Equal("C1", secondCellIdentifierNode.Token.Address.ToString());
}
[Fact]
public void FormulaParser_ShouldParseFunctionWithNoArguments()
{
var formula = "=SUM()";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<FunctionSyntaxNode>(node);
var functionNode = (FunctionSyntaxNode)node;
Assert.Equal("SUM", functionNode.Name);
Assert.Empty(functionNode.Arguments);
}
[Fact]
public void FormulaParser_ShouldParseCellRange()
{
var formula = "=A1:A2";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<RangeSyntaxNode>(node);
var rangeNode = (RangeSyntaxNode)node;
Assert.Equal("A1", rangeNode.Start.Token.Address.ToString());
Assert.Equal("A2", rangeNode.End.Token.Address.ToString());
}
[Fact]
public void FormulaParser_ShouldParseSheetQualifiedRange()
{
var formula = "=Sheet2!A1:Sheet2!B2";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<RangeSyntaxNode>(node);
var rangeNode = (RangeSyntaxNode)node;
Assert.Equal("A1", rangeNode.Start.Token.Address.ToString());
Assert.Equal("B2", rangeNode.End.Token.Address.ToString());
Assert.Equal("Sheet2", rangeNode.Start.Token.Address.Sheet);
Assert.Equal("Sheet2", rangeNode.End.Token.Address.Sheet);
}
[Fact]
public void FormulaParser_ShouldParseCellRangeInFunction()
{
var formula = "=SUM(A1:A2)";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<FunctionSyntaxNode>(node);
var functionNode = (FunctionSyntaxNode)node;
Assert.Equal("SUM", functionNode.Name);
Assert.Single(functionNode.Arguments);
Assert.IsType<RangeSyntaxNode>(functionNode.Arguments[0]);
var rangeNode = (RangeSyntaxNode)functionNode.Arguments[0];
Assert.Equal("A1", rangeNode.Start.Token.Address.ToString());
Assert.Equal("A2", rangeNode.End.Token.Address.ToString());
}
[Fact]
public void FormulaParser_ShouldHandleInvalidRange()
{
var formula = "=A2:A1";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<RangeSyntaxNode>(node);
var rangeNode = (RangeSyntaxNode)node;
Assert.Equal("A2", rangeNode.Start.Token.Address.ToString());
Assert.Equal("A1", rangeNode.End.Token.Address.ToString());
}
[Fact]
public void FormulaParser_ShouldHandleSingleCellRange()
{
var formula = "=A1:A1";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<RangeSyntaxNode>(node);
var rangeNode = (RangeSyntaxNode)node;
Assert.Equal("A1", rangeNode.Start.Token.Address.ToString());
Assert.Equal("A1", rangeNode.End.Token.Address.ToString());
}
[Fact]
public void FormulaParser_ShouldHandleMultiColumnRange()
{
var formula = "=A1:B1";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<RangeSyntaxNode>(node);
var rangeNode = (RangeSyntaxNode)node;
Assert.Equal("A1", rangeNode.Start.Token.Address.ToString());
Assert.Equal("B1", rangeNode.End.Token.Address.ToString());
}
[Fact]
public void FormulaParser_ShouldHandleMultiRowRange()
{
var formula = "=A1:A2";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<RangeSyntaxNode>(node);
var rangeNode = (RangeSyntaxNode)node;
Assert.Equal("A1", rangeNode.Start.Token.Address.ToString());
Assert.Equal("A2", rangeNode.End.Token.Address.ToString());
}
[Fact]
public void FormulaParser_ShouldHandleMultiCellRange()
{
var formula = "=A1:B2";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.IsType<RangeSyntaxNode>(node);
var rangeNode = (RangeSyntaxNode)node;
Assert.Equal("A1", rangeNode.Start.Token.Address.ToString());
Assert.Equal("B2", rangeNode.End.Token.Address.ToString());
}
[Fact]
public void FormulaParser_ShouldAddErrorOnInvalidFormula()
{
var formula = "A1"; // Missing equals sign
var syntaxTree = FormulaParser.Parse(formula);
Assert.NotEmpty(syntaxTree.Errors);
Assert.Contains("Unexpected token", syntaxTree.Errors[0]);
}
[Fact]
public void FormulaParser_ShouldReturnPartialExpressionOnIncompleteExpression()
{
var formula = "=123+"; // Incomplete expression
var syntaxTree = FormulaParser.Parse(formula);
Assert.NotEmpty(syntaxTree.Errors);
Assert.IsType<BinaryExpressionSyntaxNode>(syntaxTree.Root);
if (syntaxTree.Root is BinaryExpressionSyntaxNode binaryNode)
{
Assert.Equal(BinaryOperator.Plus, binaryNode.Operator);
Assert.IsType<NumberLiteralSyntaxNode>(binaryNode.Left);
Assert.Equal(123, ((NumberLiteralSyntaxNode)binaryNode.Left).Token.IntValue);
}
}
[Fact]
public void FormulaParser_ShouldAddErrorOnIncompleteExpression()
{
var formula = "=123+"; // Incomplete expression
var syntaxTree = FormulaParser.Parse(formula);
Assert.NotEmpty(syntaxTree.Errors);
}
[Fact]
public void FormulaParser_ShouldReturnPartialFunctionOnMissingCloseParen()
{
var formula = "=SUM(A1"; // Missing closing parenthesis
var syntaxTree = FormulaParser.Parse(formula);
Assert.NotEmpty(syntaxTree.Errors);
Assert.IsType<FunctionSyntaxNode>(syntaxTree.Root);
var functionNode = (FunctionSyntaxNode)syntaxTree.Root;
Assert.Equal("SUM", functionNode.Name);
Assert.Single(functionNode.Arguments);
Assert.IsType<CellSyntaxNode>(functionNode.Arguments[0]);
}
[Fact]
public void FormulaParser_ShouldAddErrorOnInvalidFunctionSyntax()
{
var formula = "=SUM(A1"; // Missing closing parenthesis
var syntaxTree = FormulaParser.Parse(formula);
Assert.NotEmpty(syntaxTree.Errors);
}
[Fact]
public void FormulaParser_ShouldParseGroupedExpression()
{
var formula = "=(A1)"; // Parentheses without function name should parse as grouped expression
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors); // This should actually succeed as it's a valid grouped expression
Assert.IsType<CellSyntaxNode>(syntaxTree.Root);
}
[Fact]
public void FormulaParser_ShouldReturnPartialRangeOnIncompleteRange()
{
var formula = "=A1:"; // Incomplete range
var syntaxTree = FormulaParser.Parse(formula);
Assert.NotEmpty(syntaxTree.Errors);
Assert.NotNull(syntaxTree.Root);
}
[Fact]
public void FormulaParser_ShouldAddErrorOnInvalidRange()
{
var formula = "=A1:"; // Incomplete range
var syntaxTree = FormulaParser.Parse(formula);
Assert.NotEmpty(syntaxTree.Errors);
}
[Fact]
public void FormulaParser_ShouldHandleUnterminatedString()
{
var formula = "=\"hello"; // Unterminated string literal
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors); // Should succeed as lexer handles unterminated strings
Assert.IsType<StringLiteralSyntaxNode>(syntaxTree.Root);
var stringNode = (StringLiteralSyntaxNode)syntaxTree.Root;
Assert.Equal("hello", stringNode.Token.Value);
}
[Fact]
public void FormulaParser_ShouldHandleMissingOperand()
{
var formula = "=*5"; // Missing left operand
var syntaxTree = FormulaParser.Parse(formula);
Assert.NotEmpty(syntaxTree.Errors); // Should have errors
Assert.NotNull(syntaxTree.Root);
}
[Fact]
public void FormulaParser_ShouldReturnPartialExpressionOnUnbalancedParentheses()
{
var formula = "=(A1+B1"; // Missing closing parenthesis
var syntaxTree = FormulaParser.Parse(formula);
Assert.NotEmpty(syntaxTree.Errors);
Assert.IsType<BinaryExpressionSyntaxNode>(syntaxTree.Root); // Should return the binary expression inside
var binaryNode = (BinaryExpressionSyntaxNode)syntaxTree.Root;
Assert.Equal(BinaryOperator.Plus, binaryNode.Operator);
Assert.IsType<CellSyntaxNode>(binaryNode.Left);
Assert.IsType<CellSyntaxNode>(binaryNode.Right);
}
[Fact]
public void FormulaParser_ShouldAddErrorOnUnbalancedParentheses()
{
var formula = "=(A1+B1"; // Missing closing parenthesis
var syntaxTree = FormulaParser.Parse(formula);
Assert.NotEmpty(syntaxTree.Errors);
}
[Fact]
public void FormulaParser_ShouldReturnPartialFunctionOnIncompleteArguments()
{
var formula = "=SUM(A1,"; // Incomplete function arguments
var syntaxTree = FormulaParser.Parse(formula);
Assert.NotEmpty(syntaxTree.Errors);
Assert.IsType<FunctionSyntaxNode>(syntaxTree.Root);
var functionNode = (FunctionSyntaxNode)syntaxTree.Root;
Assert.Equal("SUM", functionNode.Name);
Assert.True(functionNode.Arguments.Count >= 1); // Should have at least the first argument
Assert.IsType<CellSyntaxNode>(functionNode.Arguments[0]);
}
[Fact]
public void FormulaParser_DefaultBehavior_ShouldStillWork()
{
// Test that default behavior still works as before
var formula = "=123+456";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var node = syntaxTree.Root;
Assert.NotNull(node);
Assert.IsType<BinaryExpressionSyntaxNode>(node);
}
[Fact]
public void FormulaParser_ShouldParseBooleanTrue()
{
var formula = "=TRUE";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
Assert.IsType<BooleanLiteralSyntaxNode>(syntaxTree.Root);
var boolNode = (BooleanLiteralSyntaxNode)syntaxTree.Root;
Assert.Equal("TRUE", boolNode.Token.Value);
}
[Fact]
public void FormulaParser_ShouldParseBooleanFalse_Lowercase()
{
var formula = "=false";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
Assert.IsType<BooleanLiteralSyntaxNode>(syntaxTree.Root);
var boolNode = (BooleanLiteralSyntaxNode)syntaxTree.Root;
Assert.Equal("false", boolNode.Token.Value);
}
[Fact]
public void FormulaParser_ShouldParseBooleanInFunction()
{
var formula = "=TEXTJOIN(\", \", TRUE, A1:A2)";
var syntaxTree = FormulaParser.Parse(formula);
Assert.Empty(syntaxTree.Errors);
var fn = Assert.IsType<FunctionSyntaxNode>(syntaxTree.Root);
Assert.Equal("TEXTJOIN", fn.Name);
Assert.IsType<BooleanLiteralSyntaxNode>(fn.Arguments[1]);
}
[Fact]
public void FormulaParser_ShouldParse_Percent()
{
var formula = "=$%";
var syntaxTree = FormulaParser.Parse(formula);
Assert.NotEmpty(syntaxTree.Errors);
}
}

View File

@@ -0,0 +1,74 @@
using System;
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class FunctionRegistryTests
{
private readonly FunctionStore functionRegistry = new();
[Theory]
[InlineData(2, -1)]
[InlineData(4, -1)]
[InlineData(5, 0)]
[InlineData(6, 0)]
[InlineData(7, 1)]
[InlineData(8, 1)]
[InlineData(9, 2)]
[InlineData(10, 2)]
public void Basic_Function_Provides_Correct_Arg_Index(int cursorPosition, int expectedArgIndex)
{
var func = "=SUM(1,2,3)";
var result = functionRegistry.CreateFunctionHint(func, cursorPosition);
Assert.NotNull(result);
Assert.Equal(expectedArgIndex, result.ArgumentIndex);
Assert.IsType<SumFunction>(result.Function);
}
[Theory]
[InlineData(5, 0, "=SUM(")]
[InlineData(4, -1, "=SUM(")]
public void Basic_Function_Provides_Correct_Arg_Index_With_IncompleteFormula(int cursorPosition, int expectedArgIndex, string formula)
{
var result = functionRegistry.CreateFunctionHint(formula, cursorPosition);
Assert.NotNull(result);
Assert.Equal(expectedArgIndex, result.ArgumentIndex);
Assert.IsType<SumFunction>(result.Function);
}
[Fact]
public void Position_Outside_Of_Formula_Returns_null()
{
var func = "=1 + SUM(1,2, 3) + 2";
var result = functionRegistry.CreateFunctionHint(func, 0);
Assert.Null(result);
result = functionRegistry.CreateFunctionHint(func, 5);
Assert.Null(result);
result = functionRegistry.CreateFunctionHint(func, 16);
Assert.Null(result);
}
[Theory]
[InlineData(5, 0, typeof(SumFunction))]
[InlineData(7, 1, typeof(SumFunction))]
[InlineData(8, -1, typeof(CountFunction))]
[InlineData(13, 0, typeof(CountFunction))]
[InlineData(15, 1, typeof(CountFunction))]
[InlineData(17, 1, typeof(SumFunction))]
public void Nested_Function_Produces_Correct_ArgIndex(int cursorPosition, int expectedArgIndex, Type expectedFunction)
{
var func = "=SUM(1,COUNT(1,2),3)";
var result = functionRegistry.CreateFunctionHint(func, cursorPosition);
Assert.NotNull(result);
Assert.Equal(expectedArgIndex, result.ArgumentIndex);
Assert.IsType(expectedFunction, result.Function);
}
}

View File

@@ -0,0 +1,59 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class HorizontalLookupFunctionTests
{
readonly Sheet sheet = new(10, 10);
[Fact]
public void ShouldFindExactMatchInTwoRowRange()
{
sheet.Cells["A1"].Value = "Size";
sheet.Cells["B1"].Value = "Color";
sheet.Cells["A2"].Value = "M";
sheet.Cells["B2"].Value = "Blue";
sheet.Cells["C1"].Formula = "=HLOOKUP(\"Color\",A1:B2,2,0)";
Assert.Equal("Blue", sheet.Cells["C1"].Value);
}
[Fact]
public void ShouldReturnNAWhenNoExactMatch()
{
sheet.Cells["A1"].Value = "Size";
sheet.Cells["A2"].Value = "M";
sheet.Cells["B1"].Formula = "=HLOOKUP(\"Color\",A1:A2,2,0)";
Assert.Equal(CellError.NA, sheet.Cells["B1"].Value);
}
[Fact]
public void ShouldFindApproximateMatchInSortedTopRow()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["B1"].Value = 20;
sheet.Cells["C1"].Value = 30;
sheet.Cells["A2"].Value = "Low";
sheet.Cells["B2"].Value = "Medium";
sheet.Cells["C2"].Value = "High";
sheet.Cells["D1"].Formula = "=HLOOKUP(25,A1:C2,2,1)";
Assert.Equal("Medium", sheet.Cells["D1"].Value);
}
[Fact]
public void ShouldErrorWhenIndexOutOfRange()
{
sheet.Cells["A1"].Value = "X";
sheet.Cells["A2"].Value = 1;
sheet.Cells["B1"].Formula = "=HLOOKUP(\"X\",A1:A2,3,0)";
Assert.Equal(CellError.Ref, sheet.Cells["B1"].Value);
}
}

View File

@@ -0,0 +1,33 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class HourFunctionTests
{
[Fact]
public void Hour_FromFraction_Returns18()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A2"].Data = CellData.FromNumber(0.75); // 18:00
sheet.Cells["B2"].Formula = "=HOUR(A2)";
Assert.Equal(18, sheet.Cells["B2"].Data.GetValueOrDefault<double>());
}
[Fact]
public void Hour_FromDateTimeValue_ReturnsHour()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A3"].Data = CellData.FromDate(new System.DateTime(2011, 7, 18, 7, 45, 0));
sheet.Cells["B3"].Formula = "=HOUR(A3)";
Assert.Equal(7, sheet.Cells["B3"].Data.GetValueOrDefault<double>());
}
[Fact]
public void Hour_FromDateOnly_ReturnsZero()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A4"].Data = CellData.FromDate(new System.DateTime(2012, 4, 21));
sheet.Cells["B4"].Formula = "=HOUR(A4)";
Assert.Equal(0, sheet.Cells["B4"].Data.GetValueOrDefault<double>());
}
}

View File

@@ -0,0 +1,138 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class IfErrorFunctionTests
{
readonly Sheet sheet = new(5, 5);
[Fact]
public void ShouldEvaluateIfErrorFunctionWithNoError()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 2;
sheet.Cells["A3"].Formula = "=IFERROR(A1/A2, \"Error in calculation\")";
Assert.Equal(5d, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateIfErrorFunctionWithDivisionByZero()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 0;
sheet.Cells["A3"].Formula = "=IFERROR(A1/A2, \"Error in calculation\")";
Assert.Equal("Error in calculation", sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateIfErrorFunctionWithReferenceError()
{
sheet.Cells["A1"].Formula = "=IFERROR(A6, \"Error in calculation\")";
Assert.Equal("Error in calculation", sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldEvaluateIfErrorFunctionWithEmptyStringForError()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 0;
sheet.Cells["A3"].Formula = "=IFERROR(A1/A2, \"\")";
Assert.Equal("", sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateIfErrorFunctionWithNumericErrorValue()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 0;
sheet.Cells["A3"].Formula = "=IFERROR(A1/A2, 0)";
Assert.Equal(0d, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateIfErrorFunctionWithEmptyCellAsErrorValue()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 0;
sheet.Cells["A3"].Formula = "=IFERROR(A1/A2, A4)";
Assert.Equal("", sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateIfErrorFunctionWithEmptyCellAsValue()
{
sheet.Cells["A1"].Formula = "=IFERROR(A2, \"Empty cell\")";
Assert.Equal("", sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldEvaluateIfErrorFunctionWithStringValue()
{
sheet.Cells["A1"].Value = "Hello";
sheet.Cells["A2"].Formula = "=IFERROR(A1, \"Error\")";
Assert.Equal("Hello", sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateIfErrorFunctionWithBooleanValue()
{
sheet.Cells["A1"].Value = true;
sheet.Cells["A2"].Formula = "=IFERROR(A1, \"Error\")";
Assert.Equal(true, sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldReturnValueErrorForIfErrorTooFewArguments()
{
sheet.Cells["A1"].Formula = "=IFERROR(A2)";
Assert.Equal(CellError.Value, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldReturnValueErrorForIfErrorTooManyArguments()
{
sheet.Cells["A1"].Formula = "=IFERROR(A2, \"Error\", \"Extra\")";
Assert.Equal(CellError.Value, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldEvaluateIfErrorFunctionWithNestedFormula()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 0;
sheet.Cells["A3"].Formula = "=IFERROR(A1/A2, IFERROR(A1/0, \"Nested Error\"))";
Assert.Equal("Nested Error", sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateIfErrorFunctionWithSumFunction()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 20;
sheet.Cells["A3"].Formula = "=IFERROR(SUM(A1:A2), \"Error\")";
Assert.Equal(30d, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateIfErrorFunctionWithSumFunctionError()
{
sheet.Cells["A1"].Formula = "=IFERROR(SUM(A6:A8), \"Error\")";
Assert.Equal("Error", sheet.Cells["A1"].Value);
}
}

View File

@@ -0,0 +1,178 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class IfFunctionTests
{
readonly Sheet sheet = new(5, 5);
[Fact]
public void ShouldEvaluateIfFunctionWithTrueCondition()
{
sheet.Cells["A1"].Value = 1;
sheet.Cells["A2"].Formula = "=IF(A1=1,\"Yes\",\"No\")";
Assert.Equal("Yes", sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateIfFunctionWithFalseCondition()
{
sheet.Cells["A1"].Value = 2;
sheet.Cells["A2"].Formula = "=IF(A1=1,\"Yes\",\"No\")";
Assert.Equal("No", sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateIfFunctionWithNumericComparison()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 5;
sheet.Cells["A3"].Formula = "=IF(A1>A2,\"Over Budget\",\"Within Budget\")";
Assert.Equal("Over Budget", sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateIfFunctionWithNumericResult()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 5;
sheet.Cells["A3"].Formula = "=IF(A1>A2,A1-A2,0)";
Assert.Equal(5d, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateIfFunctionWithTwoArguments()
{
sheet.Cells["A1"].Value = 1;
sheet.Cells["A2"].Formula = "=IF(A1=1,\"True\")";
Assert.Equal("True", sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateIfFunctionWithTwoArgumentsFalseCondition()
{
sheet.Cells["A1"].Value = 0;
sheet.Cells["A2"].Formula = "=IF(A1=1,\"True\")";
Assert.Equal(false, sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateIfFunctionWithZeroAsFalse()
{
sheet.Cells["A1"].Value = 0;
sheet.Cells["A2"].Formula = "=IF(A1,\"True\",\"False\")";
Assert.Equal("False", sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateIfFunctionWithNonZeroAsTrue()
{
sheet.Cells["A1"].Value = 5;
sheet.Cells["A2"].Formula = "=IF(A1,\"True\",\"False\")";
Assert.Equal("True", sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateToErrorIfFunctionWithStringCondition()
{
sheet.Cells["A1"].Value = "test";
sheet.Cells["A2"].Formula = "=IF(A1,\"Not Empty\",\"Empty\")";
Assert.Equal(CellError.Value, sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateIfFunctionWithEmptyStringCondition()
{
sheet.Cells["A2"].Formula = "=IF(A1,\"Not Empty\",\"Empty\")";
Assert.Equal("Empty", sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateIfFunctionWithNullCondition()
{
sheet.Cells["A2"].Formula = "=IF(A1,\"Not Empty\",\"Empty\")";
Assert.Equal("Empty", sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldReturnValueErrorForTooFewArguments()
{
sheet.Cells["A1"].Formula = "=IF(A2)";
Assert.Equal(CellError.Value, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldReturnValueErrorForTooManyArguments()
{
sheet.Cells["A1"].Formula = "=IF(A2,\"True\",\"False\",\"Extra\")";
Assert.Equal(CellError.Value, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldPropagateErrorFromCondition()
{
sheet.Cells["A1"].Formula = "=IF(A6,\"True\",\"False\")";
Assert.Equal(CellError.Ref, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldPropagateErrorFromTrueValue()
{
sheet.Cells["A1"].Value = 1;
sheet.Cells["A2"].Formula = "=IF(A1=1,A6,\"False\")";
Assert.Equal(CellError.Ref, sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldPropagateErrorFromFalseValue()
{
sheet.Cells["A1"].Value = 0;
sheet.Cells["A2"].Formula = "=IF(A1=1,\"True\",A6)";
Assert.Equal(CellError.Ref, sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateNestedIfFunction()
{
sheet.Cells["A1"].Value = 85;
sheet.Cells["A2"].Formula = "=IF(A1>=90,\"A\",IF(A1>=80,\"B\",IF(A1>=70,\"C\",\"F\")))";
Assert.Equal("B", sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateIfFunctionWithBooleanValues()
{
sheet.Cells["A1"].Value = true;
sheet.Cells["A2"].Formula = "=IF(A1,\"True\",\"False\")";
Assert.Equal("True", sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateIfFunctionWithDecimalValues()
{
sheet.Cells["A1"].Value = 0.5m;
sheet.Cells["A2"].Formula = "=IF(A1,\"True\",\"False\")";
Assert.Equal("True", sheet.Cells["A2"].Value);
}
}

View File

@@ -0,0 +1,100 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class IndexFunctionTests
{
readonly Sheet sheet = new(10, 10);
void Seed()
{
sheet.Cells["A2"].Value = "Apples";
sheet.Cells["B2"].Value = "Lemons";
sheet.Cells["A3"].Value = "Bananas";
sheet.Cells["B3"].Value = "Pears";
}
[Fact]
public void ShouldReturnIntersectionValue()
{
Seed();
sheet.Cells["C1"].Formula = "=INDEX(A2:B3,2,2)";
Assert.Equal("Pears", sheet.Cells["C1"].Value);
sheet.Cells["C2"].Formula = "=INDEX(A2:B3,2,1)";
Assert.Equal("Bananas", sheet.Cells["C2"].Value);
}
[Fact]
public void ShouldReturnRefErrorIfOutOfRange()
{
// numeric values just to ensure range exists
sheet.Cells["A1"].Value = 1;
sheet.Cells["B1"].Value = 2;
sheet.Cells["A2"].Value = 3;
sheet.Cells["B2"].Value = 4;
sheet.Cells["C1"].Formula = "=INDEX(A1:B2,3,1)"; // row 3 out of 2 rows
Assert.Equal(CellError.Ref, sheet.Cells["C1"].Value);
}
[Fact]
public void ShouldDefaultColumnToFirstWhenOmitted()
{
Seed();
sheet.Cells["C1"].Formula = "=INDEX(A2:B3,2)"; // column omitted -> first column
Assert.Equal("Bananas", sheet.Cells["C1"].Value);
}
[Fact]
public void ShouldUseAreaOneWhenSpecified()
{
Seed();
sheet.Cells["C1"].Formula = "=INDEX(A2:B3,2,2,1)";
Assert.Equal("Pears", sheet.Cells["C1"].Value);
}
[Fact]
public void ShouldReturnValueErrorWhenAreaGreaterThanOne()
{
Seed();
sheet.Cells["C1"].Formula = "=INDEX(A2:B3,1,1,2)";
Assert.Equal(CellError.Value, sheet.Cells["C1"].Value);
}
[Fact]
public void ShouldReturnFirstOfEntireColumnWhenRowIsZero()
{
Seed();
sheet.Cells["C1"].Formula = "=INDEX(A2:B3,0,2)";
Assert.Equal("Lemons", sheet.Cells["C1"].Value);
}
[Fact]
public void ShouldReturnFirstOfEntireRowWhenColumnIsZero()
{
Seed();
sheet.Cells["C1"].Formula = "=INDEX(A2:B3,2,0)";
Assert.Equal("Bananas", sheet.Cells["C1"].Value);
}
[Fact]
public void ShouldReturnValueErrorWhenBothRowAndColumnOmitted()
{
Seed();
sheet.Cells["C1"].Formula = "=INDEX(A2:B3)";
Assert.Equal(CellError.Value, sheet.Cells["C1"].Value);
}
[Fact]
public void ShouldReturnRefErrorOnNegativeIndices()
{
Seed();
sheet.Cells["C1"].Formula = "=INDEX(A2:B3,0-1,1)"; // -1
Assert.Equal(CellError.Ref, sheet.Cells["C1"].Value);
sheet.Cells["C2"].Formula = "=INDEX(A2:B3,1,0-1)"; // -1
Assert.Equal(CellError.Ref, sheet.Cells["C2"].Value);
}
}

View File

@@ -0,0 +1,64 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class InsertRowColumnTests
{
[Fact]
public void InsertColumn_ShiftsReferencesAndValues()
{
var sheet = new Sheet(5, 5);
sheet.Cells[1, 0].Value = 1; // A2
sheet.Cells[1, 1].Formula = "=A2+10"; // B2
Assert.Equal(11d, sheet.Cells[1, 1].Value);
// Insert a column before A (index 0)
sheet.InsertColumn(0, 1);
// Values shift right
Assert.Equal(1d, sheet.Cells[1, 1].Value); // A2 moved to B2
// Formula shifts position and updates referenced address
Assert.Equal("=B2+10", sheet.Cells[1, 2].Formula); // original B2 moved to C2
Assert.Equal(11d, sheet.Cells[1, 2].Value);
}
[Fact]
public void InsertRow_ShiftsReferencesAndValues()
{
var sheet = new Sheet(5, 5);
sheet.Cells[1, 0].Value = 1; // A2
sheet.Cells[1, 1].Formula = "=A2+10"; // B2
Assert.Equal(11d, sheet.Cells[1, 1].Value);
// Insert a row before row 2 (index 1)
sheet.InsertRow(1, 1);
// Values shift down
Assert.Equal(1d, sheet.Cells[2, 0].Value); // A2 moved to A3
// Formula shifts position and updates referenced address
Assert.Equal("=A3+10", sheet.Cells[2, 1].Formula); // original B2 moved to B3
Assert.Equal(11d, sheet.Cells[2, 1].Value);
}
[Fact]
public void InsertRow_IncreasesRowCount()
{
var sheet = new Sheet(5, 5);
sheet.InsertRow(2, 2);
Assert.Equal(7, sheet.RowCount);
}
[Fact]
public void InsertColumn_IncreasesColumnCount()
{
var sheet = new Sheet(5, 5);
sheet.InsertColumn(3, 3);
Assert.Equal(8, sheet.ColumnCount);
}
}

View File

@@ -0,0 +1,30 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class IntFunctionTests
{
readonly Sheet sheet = new(10, 10);
[Fact]
public void ShouldRoundDownPositive()
{
sheet.Cells["A1"].Formula = "=INT(8.9)";
Assert.Equal(8d, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldRoundDownNegative()
{
sheet.Cells["A1"].Formula = "=INT(0-8.9)";
Assert.Equal(-9d, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldReturnDecimalPart()
{
sheet.Cells["A2"].Value = 19.5;
sheet.Cells["A1"].Formula = "=A2-INT(A2)";
Assert.Equal(0.5, sheet.Cells["A1"].Value);
}
}

View File

@@ -0,0 +1,74 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class LargeFunctionTests
{
readonly Sheet sheet = new(10, 10);
[Fact]
public void ShouldReturnKthLargestAcrossRange()
{
// Populate A2:B6 as in example
sheet.Cells["A2"].Value = 3;
sheet.Cells["A3"].Value = 4;
sheet.Cells["A4"].Value = 5;
sheet.Cells["A5"].Value = 2;
sheet.Cells["A6"].Value = 3;
sheet.Cells["B2"].Value = 4;
sheet.Cells["B3"].Value = 5;
sheet.Cells["B4"].Value = 6;
sheet.Cells["B5"].Value = 4;
sheet.Cells["B6"].Value = 7;
sheet.Cells["C1"].Formula = "=LARGE(A2:B6,3)";
Assert.Equal(5d, sheet.Cells["C1"].Value);
}
[Fact]
public void ShouldReturn7thLargestAsFour()
{
sheet.Cells["A2"].Value = 3;
sheet.Cells["A3"].Value = 4;
sheet.Cells["A4"].Value = 5;
sheet.Cells["A5"].Value = 2;
sheet.Cells["A6"].Value = 3;
sheet.Cells["B2"].Value = 4;
sheet.Cells["B3"].Value = 5;
sheet.Cells["B4"].Value = 6;
sheet.Cells["B5"].Value = 4;
sheet.Cells["B6"].Value = 7;
sheet.Cells["C1"].Formula = "=LARGE(A2:B6,7)";
Assert.Equal(4d, sheet.Cells["C1"].Value);
}
[Fact]
public void ShouldReturnNumErrorForInvalidK()
{
sheet.Cells["A1"].Value = 1;
sheet.Cells["A2"].Value = 2;
sheet.Cells["A3"].Value = 3;
sheet.Cells["B1"].Formula = "=LARGE(A1:A3,0)";
Assert.Equal(CellError.Num, sheet.Cells["B1"].Value);
sheet.Cells["B2"].Formula = "=LARGE(A1:A3,5)";
Assert.Equal(CellError.Num, sheet.Cells["B2"].Value);
}
[Fact]
public void ShouldIgnoreNonNumericCellsInArray()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = "x"; // ignored
sheet.Cells["A3"].Value = 7;
sheet.Cells["B1"].Formula = "=LARGE(A1:A3,2)";
Assert.Equal(7d, sheet.Cells["B1"].Value);
}
}

View File

@@ -0,0 +1,42 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class LeftFunctionTests
{
[Fact]
public void Left_WithCount_ReturnsPrefix()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A2"].Value = "Sale Price";
sheet.Cells["B1"].Formula = "=LEFT(A2,4)";
Assert.Equal("Sale", sheet.Cells["B1"].Data.Value);
}
[Fact]
public void Left_OmittedCount_DefaultsToOne()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A3"].Value = "Sweden";
sheet.Cells["B1"].Formula = "=LEFT(A3)";
Assert.Equal("S", sheet.Cells["B1"].Data.Value);
}
[Fact]
public void Left_CountExceedsLength_ReturnsWhole()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A1"].Value = "Hi";
sheet.Cells["B1"].Formula = "=LEFT(A1,5)";
Assert.Equal("Hi", sheet.Cells["B1"].Data.Value);
}
[Fact]
public void Left_NegativeCount_ReturnsValueError()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A1"].Value = "Test";
sheet.Cells["B1"].Formula = "=LEFT(A1,-1)";
Assert.Equal(CellError.Value, sheet.Cells["B1"].Data.GetValueOrDefault<CellError>());
}
}

View File

@@ -0,0 +1,59 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class LenFunctionTests
{
[Fact]
public void Len_String_ReturnsLength()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A1"].Value = "Phoenix, AZ"; // 11 characters
sheet.Cells["B1"].Formula = "=LEN(A1)";
Assert.Equal(11d, sheet.Cells["B1"].Data.Value);
}
[Fact]
public void Len_BooleanCellTrue_ReturnsFour()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A1"].Value = true;
sheet.Cells["B1"].Formula = "=LEN(A1)";
Assert.Equal(4d, sheet.Cells["B1"].Data.Value);
}
[Fact]
public void Len_BooleanCellFalse_ReturnsFive()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A1"].Value = false;
sheet.Cells["B1"].Formula = "=LEN(A1)";
Assert.Equal(5d, sheet.Cells["B1"].Data.Value);
}
[Fact]
public void Len_Empty_ReturnsZero()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A1"].Value = null; // empty
sheet.Cells["B1"].Formula = "=LEN(A1)";
Assert.Equal(0d, sheet.Cells["B1"].Data.Value);
}
[Fact]
public void Len_String_WithSpaces_CountsSpaces()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A1"].Value = " One "; // 11 characters including spaces
sheet.Cells["B1"].Formula = "=LEN(A1)";
Assert.Equal(11d, sheet.Cells["B1"].Data.Value);
}
[Fact]
public void Len_Number_TreatsAsTextLength()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A1"].Value = 123.45; // "123.45" length 6
sheet.Cells["B1"].Formula = "=LEN(A1)";
Assert.Equal(6d, sheet.Cells["B1"].Data.Value);
}
}

View File

@@ -0,0 +1,24 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class LowerFunctionTests
{
[Fact]
public void Lower_ConvertsToLowercase()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A2"].Value = "E. E. Cummings";
sheet.Cells["B1"].Formula = "=LOWER(A2)";
Assert.Equal("e. e. cummings", sheet.Cells["B1"].Data.Value);
}
[Fact]
public void Lower_IgnoresNonLetters()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A3"].Value = "Apt. 2B";
sheet.Cells["B1"].Formula = "=LOWER(A3)";
Assert.Equal("apt. 2b", sheet.Cells["B1"].Data.Value);
}
}

View File

@@ -0,0 +1,64 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class MaxAllFunctionTests
{
readonly Sheet sheet = new(10, 10);
[Fact]
public void ShouldEvaluateLogicalValuesInRange()
{
sheet.Cells["A1"].Value = true; // 1
sheet.Cells["A2"].Value = false; // 0
sheet.Cells["A3"].Value = 5; // 5
sheet.Cells["B1"].Formula = "=MAXA(A1:A3)";
Assert.Equal(5d, sheet.Cells["B1"].Value);
}
[Fact]
public void ShouldTreatTextInRangeAsZeroAndNumericTextAsNumber()
{
sheet.Cells["A1"].Value = "abc"; // -> 0
sheet.Cells["A2"].Value = "15"; // -> 15
sheet.Cells["A3"].Value = 10;
sheet.Cells["B1"].Formula = "=MAXA(A1:A3)";
Assert.Equal(15d, sheet.Cells["B1"].Value);
}
[Fact]
public void ShouldCountDirectLogicalAndTextArguments()
{
sheet.Cells["A1"].Formula = "=MAXA(1=1, \"7\", 1=2)"; // TRUE, "7", FALSE -> 7
Assert.Equal(7d, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldReturnZeroWhenNoValues()
{
sheet.Cells["A1"].Value = null; // empty
sheet.Cells["A2"].Value = ""; // empty string -> Empty
sheet.Cells["B1"].Formula = "=MAXA(A1:A2)";
Assert.Equal(0d, sheet.Cells["B1"].Value);
}
[Fact]
public void ShouldPropagateErrors()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 0;
sheet.Cells["A3"].Formula = "=A1/A2"; // #DIV/0!
sheet.Cells["B1"].Formula = "=MAXA(A1:A3)";
Assert.Equal(CellError.Div0, sheet.Cells["B1"].Value);
}
}

View File

@@ -0,0 +1,69 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class MaxFunctionTests
{
readonly Sheet sheet = new(10, 10);
[Fact]
public void ShouldReturnLargestValueFromNumbers()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 7;
sheet.Cells["A3"].Value = 9;
sheet.Cells["A4"].Value = 27;
sheet.Cells["A5"].Value = 2;
sheet.Cells["B1"].Formula = "=MAX(A1:A5)";
Assert.Equal(27d, sheet.Cells["B1"].Value);
}
[Fact]
public void ShouldReturnLargestValueFromRangeAndLiteral()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 7;
sheet.Cells["A3"].Value = 9;
sheet.Cells["A4"].Value = 27;
sheet.Cells["A5"].Value = 2;
sheet.Cells["B1"].Formula = "=MAX(A1:A5,30)";
Assert.Equal(30d, sheet.Cells["B1"].Value);
}
[Fact]
public void ShouldIgnoreNonNumericInRange()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = "text";
sheet.Cells["A3"].Value = true;
sheet.Cells["A4"].Value = 27;
sheet.Cells["A5"].Value = null;
sheet.Cells["B1"].Formula = "=MAX(A1:A5)";
Assert.Equal(27d, sheet.Cells["B1"].Value);
}
[Fact]
public void ShouldTreatDirectLogicalAndNumericStringsAsNumbers()
{
sheet.Cells["A1"].Formula = "=MAX(\"15\", 5, 10)";
Assert.Equal(15d, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldReturnZeroWhenNoNumbers()
{
sheet.Cells["A1"].Value = "a";
sheet.Cells["A2"].Value = false;
sheet.Cells["A3"].Formula = "=MAX(A1:A2)";
Assert.Equal(0d, sheet.Cells["A3"].Value);
}
}

View File

@@ -0,0 +1,51 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class MidFunctionTests
{
[Fact]
public void Mid_Start1_Take5()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A2"].Value = "Fluid Flow"; // length 10
sheet.Cells["B1"].Formula = "=MID(A2,1,5)";
Assert.Equal("Fluid", sheet.Cells["B1"].Data.Value);
}
[Fact]
public void Mid_Start7_Take20_Clamped()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A2"].Value = "Fluid Flow"; // length 10
sheet.Cells["B1"].Formula = "=MID(A2,7,20)";
Assert.Equal("Flow", sheet.Cells["B1"].Data.Value);
}
[Fact]
public void Mid_StartBeyondLength_ReturnsEmpty()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A2"].Value = "Fluid Flow"; // length 10
sheet.Cells["B1"].Formula = "=MID(A2,20,5)";
Assert.Equal(string.Empty, sheet.Cells["B1"].Data.Value);
}
[Fact]
public void Mid_StartLessThan1_ReturnsValueError()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A2"].Value = "Fluid Flow";
sheet.Cells["B1"].Formula = "=MID(A2,0,5)";
Assert.Equal(CellError.Value, sheet.Cells["B1"].Data.GetValueOrDefault<CellError>());
}
[Fact]
public void Mid_NegativeNumChars_ReturnsValueError()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A2"].Value = "Fluid Flow";
sheet.Cells["B1"].Formula = "=MID(A2,1,-1)";
Assert.Equal(CellError.Value, sheet.Cells["B1"].Data.GetValueOrDefault<CellError>());
}
}

View File

@@ -0,0 +1,64 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class MinAllFunctionTests
{
readonly Sheet sheet = new(10, 10);
[Fact]
public void ShouldEvaluateLogicalValuesInRange()
{
sheet.Cells["A1"].Value = true; // 1
sheet.Cells["A2"].Value = false; // 0
sheet.Cells["A3"].Value = 5; // 5
sheet.Cells["B1"].Formula = "=MINA(A1:A3)";
Assert.Equal(0d, sheet.Cells["B1"].Value);
}
[Fact]
public void ShouldTreatTextInRangeAsZeroAndNumericTextAsNumber()
{
sheet.Cells["A1"].Value = "abc"; // -> 0
sheet.Cells["A2"].Value = "15"; // -> 15
sheet.Cells["A3"].Value = 10;
sheet.Cells["B1"].Formula = "=MINA(A1:A3)";
Assert.Equal(0d, sheet.Cells["B1"].Value);
}
[Fact]
public void ShouldCountDirectLogicalAndTextArguments()
{
sheet.Cells["A1"].Formula = "=MINA(1=1, \"7\", 1=2)"; // TRUE, "7", FALSE -> min is 0
Assert.Equal(0d, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldReturnZeroWhenNoValues()
{
sheet.Cells["A1"].Value = null; // empty
sheet.Cells["A2"].Value = ""; // empty string -> Empty
sheet.Cells["B1"].Formula = "=MINA(A1:A2)";
Assert.Equal(0d, sheet.Cells["B1"].Value);
}
[Fact]
public void ShouldPropagateErrors()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 0;
sheet.Cells["A3"].Formula = "=A1/A2"; // #DIV/0!
sheet.Cells["B1"].Formula = "=MINA(A1:A3)";
Assert.Equal(CellError.Div0, sheet.Cells["B1"].Value);
}
}

View File

@@ -0,0 +1,69 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class MinFunctionTests
{
readonly Sheet sheet = new(10, 10);
[Fact]
public void ShouldReturnSmallestValueFromNumbers()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 7;
sheet.Cells["A3"].Value = 9;
sheet.Cells["A4"].Value = 27;
sheet.Cells["A5"].Value = 2;
sheet.Cells["B1"].Formula = "=MIN(A1:A5)";
Assert.Equal(2d, sheet.Cells["B1"].Value);
}
[Fact]
public void ShouldReturnSmallestValueFromRangeAndLiteral()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = 7;
sheet.Cells["A3"].Value = 9;
sheet.Cells["A4"].Value = 27;
sheet.Cells["A5"].Value = 2;
sheet.Cells["B1"].Formula = "=MIN(A1:A5,1)";
Assert.Equal(1d, sheet.Cells["B1"].Value);
}
[Fact]
public void ShouldIgnoreNonNumericInRange()
{
sheet.Cells["A1"].Value = 10;
sheet.Cells["A2"].Value = "text";
sheet.Cells["A3"].Value = true;
sheet.Cells["A4"].Value = 27;
sheet.Cells["A5"].Value = null;
sheet.Cells["B1"].Formula = "=MIN(A1:A5)";
Assert.Equal(10d, sheet.Cells["B1"].Value);
}
[Fact]
public void ShouldTreatDirectNumericStringsAsNumbers()
{
sheet.Cells["A1"].Formula = "=MIN(\"15\", 5, 10)";
Assert.Equal(5d, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldReturnZeroWhenNoNumbers()
{
sheet.Cells["A1"].Value = "a";
sheet.Cells["A2"].Value = false;
sheet.Cells["A3"].Formula = "=MIN(A1:A2)";
Assert.Equal(0d, sheet.Cells["A3"].Value);
}
}

View File

@@ -0,0 +1,34 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class MinuteFunctionTests
{
[Fact]
public void Minute_FromFraction_ReturnsMinutes()
{
var sheet = new Sheet(10, 10);
// 0.78125 = 18:45 -> minutes 45
sheet.Cells["A1"].Data = CellData.FromNumber(0.78125);
sheet.Cells["B1"].Formula = "=MINUTE(A1)";
Assert.Equal(45, sheet.Cells["B1"].Data.GetValueOrDefault<double>());
}
[Fact]
public void Minute_FromDateTimeValue_ReturnsMinute()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A2"].Data = CellData.FromDate(new System.DateTime(2011, 7, 18, 7, 45, 0));
sheet.Cells["B2"].Formula = "=MINUTE(A2)";
Assert.Equal(45, sheet.Cells["B2"].Data.GetValueOrDefault<double>());
}
[Fact]
public void Minute_FromDateOnly_ReturnsZero()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A3"].Data = CellData.FromDate(new System.DateTime(2012, 4, 21));
sheet.Cells["B3"].Formula = "=MINUTE(A3)";
Assert.Equal(0, sheet.Cells["B3"].Data.GetValueOrDefault<double>());
}
}

View File

@@ -0,0 +1,31 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class MonthFunctionTests
{
[Fact]
public void Month_FromDateSerial_ReturnsMonth()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A1"].Formula = "=MONTH(VALUE(\"2011-04-15\"))";
Assert.Equal(4, sheet.Cells["A1"].Data.GetValueOrDefault<double>());
}
[Fact]
public void Month_FromDateValue_ReturnsMonth()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A1"].Data = CellData.FromDate(new System.DateTime(2011, 4, 15));
sheet.Cells["B1"].Formula = "=MONTH(A1)";
Assert.Equal(4, sheet.Cells["B1"].Data.GetValueOrDefault<double>());
}
[Fact]
public void Month_InvalidText_ReturnsValueError()
{
var sheet = new Sheet(10, 10);
sheet.Cells["A1"].Formula = "=MONTH(\"abc\")";
Assert.Equal(CellError.Value, sheet.Cells["A1"].Data.GetValueOrDefault<CellError>());
}
}

View File

@@ -0,0 +1,200 @@
using Xunit;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class NotFunctionTests
{
readonly Sheet sheet = new(5, 5);
[Fact]
public void ShouldEvaluateNotFunctionWithTrueValue()
{
sheet.Cells["A1"].Value = true;
sheet.Cells["A2"].Formula = "=NOT(A1)";
Assert.Equal(false, sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateNotFunctionWithEmptyStringAsError()
{
sheet.Cells["A1"].Value = "";
sheet.Cells["A2"].Formula = "=NOT(A1)";
Assert.Equal(CellError.Value, sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateNotFunctionWithFalseValue()
{
sheet.Cells["A1"].Value = false;
sheet.Cells["A2"].Formula = "=NOT(A1)";
Assert.Equal(true, sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateNotFunctionWithNumericValue()
{
sheet.Cells["A1"].Value = 5;
sheet.Cells["A2"].Formula = "=NOT(A1)";
Assert.Equal(false, sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateNotFunctionWithZeroValue()
{
sheet.Cells["A1"].Value = 0;
sheet.Cells["A2"].Formula = "=NOT(A1)";
Assert.Equal(true, sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateNotFunctionWithStringValue()
{
sheet.Cells["A1"].Value = "test";
sheet.Cells["A2"].Formula = "=NOT(A1)";
Assert.Equal(CellError.Value, sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateNotFunctionWithEmptyValue()
{
sheet.Cells["A2"].Formula = "=NOT(A1)";
Assert.Equal(true, sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateNotFunctionWithComparison()
{
sheet.Cells["A1"].Value = 50;
sheet.Cells["A2"].Formula = "=NOT(A1>100)";
Assert.Equal(true, sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateNotFunctionWithTrueComparison()
{
sheet.Cells["A1"].Value = 150;
sheet.Cells["A2"].Formula = "=NOT(A1>100)";
Assert.Equal(false, sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldReturnValueErrorForNotFunctionWithNoArguments()
{
sheet.Cells["A1"].Formula = "=NOT()";
Assert.Equal(CellError.Value, sheet.Cells["A1"].Value);
}
[Fact]
public void ShouldReturnValueErrorForNotFunctionWithMultipleArguments()
{
sheet.Cells["A1"].Value = true;
sheet.Cells["A2"].Value = false;
sheet.Cells["A3"].Formula = "=NOT(A1,A2)";
Assert.Equal(CellError.Value, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateNotFunctionWithRangeExpression()
{
sheet.Cells["A1"].Value = true;
sheet.Cells["A2"].Formula = "=NOT(A1:A1)";
Assert.Equal(false, sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateNotFunctionWithDecimalValue()
{
sheet.Cells["A1"].Value = 0.5m;
sheet.Cells["A2"].Formula = "=NOT(A1)";
Assert.Equal(false, sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateNotFunctionWithNegativeValue()
{
sheet.Cells["A1"].Value = -5;
sheet.Cells["A2"].Formula = "=NOT(A1)";
Assert.Equal(false, sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateNotFunctionInIfStatement()
{
sheet.Cells["A1"].Value = 50;
sheet.Cells["A2"].Formula = "=IF(NOT(A1>100),\"Valid\",\"Invalid\")";
Assert.Equal("Valid", sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateNotFunctionInIfStatementWithFalseCondition()
{
sheet.Cells["A1"].Value = 150;
sheet.Cells["A2"].Formula = "=IF(NOT(A1>100),\"Valid\",\"Invalid\")";
Assert.Equal("Invalid", sheet.Cells["A2"].Value);
}
[Fact]
public void ShouldEvaluateNotFunctionWithProvidedExample1()
{
sheet.Cells["A2"].Value = 50;
sheet.Cells["A3"].Formula = "=NOT(A2>100)";
Assert.Equal(true, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateNotFunctionWithProvidedExample2()
{
sheet.Cells["A2"].Value = 50;
sheet.Cells["A3"].Formula = "=IF(AND(NOT(A2>1),NOT(A2<100)),A2,\"The value is out of range\")";
Assert.Equal("The value is out of range", sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateNotFunctionWithProvidedExample3()
{
sheet.Cells["A3"].Value = 100;
sheet.Cells["A4"].Formula = "=IF(OR(NOT(A3<0),NOT(A3>50)),A3,\"The value is out of range\")";
Assert.Equal(100d, sheet.Cells["A4"].Value);
}
[Fact]
public void ShouldEvaluateNotFunctionWithNestedLogicalFunctions()
{
sheet.Cells["A1"].Value = true;
sheet.Cells["A2"].Value = false;
sheet.Cells["A3"].Formula = "=NOT(AND(A1,A2))";
Assert.Equal(true, sheet.Cells["A3"].Value);
}
[Fact]
public void ShouldEvaluateNotFunctionWithOrFunction()
{
sheet.Cells["A1"].Value = false;
sheet.Cells["A2"].Value = false;
sheet.Cells["A3"].Formula = "=NOT(OR(A1,A2))";
Assert.Equal(true, sheet.Cells["A3"].Value);
}
}

Some files were not shown because too many files have changed in this diff Show More