Skip to content

Commit fae5ce0

Browse files
Improve code coverage
1 parent 3e4a264 commit fae5ce0

File tree

4 files changed

+88
-0
lines changed

4 files changed

+88
-0
lines changed
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
}

Testing/Acceptance/GenHTTP.Testing.Acceptance.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4848
</PackageReference>
4949

50+
<PackageReference Include="NSubstitute" Version="5.1.0" />
51+
5052
</ItemGroup>
5153

5254
<ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
}

0 commit comments

Comments
 (0)