Exemplo n.º 1
0
        public void ShouldParseYamlContent()
        {
            // Arrange
            var yamlContent =
                @"
languages:
- java
extensions:
    services:
    - Outlook
    - OneDrive
    - Teams
dependencyFile: demo/GraphTutorial/app/build.gradle
noDependencies: false";

            // Act
            var header = YamlHeader.FromString(yamlContent);

            // Assert
            Assert.NotNull(header);
            Assert.Equal("demo/GraphTutorial/app/build.gradle", header.DependencyFile);
            Assert.NotNull(header.Languages);
            Assert.Single(header.Languages);
            Assert.Contains("java", header.Languages);
            Assert.NotNull(header.Extensions);
            Assert.NotNull(header.Extensions.Services);
            Assert.Equal(3, header.Extensions.Services.Length);
            Assert.Contains("Outlook", header.Extensions.Services);
            Assert.False(header.NoDependencies);
            Assert.True(header.NoDependenciesWasSpecified);
        }
Exemplo n.º 2
0
        public void ShouldMergeButNotOverwrite()
        {
            // Arrange
            var mergeHeaderContent =
                @"
languages:
- csharp
extensions:
    services:
    - Outlook
    - OneDrive
    - Teams
noDependencies: true";

            var mergeIntoHeaderContent =
                @"
languages:
- java
dependencyFile: demo/GraphTutorial/app/build.gradle
noDependencies: false";

            // Act
            var mergeHeader     = YamlHeader.FromString(mergeHeaderContent);
            var mergeIntoHeader = YamlHeader.FromString(mergeIntoHeaderContent);

            mergeIntoHeader.MergeWith(mergeHeader);

            // Assert
            Assert.Single(mergeIntoHeader.Languages);
            Assert.Contains("java", mergeIntoHeader.Languages);
            Assert.DoesNotContain("csharp", mergeIntoHeader.Languages);
            Assert.NotNull(mergeIntoHeader.Extensions);
            Assert.NotNull(mergeIntoHeader.Extensions.Services);
            Assert.Equal(3, mergeIntoHeader.Extensions.Services.Length);
            Assert.Contains("Outlook", mergeIntoHeader.Extensions.Services);
            Assert.False(mergeIntoHeader.NoDependencies);
        }