Skip to content

Commit 65d11ee

Browse files
committed
Added unit test class BackblazeClientTests.cs to Backblaze.Tests.Unit.csproj with tests that passing null for the ILoggerFactory parameter does not cause a crash.
Added a reference to NSubstitute to Backblaze.Tests.Unit.csproj.
1 parent eedbad7 commit 65d11ee

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

test/Unit/Backblaze.Tests.Unit.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
<ItemGroup>
2828
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
29+
<PackageReference Include="NSubstitute" Version="5.1.0" />
2930
<PackageReference Include="xunit" Version="2.9.2" />
3031
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
3132
<PrivateAssets>all</PrivateAssets>

test/Unit/BackblazeClientTests.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System.Net.Http;
2+
3+
using Bytewizer.Backblaze.Client;
4+
5+
using Microsoft.Extensions.Caching.Memory;
6+
7+
using Xunit;
8+
9+
using NSubstitute;
10+
11+
namespace Backblaze.Tests.Unit
12+
{
13+
public class BackblazeClientTests
14+
{
15+
[Fact]
16+
public void BackblazeClient_constructor_does_not_crash_on_null_loggerFactory()
17+
{
18+
// Arrange
19+
var clientOptions = new ClientOptions();
20+
21+
var dummyMemoryCache = Substitute.For<IMemoryCache>();
22+
23+
// Act & Assert
24+
new BackblazeClient(clientOptions, logger: null, dummyMemoryCache);
25+
}
26+
27+
[Fact]
28+
public void BackblazeClient_constructor_with_HttpClient_does_not_crash_on_null_loggerFactory()
29+
{
30+
// Arrange
31+
var clientOptions = new ClientOptions();
32+
33+
var httpClient = new HttpClient();
34+
35+
var dummyMemoryCache = Substitute.For<IMemoryCache>();
36+
37+
// Act & Assert
38+
new BackblazeClient(httpClient, clientOptions, logger: null, dummyMemoryCache);
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)