Skip to content

Commit c23e7df

Browse files
Update PowerFx to 1.1 (#311)
* Updating powerfx to 1.1 * updating tests * refactoring --------- Co-authored-by: jt000 <jasontre@microsoft.com>
1 parent b53215c commit c23e7df

File tree

6 files changed

+24
-18
lines changed

6 files changed

+24
-18
lines changed

src/Microsoft.PowerApps.TestEngine.Tests/PowerApps/PowerAppFunctionsTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public async Task SetPropertyNumberAsyncTest()
122122
var powerAppFunctions = new PowerAppFunctions(MockTestInfraFunctions.Object, MockSingleTestInstanceState.Object, MockTestState.Object);
123123
string itemPathString = "{\"controlName\":\"Rating1\",\"index\":null,\"parentControl\":null,\"propertyName\":\"Value\"}";
124124
var itemPath = JsonConvert.DeserializeObject<ItemPath>(itemPathString);
125-
var value = 5;
125+
var value = 5d;
126126
var numberValue = NumberValue.New(value);
127127
var jsonSerializedValue = JsonConvert.SerializeObject(numberValue.Value);
128128
var result = await powerAppFunctions.SetPropertyAsync(itemPath, numberValue);

src/Microsoft.PowerApps.TestEngine.Tests/PowerFx/Functions/SetPropertyFunctionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void SetPropertyNumberFunctionTest()
102102
var setPropertyFunction = new SetPropertyFunction(MockPowerAppFunctions.Object, MockLogger.Object);
103103

104104
// Set the value of Rating1's 'Value' property to 5
105-
var result = setPropertyFunction.Execute(recordValue, StringValue.New("Value"), NumberValue.New(5));
105+
var result = setPropertyFunction.Execute(recordValue, StringValue.New("Value"), NumberValue.New(5d));
106106

107107
// check to see if the value of Rating1's 'Value' property is 5
108108
Assert.IsType<BooleanValue>(result);

src/Microsoft.PowerApps.TestEngine.Tests/PowerFx/Functions/SomeOtherUntypedObject.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
3+
34
using Microsoft.PowerFx.Types;
5+
using NotImplementedException = System.NotImplementedException;
6+
using System.Collections.Generic;
47

58
namespace Microsoft.PowerApps.TestEngine.Tests.PowerFx.Functions
69
{
710
public class SomeOtherUntypedObject : IUntypedObject
811
{
912
public IUntypedObject this[int index] => throw new global::System.NotImplementedException();
1013

14+
public bool TryGetPropertyNames(out IEnumerable<string> propertyNames)
15+
{
16+
throw new NotImplementedException();
17+
}
18+
1119
public FormulaType Type
1220
{
1321
get

src/Microsoft.PowerApps.TestEngine.Tests/PowerFx/Functions/WaitFunctionTests.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ public void WaitFunctionNumberThrowsOnInvalidArgumentsTest()
5353
var recordType = RecordType.Empty().Add("Text", FormulaType.Number);
5454
var waitFunction = new WaitFunctionNumber(Timeout, MockLogger.Object);
5555
var recordValue = new ControlRecordValue(recordType, MockPowerAppFunctions.Object, "Label1");
56-
Assert.Throws<ArgumentNullException>(() => waitFunction.Execute(null, FormulaValue.New("Text"), FormulaValue.New(1)));
57-
Assert.Throws<ArgumentNullException>(() => waitFunction.Execute(new SomeOtherRecordValue(recordType), null, FormulaValue.New(1)));
56+
Assert.Throws<ArgumentNullException>(() => waitFunction.Execute(null, FormulaValue.New("Text"), FormulaValue.New(1d)));
57+
Assert.Throws<ArgumentNullException>(() => waitFunction.Execute(new SomeOtherRecordValue(recordType), null, FormulaValue.New(1d)));
5858
Assert.Throws<ArgumentNullException>(() => waitFunction.Execute(new SomeOtherRecordValue(recordType), FormulaValue.New("Text"), null));
59-
Assert.Throws<InvalidCastException>(() => waitFunction.Execute(new SomeOtherRecordValue(recordType), FormulaValue.New("Text"), FormulaValue.New(1)));
59+
Assert.Throws<InvalidCastException>(() => waitFunction.Execute(new SomeOtherRecordValue(recordType), FormulaValue.New("Text"), FormulaValue.New(1d)));
6060
}
6161

6262
[Fact]
@@ -141,13 +141,13 @@ public void WaitFunctionImproperValueForStringTest()
141141
public void WaitFunctionNumberSucceedsTest()
142142
{
143143
LoggingTestHelper.SetupMock(MockLogger);
144-
var valueToWaitFor = 1;
144+
var valueToWaitFor = 1d;
145145
var recordType = RecordType.Empty().Add("Text", FormulaType.Number);
146146

147147
var recordValue = new ControlRecordValue(recordType, MockPowerAppFunctions.Object, "Label1");
148148
var jsPropertyValueModel = new JSPropertyValueModel()
149149
{
150-
PropertyValue = valueToWaitFor.ToString(),
150+
PropertyValue = valueToWaitFor.ToString("G"),
151151
};
152152
var expectedItemPath = new ItemPath
153153
{
@@ -159,7 +159,7 @@ public void WaitFunctionNumberSucceedsTest()
159159
MockTestState.Setup(x => x.GetTimeout()).Returns(Timeout);
160160

161161
var waitFunction = new WaitFunctionNumber(Timeout, MockLogger.Object);
162-
waitFunction.Execute(recordValue, FormulaValue.New("Text"), NumberValue.New(valueToWaitFor));
162+
waitFunction.Execute(recordValue, FormulaValue.New("Text"), FormulaValue.New(valueToWaitFor));
163163

164164
MockPowerAppFunctions.Verify(x => x.GetPropertyValueFromControl<string>(It.Is<ItemPath>((itemPath) => itemPath.ControlName == expectedItemPath.ControlName && itemPath.PropertyName == expectedItemPath.PropertyName)), Times.Exactly(2));
165165
}
@@ -185,7 +185,7 @@ public void WaitFunctionImproperValueForNumberTest()
185185
MockTestState.Setup(x => x.GetTimeout()).Returns(Timeout);
186186

187187
var waitFunction = new WaitFunctionNumber(Timeout, MockLogger.Object);
188-
Assert.Throws<InvalidDataException>(() => waitFunction.Execute(recordValue, FormulaValue.New("Value"), NumberValue.New(1)));
188+
Assert.Throws<InvalidDataException>(() => waitFunction.Execute(recordValue, FormulaValue.New("Value"), FormulaValue.New(1d)));
189189
}
190190

191191
[Fact]
@@ -405,7 +405,7 @@ public void WaitFunctionStringWaitsForValueToUpdateTest()
405405
public void WaitFunctionNumberWaitsForValueToUpdateTest()
406406
{
407407
LoggingTestHelper.SetupMock(MockLogger);
408-
var valueToWaitFor = 1;
408+
var valueToWaitFor = 1d;
409409
var recordType = RecordType.Empty().Add("Text", FormulaType.Number);
410410
var recordValue = new ControlRecordValue(recordType, MockPowerAppFunctions.Object, "Label1");
411411
var jsPropertyValueModel = new JSPropertyValueModel()
@@ -414,7 +414,7 @@ public void WaitFunctionNumberWaitsForValueToUpdateTest()
414414
};
415415
var finalJsPropertyValueModel = new JSPropertyValueModel()
416416
{
417-
PropertyValue = valueToWaitFor.ToString(),
417+
PropertyValue = valueToWaitFor.ToString("G"),
418418
};
419419
var expectedItemPath = new ItemPath
420420
{
@@ -428,7 +428,7 @@ public void WaitFunctionNumberWaitsForValueToUpdateTest()
428428
MockTestState.Setup(x => x.GetTimeout()).Returns(Timeout);
429429

430430
var waitFunction = new WaitFunctionNumber(Timeout, MockLogger.Object);
431-
waitFunction.Execute(recordValue, FormulaValue.New("Text"), NumberValue.New(valueToWaitFor));
431+
waitFunction.Execute(recordValue, FormulaValue.New("Text"), FormulaValue.New(valueToWaitFor));
432432

433433
MockPowerAppFunctions.Verify(x => x.GetPropertyValueFromControl<string>(It.Is<ItemPath>((itemPath) => itemPath.ControlName == expectedItemPath.ControlName && itemPath.PropertyName == expectedItemPath.PropertyName)), Times.Exactly(3));
434434
}
@@ -554,7 +554,7 @@ public void WaitFunctionStringTimeoutTest()
554554
public void WaitFunctionNumberTimeoutTest()
555555
{
556556
LoggingTestHelper.SetupMock(MockLogger);
557-
var valueToWaitFor = 1;
557+
var valueToWaitFor = 1d;
558558
var recordType = RecordType.Empty().Add("Text", FormulaType.Number);
559559
var recordValue = new ControlRecordValue(recordType, MockPowerAppFunctions.Object, "Label1");
560560
var jsPropertyValueModel = new JSPropertyValueModel()

src/Microsoft.PowerApps.TestEngine.Tests/PowerFx/PowerFxEngineTests.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Collections.Generic;
66
using System.Globalization;
7+
using System.Threading;
78
using System.Threading.Tasks;
89
using Microsoft.Extensions.Logging;
910
using Microsoft.PowerApps.TestEngine.Config;
@@ -485,10 +486,7 @@ public async Task TestStepByStep()
485486
});
486487
MockPowerAppFunctions.Setup(x => x.CheckAndHandleIfLegacyPlayerAsync()).Returns(Task.FromResult(true));
487488
MockPowerAppFunctions.Setup(x => x.CheckIfAppIsIdleAsync()).Returns(Task.FromResult(true));
488-
MockPowerAppFunctions.Setup(x => x.SelectControlAsync(It.IsAny<ItemPath>())).Callback(async () =>
489-
{
490-
await powerFxEngine.UpdatePowerFxModelAsync();
491-
}).Returns(Task.FromResult(true));
489+
MockPowerAppFunctions.Setup(x => x.SelectControlAsync(It.IsAny<ItemPath>())).Returns(Task.FromResult(true));
492490

493491
var oldUICulture = CultureInfo.CurrentUICulture;
494492
var frenchCulture = new CultureInfo("fr");

src/Microsoft.PowerApps.TestEngine/Microsoft.PowerApps.TestEngine.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
3131
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
3232
<PackageReference Include="Microsoft.Playwright" Version="1.35.0" />
33-
<PackageReference Include="Microsoft.PowerFx.Interpreter" Version="0.2.6-preview" />
33+
<PackageReference Include="Microsoft.PowerFx.Interpreter" Version="1.1.0" />
3434
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
3535
<PackageReference Include="YamlDotNet" Version="11.2.1" />
3636
</ItemGroup>

0 commit comments

Comments
 (0)