-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved test extensions to separate project
- Loading branch information
Showing
36 changed files
with
231 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 13 additions & 16 deletions
29
...esting/BUnitLocalStorageTestExtensions.cs → ...ions/BUnitSessionStorageTestExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,34 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using Blazored.SessionStorage; | ||
using Blazored.SessionStorage.JsonConverters; | ||
using Blazored.SessionStorage.Serialization; | ||
using Blazored.SessionStorage.StorageOptions; | ||
using Blazored.SessionStorage.TestExtensions; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using Blazored.SessionStorage; | ||
using Blazored.SessionStorage.Testing; | ||
|
||
namespace Bunit | ||
{ | ||
[ExcludeFromCodeCoverage] | ||
public static class BUnitSessionStorageTestExtensions | ||
|
||
{ | ||
public static ISessionStorageService AddBlazoredSessionStorage(this TestContextBase context) | ||
=> AddBlazoredSessionStorage(context, null); | ||
|
||
public static ISessionStorageService AddBlazoredSessionStorage(this TestContextBase context, Action<SessionStorageOptions> configure) | ||
{ | ||
if (context is null) | ||
throw new ArgumentNullException(nameof(context)); | ||
throw new ArgumentNullException(nameof(context)); | ||
|
||
var sessionStorageOptions = new SessionStorageOptions(); | ||
configure?.Invoke(sessionStorageOptions); | ||
sessionStorageOptions.JsonSerializerOptions.Converters.Add(new TimespanJsonConverter()); | ||
|
||
context.Services | ||
.AddSingleton<IJsonSerializer, SystemTextJsonSerializer>() | ||
.AddSingleton<IStorageProvider, InMemoryStorageProvider>() | ||
.AddSingleton<ISessionStorageService, SessionStorageService>() | ||
.AddSingleton<ISyncSessionStorageService, SessionStorageService>() | ||
.Configure<SessionStorageOptions>(configureOptions => | ||
{ | ||
configure?.Invoke(configureOptions); | ||
configureOptions.JsonSerializerOptions.Converters.Add(new TimespanJsonConverter()); | ||
}); | ||
var localStorageService = new SessionStorageService(new InMemoryStorageProvider(), new SystemTextJsonSerializer(sessionStorageOptions)); | ||
context.Services.AddSingleton<ISessionStorageService>(localStorageService); | ||
|
||
return context.Services.GetService<ISessionStorageService>(); | ||
return localStorageService; | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/Blazored.SessionStorage.TestExtensions/Blazored.SessionStorage.TestExtensions.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.1;net5.0</TargetFrameworks> | ||
|
||
<Authors>Chris Sainty</Authors> | ||
<Company></Company> | ||
<Copyright>Copyright 2020 (c) Chris Sainty. All rights reserved.</Copyright> | ||
<Description>A testing library to provide helper extensions for Blazored.SessionStorage</Description> | ||
<IncludeSymbols>true</IncludeSymbols> | ||
<SymbolPackageFormat>snupkg</SymbolPackageFormat> | ||
|
||
<!-- NuGet settings --> | ||
<PackageId>Blazored.SessionStorage.TestExtensions</PackageId> | ||
<PackageTags>Blazored;Blazor;Razor;Components;SessionStorage;Session Storage;ASP.NET Core;CSharp;Web</PackageTags> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<PackageProjectUrl>https://github.com/Blazored/SessionStorage</PackageProjectUrl> | ||
<PackageIcon>icon.png</PackageIcon> | ||
<RepositoryType>git</RepositoryType> | ||
<RepositoryUrl>https://github.com/Blazored/SessionStorage</RepositoryUrl> | ||
|
||
<!-- SourceLink settings --> | ||
<PublishRepositoryUrl>true</PublishRepositoryUrl> | ||
<EmbedUntrackedSources>true</EmbedUntrackedSources> | ||
<SignAssembly>true</SignAssembly> | ||
<AssemblyOriginatorKeyFile>Blazored.SessionStorage.snk</AssemblyOriginatorKeyFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Include="..\Blazored.SessionStorage\icon.png" Pack="true" PackagePath="\" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="bunit.core" Version="1.2.49" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Blazored.SessionStorage\Blazored.SessionStorage.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute"> | ||
<_Parameter1> | ||
Blazored.SessionStorage.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001007527e122cc36dc13c695a4f43b7c2da3f631aed456ed309140c0d52262323e25d84bef7feddc8bd29cfe46ec652186cb10e059eedabf2ff000b977a2376a613dccfb092de6c243e0888db4c66a084124b2c1799bda4bbb2f70fed0382fc1cbdafa6dc0f4baccdc2cee55234f8a5ad76645c315523fee5352d9f01036e48b13e3 | ||
</_Parameter1> | ||
</AssemblyAttribute> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="..\Blazored.SessionStorage\Blazored.SessionStorage.snk" Link="Blazored.SessionStorage.snk" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Binary file added
BIN
+596 Bytes
src/Blazored.SessionStorage.TestExtensions/Blazored.SessionStorage.snk
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.