Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Client/Backblaze.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Authors>Microcompiler</Authors>
<Company>Bytewizer Inc.</Company>
<Product>Backblaze B2 Cloud Storage</Product>
<LangVersion>7.1</LangVersion>
<LangVersion>8.0</LangVersion>
<RootNamespace>Bytewizer.Backblaze</RootNamespace>
<VersionPrefix>1.1.0</VersionPrefix>
<Version Condition=" '$(Version)' == '' and '$(VersionSuffix)' != '' ">$(VersionPrefix)-$(VersionSuffix)</Version>
Expand Down
2 changes: 2 additions & 0 deletions src/Client/Client/Storage/Storage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ protected Storage(HttpClient client, IClientOptions options, ILoggerFactory logg
try
{
// Initialize components
logger ??= NullLoggerFactory.Instance;

_client = new ApiClient(client, options, logger.CreateLogger<ApiClient>(), cache);
_logger = logger.CreateLogger<Storage>();
}
Expand Down
1 change: 1 addition & 0 deletions test/Unit/Backblaze.Tests.Unit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
Expand Down
41 changes: 41 additions & 0 deletions test/Unit/BackblazeClientTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Net.Http;

using Bytewizer.Backblaze.Client;

using Microsoft.Extensions.Caching.Memory;

using Xunit;

using NSubstitute;

namespace Backblaze.Tests.Unit
{
public class BackblazeClientTests
{
[Fact]
public void BackblazeClient_constructor_does_not_crash_on_null_loggerFactory()
{
// Arrange
var clientOptions = new ClientOptions();

var dummyMemoryCache = Substitute.For<IMemoryCache>();

// Act & Assert
new BackblazeClient(clientOptions, logger: null, dummyMemoryCache);
}

[Fact]
public void BackblazeClient_constructor_with_HttpClient_does_not_crash_on_null_loggerFactory()
{
// Arrange
var clientOptions = new ClientOptions();

var httpClient = new HttpClient();

var dummyMemoryCache = Substitute.For<IMemoryCache>();

// Act & Assert
new BackblazeClient(httpClient, clientOptions, logger: null, dummyMemoryCache);
}
}
}