Skip to content

Commit

Permalink
Merge branch 'master' into users/shshetty/GalleryIssue
Browse files Browse the repository at this point in the history
  • Loading branch information
shshetty-microsoft authored Jul 25, 2024
2 parents 6386b38 + b2a2aef commit 47864b4
Show file tree
Hide file tree
Showing 36 changed files with 350 additions and 221 deletions.
13 changes: 13 additions & 0 deletions src/PASopa.sln
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{7361DB16-D53
Versions.props = Versions.props
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YamlValidator", "YamlValidator\Microsoft.PowerPlatform.PowerApps.YamlValidator.csproj", "{296D952B-C284-4AAB-9A79-59538CA7BF38}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YamlValidator.Tests", "YamlValidator.Tests\YamlValidator.Tests.csproj", "{E6180C81-59C1-4B25-90E0-E4390D455518}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -52,6 +56,14 @@ Global
{8AB1C901-FE5E-44BF-AA21-B8F20A9D7CDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8AB1C901-FE5E-44BF-AA21-B8F20A9D7CDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8AB1C901-FE5E-44BF-AA21-B8F20A9D7CDD}.Release|Any CPU.Build.0 = Release|Any CPU
{296D952B-C284-4AAB-9A79-59538CA7BF38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{296D952B-C284-4AAB-9A79-59538CA7BF38}.Debug|Any CPU.Build.0 = Debug|Any CPU
{296D952B-C284-4AAB-9A79-59538CA7BF38}.Release|Any CPU.ActiveCfg = Release|Any CPU
{296D952B-C284-4AAB-9A79-59538CA7BF38}.Release|Any CPU.Build.0 = Release|Any CPU
{E6180C81-59C1-4B25-90E0-E4390D455518}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E6180C81-59C1-4B25-90E0-E4390D455518}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E6180C81-59C1-4B25-90E0-E4390D455518}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E6180C81-59C1-4B25-90E0-E4390D455518}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -60,6 +72,7 @@ Global
{8AD94CC0-7330-4880-A8E0-177B37CDB27B} = {4993E606-484B-46D9-892E-7AE9CE8D4423}
{8AB1C901-FE5E-44BF-AA21-B8F20A9D7CDD} = {4993E606-484B-46D9-892E-7AE9CE8D4423}
{7361DB16-D534-4E0E-8597-BE22317DEF47} = {794D8C68-BF6F-49C8-BCA5-AA52D8F45EF4}
{E6180C81-59C1-4B25-90E0-E4390D455518} = {4993E606-484B-46D9-892E-7AE9CE8D4423}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C936F8B1-DE7A-4401-95D5-5E199210F960}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<PublicSign>true</PublicSign>
<!-- Workaround for version range https://github.com/NuGet/Home/issues/11842 -->
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<NoWarn>$(NoWarn);NU1601;CA1822</NoWarn>
<NoWarn>$(NoWarn);NU1601</NoWarn>
</PropertyGroup>

<ItemGroup Label="Global usings">
Expand All @@ -43,18 +43,6 @@
<PackageReference Include="Microsoft.PowerFx.Core" Version="1.2.0" />
<PackageReference Include="YamlDotNet" Version="$(YamlDotNetVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingVersion)" />
<PackageReference Include="JsonSchema.Net" Version="7.1.0" />
<PackageReference Include="Yaml2JsonNode" Version="2.1.0" />
</ItemGroup>

<ItemGroup>
<Content Include="..\..\docs\pa.yaml-schema.json" Link="YamlValidator\schema\pa.yaml-schema.json" CopyToOutputDirectory="PreserveNewest" />
<Content Include="..\..\docs\subschemas\control-type-schema.json" Link="YamlValidator\schema\subschemas\control-type-schema.json" CopyToOutputDirectory="PreserveNewest" />
<Content Include="..\..\docs\subschemas\control-property-schema.json" Link="YamlValidator\schema\subschemas\control-property-schema.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="Persistence.Tests" Key="0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9" />
</ItemGroup>

</Project>
</Project>
18 changes: 0 additions & 18 deletions src/Persistence/YamlValidator/Constants.cs

This file was deleted.

29 changes: 0 additions & 29 deletions src/Persistence/YamlValidator/SchemaLoader.cs

This file was deleted.

40 changes: 0 additions & 40 deletions src/Persistence/YamlValidator/ValidationProcessor.cs

This file was deleted.

25 changes: 0 additions & 25 deletions src/Persistence/YamlValidator/VerbosityData.cs

This file was deleted.

49 changes: 0 additions & 49 deletions src/Persistence/YamlValidator/YamlLoader.cs

This file was deleted.

38 changes: 38 additions & 0 deletions src/YamlValidator.Tests/TestBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Microsoft.PowerPlatform.PowerApps.Persistence.YamlValidator;


namespace Persistence.YamlValidator.Tests;
public abstract class TestBase : VSTestBase
{
public static IServiceProvider ServiceProvider { get; set; }
public IValidatorFactory ValidatorFactory { get; private set; }

static TestBase()
{
ServiceProvider = BuildServiceProvider();
}

public TestBase()
{
ValidatorFactory = ServiceProvider.GetRequiredService<IValidatorFactory>();
}

private static ServiceProvider BuildServiceProvider()
{
var serviceCollection = new ServiceCollection();
var serviceProvider = ConfigureServices(serviceCollection);

return serviceProvider;
}

private static ServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddPowerAppsPersistenceYamlValidator();

return services.BuildServiceProvider();
}

}
16 changes: 16 additions & 0 deletions src/YamlValidator.Tests/VSTestBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Persistence.YamlValidator.Tests;

/// <summary>
/// Represents a shared base class for any test class that uses the Visual Studio Test Framework.
/// </summary>
/// <remarks>
/// DO NOT add any setup/tear down logic to this class, as not all tests may require it.
/// The preferred approach is to use a different derived base class for tests that require setup/tear down logic specific to some shared scenarios.
/// </remarks>
public abstract class VSTestBase
{
public required TestContext TestContext { get; set; }
}
20 changes: 20 additions & 0 deletions src/YamlValidator.Tests/ValidatorFactoryTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Microsoft.PowerPlatform.PowerApps.Persistence.YamlValidator;

namespace Persistence.YamlValidator.Tests;

[TestClass]
public class ValidatorFactoryTest : TestBase
{
[TestMethod]
public void GetValidatorTest()
{
var factory = new ValidatorFactory();
var validator = factory.CreateValidator();

Assert.IsNotNull(validator);
Assert.IsInstanceOfType(validator, typeof(IValidator));
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Json.Schema;
using Microsoft.PowerPlatform.PowerApps.Persistence.YamlValidator;

namespace Persistence.Tests.YamlValidator;
namespace Persistence.YamlValidator.Tests;

[TestClass]
public class ValidatorTest
public class ValidatorTest : TestBase
{

private static readonly string _validPath = Path.Combine(".", "_TestData", "ValidatorTests", "ValidYaml") +
private static readonly string _validPath = Path.Combine(".", "_TestData", "ValidYaml") +
Path.DirectorySeparatorChar;

private static readonly string _invalidPath = Path.Combine(".", "_TestData", "ValidatorTests", "InvalidYaml") +
private static readonly string _invalidPath = Path.Combine(".", "_TestData", "InvalidYaml") +
Path.DirectorySeparatorChar;

private readonly JsonSchema _schema;
private readonly Validator _yamlValidator;
private readonly IValidator _yamlValidator;

public ValidatorTest()
{
var schemaFileLoader = new SchemaLoader();
_schema = schemaFileLoader.Load();
var resultVerbosity = new VerbosityData(Constants.Verbose);
_yamlValidator = new Validator(resultVerbosity.EvalOptions, resultVerbosity.JsonOutputOptions);
_yamlValidator = ValidatorFactory.CreateValidator();
}

[TestMethod]
Expand All @@ -34,8 +29,8 @@ public ValidatorTest()

public void TestValidationValidYaml(string filename)
{
var rawYaml = Utility.ReadFileData($@"{_validPath}{filename}");
var result = _yamlValidator.Validate(_schema, rawYaml);
var rawYaml = File.ReadAllText($@"{_validPath}{filename}");
var result = _yamlValidator.Validate(rawYaml);
Assert.IsTrue(result.SchemaValid);
}

Expand All @@ -48,10 +43,11 @@ public void TestValidationValidYaml(string filename)
[DataRow("EmptyArray.yaml")]
[DataRow("Empty.yaml")]
[DataRow("NamelessObjectNoControl.yaml")]
[DataRow("NotYaml.yaml")]
public void TestValidationInvalidYaml(string filename)
{
var rawYaml = Utility.ReadFileData($@"{_invalidPath}{filename}");
var result = _yamlValidator.Validate(_schema, rawYaml);
var rawYaml = File.ReadAllText($@"{_invalidPath}{filename}");
var result = _yamlValidator.Validate(rawYaml);
Assert.IsFalse(result.SchemaValid);
}
}
Loading

0 comments on commit 47864b4

Please sign in to comment.