static async Task Main(string[] args) { string authToken = args[0]; long repoId = long.Parse(args[1]); int pullRequestId = int.Parse(args[2]); string format = args[3]; if (!Enum.IsDefined(typeof(OutputFormat), format)) { throw new Exception($"Format must be one of 'space_delimited', 'csv', or 'json', got '{format}'."); } OutputFormat outputFormat = (OutputFormat)Enum.Parse(typeof(OutputFormat), format); GitHubClient gitClient = new GitHubClient(new ProductHeaderValue("Microsoft.IoT.ModelsRepository.Validator")); gitClient.Credentials = new Credentials(authToken); IModelValidationService modelValidationService = new ModelValidationService(gitClient); RepositoryUpdatesFormatted result = await modelValidationService.GetRepositoryUpdates(repoId, pullRequestId, outputFormat); Console.WriteLine($"::set-output name=all::{result.FilesAllFormatted}"); Console.WriteLine($"::set-output name=added::{result.FilesAddedFormatted}"); Console.WriteLine($"::set-output name=modified::{result.FilesModifiedFormatted}"); Console.WriteLine($"::set-output name=removed::{result.FilesRemovedFormatted}"); Console.WriteLine($"::set-output name=renamed::{result.FilesRenamedFormatted}"); Console.WriteLine($"::set-output name=added_modified::{result.FilesAddedModifiedFormatted}"); }
public void Validate_WhenDuplicates_ReturnsError() { var command = new UpdatePageAccessRuleSetCommand(); command.PageId = 1; command.AccessRules.AddNew("TST"); command.AccessRules.AddNew("TST"); command.AccessRules.AddNew("TST", 9); command.AccessRules.AddNew("BLH"); command.AccessRules.AddNew("BLH", 6); command.AccessRules.AddNew("BLH", 6); var validationService = new ModelValidationService(); var errors = validationService.GetErrors(command); using (new AssertionScope()) { errors.Should().HaveCount(2); var roleError = errors.Single(e => e.Message.Contains("role")); roleError.Should().NotBeNull(); roleError.Properties.Single().Should().Be(nameof(command.AccessRules)); roleError.Message.Should().Match("Duplicate*role*"); var userAreaError = errors.Single(e => e.Message.Contains("user area")); userAreaError.Should().NotBeNull(); userAreaError.Properties.Single().Should().Be(nameof(command.AccessRules)); userAreaError.Message.Should().Match("Duplicate*user area*"); } }
private static void CanValidatePropertiesOnSiteModel <TModel>(TModel def, Action <List <ValidationResult> > action) where TModel : DefinitionBase { var validationService = new ModelValidationService(); var model = SPMeta2Model.NewSiteModel(); model.ChildModels.Add(new ModelNode { Value = def }); validationService.DeployModel(null, model); var result = validationService.Result; action(result); }
public void Validate_WhenBadEnum_ReturnsError() { var command = new UpdatePageAccessRuleSetCommand(); command.PageId = 1; command.AccessRules.AddNew("TST"); command.ViolationAction = (AccessRuleViolationAction)Int32.MinValue; var validationService = new ModelValidationService(); var errors = validationService.GetErrors(command); using (new AssertionScope()) { errors.Should().HaveCount(1); var error = errors.Single(e => e.Properties.Contains(nameof(command.ViolationAction))); error.Should().NotBeNull(); error.Properties.Should().HaveCount(1); } }
public void Validate_WhenRedirectAreaIsNotInAccessRules_ReturnsError() { var command = new UpdatePageAccessRuleSetCommand(); command.PageId = 1; command.UserAreaCodeForSignInRedirect = "NON"; command.AccessRules.AddNew("TST"); var validationService = new ModelValidationService(); var errors = validationService.GetErrors(command); using (new AssertionScope()) { errors.Should().HaveCount(1); var error = errors.Single(e => e.Properties.Contains(nameof(command.UserAreaCodeForSignInRedirect))); error.Should().NotBeNull(); error.Properties.Should().HaveCount(1); error.Message.Should().Match("*redirect*sign in*access rules*"); } }
private static void CanValidateRequiredPropertiesOnSiteModel <TModel>(Action <ValidationPair <TModel> > action) where TModel : DefinitionBase, new() { var validationService = new ModelValidationService(); var def = new TModel(); var model = SPMeta2Model.NewSiteModel(); model.ChildModels.Add(new ModelNode { Value = def }); validationService.DeployModel(null, model); action(new ValidationPair <TModel> { Model = def, ValidationResult = validationService.Result }); }
public void Validate_WhenAccessRuleIsCofoundryUserArea_ReturnsError() { var command = new UpdatePageAccessRuleSetCommand(); command.PageId = 1; command.AccessRules .AddNew("TST") .AddNew(CofoundryAdminUserArea.Code); var validationService = new ModelValidationService(); var errors = validationService.GetErrors(command); using (new AssertionScope()) { errors.Should().HaveCount(1); var error = errors.Single(); error.Properties.Should().HaveCount(1); error.Properties.First().Should().Be("UserAreaCode"); error.Message.Should().Match("*added*admin user area*"); } }
public ModelValidationServiceTests() { modelValidationService = new ModelValidationService(fakeLogger); }
public QueryCategoryController() { _queryTypeService = new QueryTypeService(); _modelValidationService = new ModelValidationService(); _modelConversionService = new ModelConversionService(); }
public PaperCategoryController() { _paperTypeService = new PaperTypeService(); _modelValidationService = new ModelValidationService(); _modelConversionService = new ModelConversionService(); }
public PaperController() { _paperService = new PaperService(); _modelValidationService = new ModelValidationService(); _modelConversionService = new ModelConversionService(); }