File tree 5 files changed +93
-4
lines changed
Modules/DirectoryBrowsing/Provider
Modules/DirectoryBrowsing
5 files changed +93
-4
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Globalization ;
2
3
3
4
namespace GenHTTP . Modules . DirectoryBrowsing . Provider
4
5
{
@@ -22,19 +23,19 @@ public static string Format(ulong? bytes)
22
23
23
24
if ( bytes > TERABYTES )
24
25
{
25
- return Math . Round ( b / TERABYTES , 2 ) + " TB" ;
26
+ return Math . Round ( b / TERABYTES , 2 ) . ToString ( CultureInfo . InvariantCulture ) + " TB" ;
26
27
}
27
28
if ( bytes > GIGABYTES )
28
29
{
29
- return Math . Round ( b / GIGABYTES , 2 ) + " GB" ;
30
+ return Math . Round ( b / GIGABYTES , 2 ) . ToString ( CultureInfo . InvariantCulture ) + " GB" ;
30
31
}
31
32
else if ( bytes > MEGABYTES )
32
33
{
33
- return Math . Round ( b / MEGABYTES , 2 ) + " MB" ;
34
+ return Math . Round ( b / MEGABYTES , 2 ) . ToString ( CultureInfo . InvariantCulture ) + " MB" ;
34
35
}
35
36
else if ( bytes > KILOBYTES )
36
37
{
37
- return Math . Round ( b / KILOBYTES , 2 ) + " KB" ;
38
+ return Math . Round ( b / KILOBYTES , 2 ) . ToString ( CultureInfo . InvariantCulture ) + " KB" ;
38
39
}
39
40
40
41
return $ "{ bytes } Bytes";
Original file line number Diff line number Diff line change
1
+ using System . Net ;
2
+ using System . Net . Http ;
3
+ using System . Threading . Tasks ;
4
+
5
+ using GenHTTP . Modules . IO ;
6
+
7
+ using Microsoft . VisualStudio . TestTools . UnitTesting ;
8
+
9
+ namespace GenHTTP . Testing . Acceptance . Engine
10
+ {
11
+
12
+ [ TestClass ]
13
+ public sealed class MethodTests
14
+ {
15
+
16
+ [ TestMethod ]
17
+ public async Task TestCustomMethods ( )
18
+ {
19
+ var result = Content . From ( Resource . FromString ( "OK" ) ) ;
20
+
21
+ using var host = TestHost . Run ( result ) ;
22
+
23
+ var request = host . GetRequest ( method : new HttpMethod ( "BREW" ) ) ;
24
+
25
+ using var response = await host . GetResponseAsync ( request ) ;
26
+
27
+ await response . AssertStatusAsync ( HttpStatusCode . OK ) ;
28
+ }
29
+
30
+ }
31
+
32
+ }
Original file line number Diff line number Diff line change
1
+ using Microsoft . VisualStudio . TestTools . UnitTesting ;
2
+ using System . Security . Cryptography . X509Certificates ;
3
+
4
+ using GenHTTP . Engine . Infrastructure . Endpoints ;
5
+
6
+ using NSubstitute ;
7
+
8
+ namespace GenHTTP . Testing . Acceptance . Engine
9
+ {
10
+
11
+ [ TestClass ]
12
+ public sealed class SimpleCertificateProviderTest
13
+ {
14
+
15
+ [ TestMethod ]
16
+ public void TestProvider ( )
17
+ {
18
+ using var cert = Substitute . For < X509Certificate2 > ( ) ;
19
+
20
+ var provider = new SimpleCertificateProvider ( cert ) ;
21
+
22
+ Assert . IsNotNull ( provider . Provide ( "google.com" ) ) ;
23
+ }
24
+
25
+ }
26
+
27
+ }
Original file line number Diff line number Diff line change 47
47
<IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
48
48
</PackageReference >
49
49
50
+ <PackageReference Include =" NSubstitute" Version =" 5.1.0" />
51
+
50
52
</ItemGroup >
51
53
52
54
<ItemGroup >
Original file line number Diff line number Diff line change
1
+ using GenHTTP . Modules . DirectoryBrowsing . Provider ;
2
+ using Microsoft . VisualStudio . TestTools . UnitTesting ;
3
+
4
+ namespace GenHTTP . Testing . Acceptance . Modules . DirectoryBrowsing
5
+ {
6
+
7
+ [ TestClass ]
8
+ public sealed class FormatterTest
9
+ {
10
+
11
+ [ TestMethod ]
12
+ public void TestFormatting ( )
13
+ {
14
+ Assert . AreEqual ( "512 Bytes" , FileSizeFormatter . Format ( 512 ) ) ;
15
+
16
+ Assert . AreEqual ( "2.78 KB" , FileSizeFormatter . Format ( 2842 ) ) ;
17
+
18
+ Assert . AreEqual ( "2.78 MB" , FileSizeFormatter . Format ( 2842 * 1024 ) ) ;
19
+
20
+ Assert . AreEqual ( "2.78 GB" , FileSizeFormatter . Format ( 2842L * 1024 * 1024 ) ) ;
21
+
22
+ Assert . AreEqual ( "2.78 TB" , FileSizeFormatter . Format ( 2842L * 1024 * 1024 * 1024 ) ) ;
23
+ }
24
+
25
+ }
26
+
27
+ }
You can’t perform that action at this time.
0 commit comments