Testura/Testura.Code

Creating DeclareAndAssign statement with DateTime

Closed this issue · 1 comments

I've been through the docs and the source, and have been unable to determine how to create a DeclareAndAssign statement with a DateTime.

This works fine:
Statement.Declaration.DeclareAndAssign("intVar", 123);

This throws:
Statement.Declaration.DeclareAndAssign("dateVar", DateTime.Now); // throws System.NotSupportedException: 'Not a supported value'

I assume my syntax is wrong - what is the correct syntax here?

Super late to answer (but gonna do it if someone else are looking for it), you can simply use the VariableReference like this:

Statement.Declaration.DeclareAndAssign("datvar", typeof(DateTime), new VariableReference("DateTime", new MemberReference("Now")))