예제 #1
0
        public void ModuleYamlParserDoesNotThrow(string path)
        {
            var parser = ModuleYamlParserFactory.Get();
            var text   = pathToContentMap[path];

            Assert.DoesNotThrow(() => parser.Parse(text));
        }
예제 #2
0
        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);
                }
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        public void TestgetDepsRemoveDepRaisesExceptionNoSuchModuleToDelete2()
        {
            var text = @"
default:
    deps:
        - A
client:
    deps:
        - -C
        - C
        - A";

            Assert.Throws <BadYamlException>(() => ModuleYamlParserFactory.Get().Parse(text));
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
            }
        }
예제 #9
0
        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);
        }
예제 #10
0
        public ModuleDefinition NewModuleYamlParser()
        {
            var parser = ModuleYamlParserFactory.Get();

            return(parser.Parse(Content));
        }