File tree 1 file changed +36
-0
lines changed
tests/Core/Components/InputFile 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 86
86
}
87
87
}
88
88
89
+ [Fact ]
90
+ public async Task FluentInputFile_DialogService_FileError ()
91
+ {
92
+ var errorDetected = false ;
93
+ var fileToUpload = InputFileContent .CreateFromText (" Text content" , " Filename.txt" );
94
+ var filesDownloaded = new List <FluentInputFileEventArgs >();
95
+
96
+ // Arrange
97
+ await DialogService .RegisterInputFileAsync (" MyButton" , CompletedAsync , options =>
98
+ {
99
+ options .MaximumFileSize = 3 ; // Set a small size to trigger an error
100
+ options .OnFileErrorAsync = (e ) => ErrorAsync (e );
101
+ });
102
+
103
+ // Act
104
+ var inputFile = DialogProvider .FindComponent <InputFile >();
105
+ inputFile .UploadFiles (fileToUpload );
106
+
107
+ // Assert
108
+ Assert .Single (filesDownloaded );
109
+ Assert .Equal (" The maximum size allowed is reached" , filesDownloaded [0 ].ErrorMessage );
110
+ Assert .True (errorDetected );
111
+
112
+ async Task CompletedAsync (IEnumerable < FluentInputFileEventArgs > args )
113
+ {
114
+ filesDownloaded = args .ToList ();
115
+ await Task .CompletedTask ;
116
+ }
117
+
118
+ async Task ErrorAsync (FluentInputFileErrorEventArgs args )
119
+ {
120
+ errorDetected = true ;
121
+ await Task .CompletedTask ;
122
+ }
123
+ }
124
+
89
125
[Fact ]
90
126
public async Task FluentInputFile_DialogService_Unregister ()
91
127
{
You can’t perform that action at this time.
0 commit comments