Sitelet https://github.com/bUnit-dev/bUnit/issues/1846
Skip to content

Add support for Assets #1846

Description

@LasseHerget

Hey,

I need to test a component that iterates over the Assets property.
I am currently struggling to figure out how to seed these Assets in bunit.

I already saw that this has been suggested for net9.0, and I am working in net10.0.
However that issue has been closed, because the usecase under test was (probably) appending the hash to the path.
#1612

But my usecase to test is an iteration over these assets.

So my question is:
How exactly would I correctly set these assets up in bUnit?

Scenario

public partial class AssetComponent : ComponentBase
{
    private IReadOnlyList<string> SubresourceNames { get; set; } 
   
    protected override void OnInitialized()
    {
        SubresourceNames = Assets
            .Select(asset => asset.Properties?.Single(property => property.Name == "label")?.Value) // The "label" property contains the relative file path.
            .Where( .. )
            .ToList();
    }
}
@foreach (var assetName in SubresourceNames)
{
  <DoStuff attribute="@assetName" />
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

needs designMore design is needed before this issue should result in a feature being implemented.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions