-
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.
iteration two, ready for consumption by pac cli
- Loading branch information
1 parent
ef050cd
commit ca58cc6
Showing
12 changed files
with
95 additions
and
158 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/Persistence.Tests/YamlValidator/ValidatorFactoryTest.cs
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,20 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using Microsoft.PowerPlatform.PowerApps.Persistence.YamlValidator; | ||
|
||
namespace Persistence.Tests.YamlValidator; | ||
|
||
[TestClass] | ||
public class ValidatorFactoryTest | ||
{ | ||
[TestMethod] | ||
public void GetValidatorTest() | ||
{ | ||
var factory = new ValidatorFactory(); | ||
var validator = factory.GetValidator(); | ||
|
||
Assert.IsNotNull(validator); | ||
Assert.IsInstanceOfType(validator, typeof(Validator)); | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
src/Persistence.Tests/_TestData/ValidatorTests/InvalidYaml/NotYaml.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
features => [ | ||
{ | ||
name => lorem ipsum, | ||
points => [ | ||
"bullet 1", | ||
"bullet 2" | ||
] | ||
}, | ||
{ | ||
name => lorem ipsum 2, | ||
description => lorem ipsum 3 | ||
} | ||
] | ||
} |
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,31 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using Json.Schema; | ||
using System.Text.Json; | ||
|
||
namespace Microsoft.PowerPlatform.PowerApps.Persistence.YamlValidator; | ||
|
||
public class ValidatorFactory | ||
{ | ||
public Validator GetValidator() | ||
{ | ||
// register schema in from memory into global schema registry | ||
var schemaLoader = new SchemaLoader(); | ||
var serializedSchema = schemaLoader.Load(); | ||
|
||
var evalOptions = new EvaluationOptions | ||
{ | ||
OutputFormat = OutputFormat.List | ||
}; | ||
|
||
// pass in serailization options for validator results object to json | ||
// This is unused for now but can be useful for producing raw json validation results which can be consumed elsewhere | ||
var resultSerializeOptions = new JsonSerializerOptions | ||
{ | ||
Converters = { new EvaluationResultsJsonConverter() } | ||
}; | ||
|
||
return new Validator(evalOptions, resultSerializeOptions, serializedSchema); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.