Skip to content

Add support for Assets #1846

@LasseHerget

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" />
}

Metadata

Metadata

Assignees

Labels

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

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions