public OutputDashboardArmTemplate Transform(InputDashboardArmTemplate inputTemplate, TransformationDetails transformationDetails) { var armTemplate = DashboardJsonTemplateTransformationService.TransformTemplate(inputTemplate, transformationDetails); var parametersJson = DashboardJsonParametersService.CreateParameters(armTemplate.AdditionalResourceNames, transformationDetails); var outputJson = JsonWriter.CreateOutputJsonWithFormatting(armTemplate.Json); return(new OutputDashboardArmTemplate(outputJson, parametersJson)); }
internal static ArmTemplate TransformTemplate(InputDashboardArmTemplate inputTemplate, TransformationDetails transformationDetails) { try { var inputJson = JObject.Parse(inputTemplate.TemplateJson); var armTemplate = new ArmTemplate(inputJson); ArmTemplateTransformer rootTransformer = CreateTransformer(transformationDetails); IArmPropertyValueResolver armPropertyValueResolver = CreatePropertyValueResolver(transformationDetails); rootTransformer.Transform(armTemplate, armPropertyValueResolver); return(armTemplate); } catch (Exception e) { throw new InvalidInputTemplateException(e); } }
public void Setup() { this.reportedError = null; this.userMessage = null; this.inputTemplate = new InputDashboardArmTemplate("SomeJson"); this.completeOutputTemplate = new OutputDashboardArmTemplate("SomeOutputJson", "SomeParametersJson"); this.partOfExistingTemplateOutput = new OutputDashboardArmTemplate("PartOutputJson", "SomeParametersJson"); this.fileService = A.Fake <ITransformationFileService>(); this.transformationService = A.Fake <ITransformationService>(); Messenger.Default.Register <Exception>(this, e => this.reportedError = e); Messenger.Default.Register <string>(this, e => this.userMessage = e); this.mainViewModel = new MainViewModel(this.fileService, this.transformationService); this.mainViewModel.SourceFilePath = @"C:\Input.json"; this.mainViewModel.OutputFolderPath = OutputPath; A.CallTo(() => this.transformationService.Transform(this.inputTemplate, A <TransformationDetails> .That.Matches(x => x.DashboardIsCompleteTemplate.Equals(true)))).Returns(this.completeOutputTemplate); A.CallTo(() => this.transformationService.Transform(this.inputTemplate, A <TransformationDetails> .That.Matches(x => x.DashboardIsCompleteTemplate.Equals(false)))).Returns(this.partOfExistingTemplateOutput); }
private void InvalidJson(string json) { this.inputDashboardArmTemplate = new InputDashboardArmTemplate(json); }
private void ValidJson(byte[] jsonFile) { var json = this.GetJsonFromResourceFile(jsonFile); this.inputDashboardArmTemplate = new InputDashboardArmTemplate(json); }