Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test to show ColumnNames usage with External.ArrayAndObject untyp… #2588

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,24 @@ public void PadUntypedObject2MutationTest()
Assert.Equal(97m, result.ToObject());
}

[Fact]
public void PadUntypedObject2ColumnNamesTest()
{
var uo = new PadUntypedObject2(GetDataTable());
var uov = new UntypedObjectValue(IRContext.NotInSource(FormulaType.UntypedObject), uo);

PowerFxConfig config = new PowerFxConfig(Features.PowerFxV1);
RecalcEngine engine = new RecalcEngine(config);

engine.Config.SymbolTable.EnableMutationFunctions();
engine.UpdateVariable("padTable", uov, new SymbolProperties() { CanMutate = true, CanSetMutate = true });

var result = engine.Eval(@"ColumnNames(Index(padTable, 1))");

// would expect not to be an error value
Assert.IsType<ErrorValue>(result);
}

private DataTable GetDataTable()
{
var dt = new DataTable("someTable");
Expand Down Expand Up @@ -513,7 +531,7 @@ public override string GetUntypedNumber()
{
throw new NotImplementedException();
}

public string[] GetPropertyNames()
{
throw new NotImplementedException();
Expand Down Expand Up @@ -547,6 +565,13 @@ public override bool TryGetProperty(string propertyName, out IUntypedObject resu
public override bool TryGetPropertyNames(out IEnumerable<string> result)
{
result = null;

if (DataRow != null)
{
result = DataRow.Table.Columns.Cast<DataColumn>().Select(dc => dc.ColumnName);
return true;
}

return false;
}

Expand Down