-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Andrew Petrochuk (from Dev Box) <[email protected]>
- Loading branch information
Showing
24 changed files
with
472 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using Microsoft.PowerPlatform.PowerApps.Persistence.Models; | ||
|
||
namespace Persistence.Tests.Yaml; | ||
|
||
[TestClass] | ||
public class DeserializeComponentTests : TestBase | ||
{ | ||
[TestMethod] | ||
[DataRow(@"_TestData/ValidYaml{0}/Components/with-custom-properties.pa.yaml", true, 6, 1, 3, | ||
"inputFuncImage", 1, "reqColorParam", "a required color param")] | ||
public void Deserialize_Component_Should_Succeed(string path, bool isControlIdentifiers, | ||
int customPropertiesCount, int childrenCount, int propertiesCount, | ||
string firstCustomProperyName, int firstCustomProperyParametersCount, | ||
string firstCustomProperyParameterName, string firstCustomProperyParameterDescription) | ||
{ | ||
// Arrange | ||
var deserializer = CreateDeserializer(isControlIdentifiers); | ||
using var yamlStream = File.OpenRead(GetTestFilePath(path, isControlIdentifiers)); | ||
using var yamlReader = new StreamReader(yamlStream); | ||
|
||
// Act | ||
var component = deserializer.Deserialize<Control>(yamlReader) as Component; | ||
if (component == null) | ||
throw new InvalidOperationException("Failed to deserialize component"); | ||
|
||
// Assert | ||
component.Should().NotBeNull(); | ||
component.Children!.Count.Should().Be(childrenCount); | ||
component.Properties!.Count.Should().Be(propertiesCount); | ||
component.Template.Should().NotBeNull(); | ||
component.Template!.Name.Should().Be("Component"); | ||
component.CustomProperties.Count.Should().Be(customPropertiesCount); | ||
component.CustomProperties[0].Name.Should().Be(firstCustomProperyName); | ||
component.CustomProperties[0].Parameters.Count.Should().Be(firstCustomProperyParametersCount); | ||
component.CustomProperties[0].Parameters[0].Name.Should().Be(firstCustomProperyParameterName); | ||
component.CustomProperties[0].Parameters[0].Description.Should().Be(firstCustomProperyParameterDescription); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Persistence.Tests/_TestData/ValidYaml-CI/Components/CustomProperty1.pa.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/Persistence.Tests/_TestData/ValidYaml-CI/Components/CustomProperty2.pa.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
Component1: | ||
Control: Component | ||
CustomProperties: | ||
MyFuncProp1: | ||
- MyFuncProp1: | ||
Direction: Input | ||
PropertyType: Function | ||
DataType: String | ||
IsResettable: false | ||
Default: lorem | ||
Parameters: | ||
param1: | ||
- param1: | ||
DataType: String | ||
IsRequired: true |
Oops, something went wrong.