File tree Expand file tree Collapse file tree
test/FubarDev.FtpServer.Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66using System . Threading . Tasks ;
77
88using Microsoft . Extensions . DependencyInjection ;
9+ using Microsoft . Extensions . Logging ;
910
1011using Xunit ;
1112
@@ -25,6 +26,15 @@ public class FtpServerFixture : IAsyncLifetime
2526 public FtpServerFixture ( )
2627 {
2728 var services = new ServiceCollection ( )
29+ . AddLogging (
30+ lb =>
31+ {
32+ lb . AddConsole ( ) ;
33+ lb . SetMinimumLevel ( LogLevel . Trace ) ;
34+ lb . AddFilter ( "System" , LogLevel . Warning ) ;
35+ lb . AddFilter ( "Microsoft" , LogLevel . Warning ) ;
36+ lb . AddFilter ( "FubarDev.FtpServer" , LogLevel . Trace ) ;
37+ } )
2838 . AddFtpServer (
2939 opt => opt . EnableAnonymousAuthentication ( )
3040 . UseSingleRoot ( )
Original file line number Diff line number Diff line change 77 <ItemGroup >
88 <PackageReference Include =" FluentFTP" Version =" 27.0.3" />
99 <PackageReference Include =" Microsoft.Extensions.DependencyInjection" Version =" 2.2.0" />
10+ <PackageReference Include =" Microsoft.Extensions.Logging" Version =" 2.2.0" />
11+ <PackageReference Include =" Microsoft.Extensions.Logging.Console" Version =" 2.2.0" />
1012 <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 16.2.0" />
1113 <PackageReference Include =" StyleCop.Analyzers" Version =" 1.1.118" >
1214 <PrivateAssets >all</PrivateAssets >
Original file line number Diff line number Diff line change 22// Copyright (c) Fubar Development Junker. All rights reserved.
33// </copyright>
44
5+ using System . Diagnostics ;
56using System . IO ;
67using System . Text ;
78using System . Threading . Tasks ;
@@ -35,6 +36,33 @@ public Task DisposeAsync()
3536 return _client . DisconnectAsync ( ) ;
3637 }
3738
39+ /// <summary>
40+ /// Upload a test file.
41+ /// </summary>
42+ /// <param name="fileName">The name of the file to write.</param>
43+ /// <returns>The task.</returns>
44+ [ Theory ]
45+ [ InlineData ( "设备管理-摄像机管理-w.txt" ) ]
46+ public async Task TestUtf8FileNamesForUploadAsync ( string fileName )
47+ {
48+ await _client . UploadAsync (
49+ Encoding . UTF8 . GetBytes ( "Hello, this is a test!" ) ,
50+ fileName ) ;
51+
52+ var fileNames = await _client . GetNameListingAsync ( ) ;
53+ Assert . NotNull ( fileNames ) ;
54+ Assert . Collection (
55+ fileNames ,
56+ item =>
57+ {
58+ Debug . WriteLine ( item . Length ) ;
59+ Debug . WriteLine ( item ) ;
60+ Debug . WriteLine ( char . ConvertToUtf32 ( item , 0 ) ) ;
61+ Assert . Equal ( "." , item ) ;
62+ } ,
63+ item => Assert . Equal ( fileName , item ) ) ;
64+ }
65+
3866 /// <summary>
3967 /// Upload a test file.
4068 /// </summary>
You can’t perform that action at this time.
0 commit comments