public void ModuleYamlParserDoesNotThrow(string path) { var parser = ModuleYamlParserFactory.Get(); var text = pathToContentMap[path]; Assert.DoesNotThrow(() => parser.Parse(text)); }
public void EnsureEquivalentBuildSections(string path) { var text = pathToContentMap[path]; var parser = ModuleYamlParserFactory.Get(); var buildYamlParser = new BuildYamlParser("fake", text); var md = parser.Parse(text); var configs = md.AllConfigurations.Keys.ToArray(); foreach (var config in configs) { var newBuild = md[config].Builds; var oldBuild = buildYamlParser.Get(config); var oldBuildIsActuallyEmpty = oldBuild.Count == 1 && oldBuild[0].Configuration == null && oldBuild[0].Name == string.Empty && oldBuild[0].Target == string.Empty && oldBuild[0].Parameters.Count == 0; if (newBuild != null && !oldBuildIsActuallyEmpty) { newBuild.Should().BeEquivalentTo(oldBuild); } } }
public void EnsureEquivalentSettings(string path) { var text = pathToContentMap[path]; var parser = ModuleYamlParserFactory.Get(); var settingsYamlParser = new SettingsYamlParser("fake", text); var md = parser.Parse(text); var newSettings = md.Defaults.SettingsSection; var oldSettings = settingsYamlParser.Get(); newSettings.Should().BeEquivalentTo(oldSettings); }
public void EnsureEquivalentHooks(string path) { var text = pathToContentMap[path]; var parser = ModuleYamlParserFactory.Get(); var hooksYamlParser = new HooksYamlParser("fake", text); var md = parser.Parse(text); var newHooks = md.Defaults?.HooksSection; var oldHooks = hooksYamlParser.Get(); newHooks.Should().BeEquivalentTo(oldHooks); }
public void TestgetDepsRemoveDepRaisesExceptionNoSuchModuleToDelete2() { var text = @" default: deps: - A client: deps: - -C - C - A"; Assert.Throws <BadYamlException>(() => ModuleYamlParserFactory.Get().Parse(text)); }
public void EnsureEquivalentDeps(string path) { var text = pathToContentMap[path]; var parser = ModuleYamlParserFactory.Get(); var depsSectionParser = new DepsYamlParser("fake", text); var md = parser.Parse(text); var configs = md.AllConfigurations.Keys.ToArray(); foreach (var config in configs) { var newDeps = md[config].Deps; var oldDeps = depsSectionParser.Get(config); newDeps.Should().BeEquivalentTo(oldDeps); } }
public void EnsureEquivalentConfigurations(string path) { var text = pathToContentMap[path]; var parser = ModuleYamlParserFactory.Get(); var depsSectionParser = new DepsYamlParser("fake", text); var md = parser.Parse(text); var oldConfigSet = depsSectionParser.GetConfigurations(); var newConfigSet = md.AllConfigurations.Keys.ToArray(); newConfigSet.Should().BeEquivalentTo(oldConfigSet); var oldDefaultConfig = depsSectionParser.GetDefaultConfigurationName(); var newDefaultConfig = md.FindDefaultConfiguration()?.Name ?? "full-build"; newDefaultConfig.Should().BeEquivalentTo(oldDefaultConfig); }
public void EnsureEquivalentInstallSections(string path) { var text = pathToContentMap[path]; var parser = ModuleYamlParserFactory.Get(); var installYamlParser = new InstallYamlParser("fake", text); var md = parser.Parse(text); var configs = md.AllConfigurations.Keys.ToArray(); foreach (var config in configs) { var newInstall = md[config].Installs; var oldInstall = installYamlParser.Get(config); // todo - disputable - is it equivalent enough is the lists are the same only after Distinct()? oldInstall.ExternalModules = oldInstall.ExternalModules?.Distinct().ToList(); oldInstall.NuGetPackages = oldInstall.NuGetPackages?.Distinct().ToList(); newInstall.Should().BeEquivalentTo(oldInstall); } }
private DepsData GetDepsContent(string text, string config = null, bool strictOrdering = true) { var a = YamlFromText.DepsParser(text).Get(config); var md = ModuleYamlParserFactory.Get().Parse(text); var configName = string.IsNullOrEmpty(config) ? md.GetDefaultConfiguration().Name : config; var b = md.AllConfigurations[configName].Deps; if (strictOrdering) { a.Should().BeEquivalentTo(b, o => o.WithStrictOrdering()); } else { a.Should().BeEquivalentTo(b); } return(a); }
public ModuleDefinition NewModuleYamlParser() { var parser = ModuleYamlParserFactory.Get(); return(parser.Parse(Content)); }