Skip to content

Commit

Permalink
Merge pull request #428 from TimeWarpEngineering/Cramer/2024-06-23/Next
Browse files Browse the repository at this point in the history
Only include contentFiles in nuget. Put types in contentfiles and js …
  • Loading branch information
StevenTCramer authored Jun 25, 2024
2 parents ce519f9 + 991a401 commit 938ecc3
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ jobs:
cd ${{ github.workspace }}/Tests/TimeWarp.State.Analyzer.Tests/
dotnet restore
dotnet fixie --configuration Debug
- name: TimeWarp.State.Tests
run: |
cd ${{ github.workspace }}/Tests/TimeWarp.State.Tests/
dotnet restore
dotnet fixie --configuration Debug
# End to End Tests
- name: Test.App.EndToEnd.Tests
Expand Down
3 changes: 2 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Authors>Steven T. Cramer</Authors>
<Product>TimeWarp State</Product>
<PackageVersion>11.0.0-beta.44+8.0.300</PackageVersion>
<PackageVersion>11.0.0-beta.45+8.0.300</PackageVersion>
<PackageProjectUrl>https://timewarpengineering.github.io/blazor-state/</PackageProjectUrl>
<PackageTags>TimeWarp.State; TimeWarp-State; TimeWarpState; BlazorState; Blazor; State; Blazor-State; MediatR; Mediator; Pipeline; Redux; Flux</PackageTags>
<PackageIcon>Logo.png</PackageIcon>
Expand All @@ -13,6 +13,7 @@
<PackageLicenseExpression>Unlicense</PackageLicenseExpression>
<PackageReleaseNotes>https://timewarpengineering.github.io/blazor-state/Overview.html</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<ContentTargetFolders>contentFiles</ContentTargetFolders>
</PropertyGroup>

<!-- Deterministic Builds https://devblogs.microsoft.com/dotnet/producing-packages-with-source-link/#deterministic-builds -->
Expand Down
11 changes: 6 additions & 5 deletions Source/TimeWarp.State/Extensions/TypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ public static class TypeExtensions
public static Type GetEnclosingStateType(this Type type)
{
string name = type.Name;
while (!typeof(IState).IsAssignableFrom(type))
while (type.DeclaringType != null && !typeof(IState).IsAssignableFrom(type))
{
type = type.DeclaringType!; // Not null because of analyzer
type = type.DeclaringType;
}
if (type == null)

if (!typeof(IState).IsAssignableFrom(type))
{
throw new NonNestedClassException
($"{name} must be nested in a class that implements {nameof(IState)}");
($"{name} must be nested in a class that implements {nameof(IState)}");
}

return type!; // Not null because of analyzer
return type;
}
}
24 changes: 24 additions & 0 deletions Tests/TimeWarp.State.Tests/ConventionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace ConventionTest_;

using FluentAssertions;
using TimeWarp.Fixie;

[TestTag(TestTags.Fast)]
public class SimpleNoApplicationTest_Should_
{
public static void AlwaysPass() => true.Should().BeTrue();

[Skip("Demonstrates skip attribute")]
public static void SkipExample() => true.Should().BeFalse();

[TestTag(TestTags.Fast)]
public static void TagExample() => true.Should().BeTrue();

[Input(5, 3, 2)]
[Input(8, 5, 3)]
public static void Subtract(int aX, int aY, int aExpectedDifference)
{
int result = aX - aY;
result.Should().Be(aExpectedDifference);
}
}
3 changes: 3 additions & 0 deletions Tests/TimeWarp.State.Tests/TestingConvention.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace TimeWarp.State.Tests;

class TestingConvention : TimeWarp.Fixie.TestingConvention { }
19 changes: 19 additions & 0 deletions Tests/TimeWarp.State.Tests/TimeWarp.State.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Fixie.TestAdapter" />
<PackageReference Include="FluentAssertions" />
<PackageReference Include="TimeWarp.Fixie" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Source\TimeWarp.State\TimeWarp.State.csproj" />
</ItemGroup>

</Project>
58 changes: 58 additions & 0 deletions Tests/TimeWarp.State.Tests/TypeExtensionsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
namespace GetEnclosingStateType_;

using FluentAssertions;
using TimeWarp.Features.RenderSubscriptions;
using TimeWarp.State;
using TimeWarp.State.Extensions;

public class TypeExtensionsTests
{
private class TestState : IState
{
public class NestedClass
{
}

public class AnotherNestedClass : NestedClass
{
}

public Guid Guid { get; }
public void Initialize() => throw new NotImplementedException();
}

public void Should_Get_Enclosing_State_Type_For_Nested_Class()
{
// Arrange
Type nestedClassType = typeof(TestState.NestedClass);

// Act
Type enclosingStateType = nestedClassType.GetEnclosingStateType();

// Assert
enclosingStateType.Should().Be(typeof(TestState));
}

public void Should_Get_Enclosing_State_Type_For_Deeply_Nested_Class()
{
// Arrange
Type deeplyNestedClassType = typeof(TestState.AnotherNestedClass);

// Act
Type enclosingStateType = deeplyNestedClassType.GetEnclosingStateType();

// Assert
enclosingStateType.Should().Be(typeof(TestState));
}

public void Should_Throw_Exception_For_Non_Nested_Class()
{
// Arrange
Type nonNestedClassType = typeof(string); // Example of a non-nested class

// Act & Assert
Action act = () => nonNestedClassType.GetEnclosingStateType();
act.Should().Throw<NonNestedClassException>()
.WithMessage("String must be nested in a class that implements IState");
}
}
9 changes: 9 additions & 0 deletions TimeWarp.State.sln
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Integration.Tests",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.App.EndToEnd.Tests", "Tests\Test.App.EndToEnd.Tests\Test.App.EndToEnd.Tests.csproj", "{1E3F033B-0E8E-41A5-A2A0-A3E4B7FF772C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimeWarp.State.Tests", "Tests\TimeWarp.State.Tests\TimeWarp.State.Tests.csproj", "{B885628C-1360-4665-BB59-0F72BB3EA9AD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -154,6 +156,12 @@ Global
{1E3F033B-0E8E-41A5-A2A0-A3E4B7FF772C}.ReduxDevToolsEnabled|Any CPU.Build.0 = Debug|Any CPU
{1E3F033B-0E8E-41A5-A2A0-A3E4B7FF772C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1E3F033B-0E8E-41A5-A2A0-A3E4B7FF772C}.Release|Any CPU.Build.0 = Release|Any CPU
{B885628C-1360-4665-BB59-0F72BB3EA9AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B885628C-1360-4665-BB59-0F72BB3EA9AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B885628C-1360-4665-BB59-0F72BB3EA9AD}.ReduxDevToolsEnabled|Any CPU.ActiveCfg = Debug|Any CPU
{B885628C-1360-4665-BB59-0F72BB3EA9AD}.ReduxDevToolsEnabled|Any CPU.Build.0 = Debug|Any CPU
{B885628C-1360-4665-BB59-0F72BB3EA9AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B885628C-1360-4665-BB59-0F72BB3EA9AD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -173,6 +181,7 @@ Global
{8891678E-2973-403B-9205-2DB2AEA6D7F7} = {B96A36DB-E4B3-412D-A9BB-7E97A9D042F4}
{D8CF79FE-21E3-4075-AA23-DD98329FFB14} = {2902FDFD-016E-4BF7-8B41-53D674FA53DD}
{1E3F033B-0E8E-41A5-A2A0-A3E4B7FF772C} = {2902FDFD-016E-4BF7-8B41-53D674FA53DD}
{B885628C-1360-4665-BB59-0F72BB3EA9AD} = {2902FDFD-016E-4BF7-8B41-53D674FA53DD}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {16FA64C2-4A0E-42D4-94E6-C8CFDE84597E}
Expand Down

0 comments on commit 938ecc3

Please sign in to comment.