Skip to content

Bunit tests for editForm dependent components #744

Answered by egil
LasVegasIs asked this question in Q&A
Discussion options

You must be logged in to vote

UPDATED with code that probably works :) (I actually have not tested it locally, just typing this out on my phone between meetings).

@LasVegasIs, I would probably write my test in .razor file, but if you prefer C#, then something like this should work:

var ctx = new TestContext();

var model = new SampleModel();
var editContext = new EditContext(model);
var dateFormat = "yyyy-MM-ddTHH:mm";
var minimumValue = DateTime.Now.AddDays(-2);
var minimumValueWithFormat = minimumValue.ToString(dateFormat);
var value = DateTime.Now;

var editForm = ctx.RenderComponent<CascadingValue<EditContext>>(ps => ps
  .Add(p => p.value, editContext)
  .AddChildContent<InputDateTime>(idtps => ipdtps.
    .Add(p =>

Replies: 6 comments 7 replies

Comment options

linkdotnet
Jun 3, 2022
Maintainer Sponsor

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@linkdotnet
Comment options

linkdotnet Jun 7, 2022
Maintainer Sponsor

@egil
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by egil
Comment options

You must be logged in to vote
5 replies
@linkdotnet
Comment options

linkdotnet Jun 7, 2022
Maintainer Sponsor

@LasVegasIs
Comment options

@egil
Comment options

@linkdotnet
Comment options

linkdotnet Jun 7, 2022
Maintainer Sponsor

@egil
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants