Skip to content

Commit

Permalink
Fix namespaces; Fix Dependency Injection; Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Psypher9 committed Sep 29, 2023
1 parent 875307d commit 5c407ef
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 11 deletions.
33 changes: 33 additions & 0 deletions BlazorToolkit.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AstroPanda.Blazor.Toolkit", "src\AstroPanda.Blazor.Toolkit.csproj", "{30E1015A-A3BB-4FDA-BB5D-3D1054E9196A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{04E1DA45-4FDB-4ACE-B236-8FA4C8F5FAEE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AstroPanda.Blazor.Toolkit.Test", "test\AstroPanda.Blazor.Toolkit.Test\AstroPanda.Blazor.Toolkit.Test\AstroPanda.Blazor.Toolkit.Test.csproj", "{FCB43029-3141-45C0-9E11-BC045C8538DE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{30E1015A-A3BB-4FDA-BB5D-3D1054E9196A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30E1015A-A3BB-4FDA-BB5D-3D1054E9196A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30E1015A-A3BB-4FDA-BB5D-3D1054E9196A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30E1015A-A3BB-4FDA-BB5D-3D1054E9196A}.Release|Any CPU.Build.0 = Release|Any CPU
{FCB43029-3141-45C0-9E11-BC045C8538DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FCB43029-3141-45C0-9E11-BC045C8538DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FCB43029-3141-45C0-9E11-BC045C8538DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FCB43029-3141-45C0-9E11-BC045C8538DE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{FCB43029-3141-45C0-9E11-BC045C8538DE} = {04E1DA45-4FDB-4ACE-B236-8FA4C8F5FAEE}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion src/Components/PrintableArea.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@namespace AstroPanda.Blazor.Toolkit

@using AstroPanda.Blazor.Toolkit.Services
@using AstroPanda.Blazor.Toolkit

<div id="@Id" class="printable-area">
@ChildContent
Expand Down
2 changes: 1 addition & 1 deletion src/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using AstroPanda.Blazor.Toolkit.Services;
using AstroPanda.Blazor.Toolkit;

namespace AstroPanda.Blazor.Toolkit;
public static class ServiceCollectionExtensions
Expand Down
5 changes: 1 addition & 4 deletions src/Services/IPrintService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Microsoft.AspNetCore.Components;
using System.Threading.Tasks;

namespace AstroPanda.Blazor.Toolkit.Services;
namespace AstroPanda.Blazor.Toolkit;

public interface IPrintService
{
Expand Down
7 changes: 2 additions & 5 deletions src/Services/PrintService.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using System;
using System.Threading.Tasks;
using Microsoft.JSInterop;

namespace AstroPanda.Blazor.Toolkit.Services
namespace AstroPanda.Blazor.Toolkit
{
public class PrintService : IPrintService, IAsyncDisposable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<Using Include="Bunit" />
<Using Include="Bunit.TestDoubles" />
<Using Include="Microsoft.Extensions.DependencyInjection" />
<Using Include="Xunit" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="bunit" Version="1.23.9" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.12.0" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\AstroPanda.Blazor.Toolkit.csproj" />
</ItemGroup>



</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace AstroPanda.Blazor.Toolkit.Test;

public class ServiceCollectionExtensionsTests : TestContext
{

[Fact]
public void AddBlazorToolkit_Adds_All_Services_To_ServiceCollection()
{
// Act
Services.AddBlazorToolkit();

// Assert
Assert.NotNull(Services.GetService<IDownloadService>());
Assert.NotNull(Services.GetService<IPrintService>());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.JSInterop
@using Microsoft.Extensions.DependencyInjection
@using Bunit
@using Bunit.TestDoubles
@using Xunit

0 comments on commit 5c407ef

Please sign in to comment.