public void EmptyConfigReturnsNoSettings()
        {
            var path = MakeTestFile("{}");

            var fsr = new FileSettingsReader(Substitute.For <INuKeeperLogger>());

            var data = fsr.Read(path);

            Assert.That(data, Is.Not.Null);
            Assert.That(data.Age, Is.Null);
            Assert.That(data.Api, Is.Null);
            Assert.That(data.Include, Is.Null);
            Assert.That(data.Exclude, Is.Null);
            Assert.That(data.Label, Is.Null);
            Assert.That(data.MaxPackageUpdates, Is.Null);
            Assert.That(data.MaxRepo, Is.Null);
            Assert.That(data.Verbosity, Is.Null);
            Assert.That(data.Change, Is.Null);
            Assert.That(data.ForkMode, Is.Null);
            Assert.That(data.UsePrerelease, Is.Null);

            Assert.That(data.OutputDestination, Is.Null);
            Assert.That(data.OutputFormat, Is.Null);
            Assert.That(data.OutputFileName, Is.Null);
            Assert.That(data.LogDestination, Is.Null);
            Assert.That(data.Platform, Is.Null);
            Assert.That(data.BranchNamePrefix, Is.Null);
            Assert.That(data.DeleteBranchAfterMerge, Is.Null);
        }
Пример #2
0
        public void ConfigKeysAreCaseInsensitive()
        {
            const string configData = @"{
               ""Age"":""3d"",
               ""API"":""http://api.com"",
               ""iNClude"":""fred"",
               ""excludE"":""fish"",
               ""IncluDeRepoS"":""repo2"",
               ""label"": [""mark"" ],
               ""MAXrepo"":3,
               ""vErBoSiTy"": ""Q"",
               ""CHANGE"": ""PATCH""
}";

            var path = MakeTestFile(configData);

            var fsr = new FileSettingsReader(Substitute.For <INuKeeperLogger>());

            var data = fsr.Read(path);

            Assert.That(data, Is.Not.Null);
            Assert.That(data.Age, Is.EqualTo("3d"));
            Assert.That(data.Api, Is.EqualTo("http://api.com"));
            Assert.That(data.Include, Is.EqualTo("fred"));
            Assert.That(data.Exclude, Is.EqualTo("fish"));
            Assert.That(data.IncludeRepos, Is.EqualTo("repo2"));
            Assert.That(data.Label.Count, Is.EqualTo(1));
            Assert.That(data.Label, Does.Contain("mark"));
            Assert.That(data.MaxRepo, Is.EqualTo(3));
            Assert.That(data.Verbosity, Is.EqualTo(LogLevel.Quiet));
            Assert.That(data.Change, Is.EqualTo(VersionChange.Patch));
        }
Пример #3
0
        public void MissingFileReturnsNoSettings()
        {
            var folder = TemporaryFolder();

            var fsr = new FileSettingsReader(Substitute.For <INuKeeperLogger>());

            var data = fsr.Read(folder);

            Assert.That(data, Is.Not.Null);
            Assert.That(data.Age, Is.Null);
            Assert.That(data.Api, Is.Null);
            Assert.That(data.Include, Is.Null);
            Assert.That(data.Exclude, Is.Null);
            Assert.That(data.Label, Is.Null);
            Assert.That(data.MaxPr, Is.Null);
            Assert.That(data.MaxRepo, Is.Null);
            Assert.That(data.Verbosity, Is.Null);
            Assert.That(data.Change, Is.Null);
            Assert.That(data.ForkMode, Is.Null);
            Assert.That(data.UsePrerelease, Is.Null);

            Assert.That(data.OutputDestination, Is.Null);
            Assert.That(data.OutputFormat, Is.Null);
            Assert.That(data.OutputFileName, Is.Null);
            Assert.That(data.LogDestination, Is.Null);
        }
        public void MissingFileReturnsNoSettings()
        {
            var fsr = new FileSettingsReader(Substitute.For <INuKeeperLogger>());

            var data = fsr.Read(_uniqueTemporaryFolder);

            Assert.That(data, Is.Not.Null);
            Assert.That(data.Age, Is.Null);
            Assert.That(data.Api, Is.Null);
            Assert.That(data.Include, Is.Null);
            Assert.That(data.Exclude, Is.Null);
            Assert.That(data.Label, Is.Null);
            Assert.That(data.MaxPackageUpdates, Is.Null);
            Assert.That(data.MaxRepo, Is.Null);
            Assert.That(data.Verbosity, Is.Null);
            Assert.That(data.Change, Is.Null);
            Assert.That(data.ForkMode, Is.Null);
            Assert.That(data.UsePrerelease, Is.Null);

            Assert.That(data.OutputDestination, Is.Null);
            Assert.That(data.OutputFormat, Is.Null);
            Assert.That(data.OutputFileName, Is.Null);
            Assert.That(data.LogDestination, Is.Null);
            Assert.That(data.Platform, Is.Null);
            Assert.That(data.BranchNameTemplate, Is.Null);
            Assert.That(data.DeleteBranchAfterMerge, Is.Null);
        }
Пример #5
0
        public void ConfigKeysAreCaseInsensitive()
        {
            const string configData = @"{
               ""Age"":""3d"",
               ""API"":""http://api.com"",
               ""iNClude"":""fred"",
               ""excludE"":""fish"",
               ""IncluDeRepoS"":""repo2"",
               ""label"": [""mark"" ]
}";

            var path = MakeTestFile(configData);

            var fsr = new FileSettingsReader(Substitute.For <INuKeeperLogger>());

            var data = fsr.Read(path);

            Assert.That(data, Is.Not.Null);
            Assert.That(data.Age, Is.EqualTo("3d"));
            Assert.That(data.Api, Is.EqualTo("http://api.com"));
            Assert.That(data.Include, Is.EqualTo("fred"));
            Assert.That(data.Exclude, Is.EqualTo("fish"));
            Assert.That(data.IncludeRepos, Is.EqualTo("repo2"));
            Assert.That(data.Label.Length, Is.EqualTo(1));
            Assert.That(data.Label, Does.Contain("mark"));
        }
Пример #6
0
        public void PopulatedConfigReturnsAllSettings()
        {
            const string configData = @"{
               ""age"":""3d"",
               ""api"":""http://api.com"",
               ""include"":""fred"",
               ""exclude"":""fish"",
               ""includeRepos"":""repoIn"",
               ""excludeRepos"":""repoOut"",
               ""label"": [ ""foo"", ""bar"" ]
}";

            var path = MakeTestFile(configData);

            var fsr = new FileSettingsReader(Substitute.For <INuKeeperLogger>());

            var data = fsr.Read(path);

            Assert.That(data, Is.Not.Null);
            Assert.That(data.Age, Is.EqualTo("3d"));
            Assert.That(data.Api, Is.EqualTo("http://api.com"));
            Assert.That(data.Include, Is.EqualTo("fred"));
            Assert.That(data.Exclude, Is.EqualTo("fish"));
            Assert.That(data.IncludeRepos, Is.EqualTo("repoIn"));
            Assert.That(data.ExcludeRepos, Is.EqualTo("repoOut"));
            Assert.That(data.Label.Length, Is.EqualTo(2));
            Assert.That(data.Label, Does.Contain("foo"));
            Assert.That(data.Label, Does.Contain("bar"));
        }
Пример #7
0
        public void PopulatedConfigReturnsNumericSettings()
        {
            var path = MakeTestFile(FullFileData);

            var fsr = new FileSettingsReader(Substitute.For <INuKeeperLogger>());

            var data = fsr.Read(path);

            Assert.That(data.MaxPr, Is.EqualTo(42));
            Assert.That(data.MaxRepo, Is.EqualTo(12));
        }
Пример #8
0
        public void PopulatedConfigReturnsEnumSettings()
        {
            var path = MakeTestFile(FullFileData);

            var fsr = new FileSettingsReader(Substitute.For <INuKeeperLogger>());

            var data = fsr.Read(path);

            Assert.That(data.Verbosity, Is.EqualTo(LogLevel.Detailed));
            Assert.That(data.Change, Is.EqualTo(VersionChange.Minor));
        }
Пример #9
0
        public void PopulatedConfigReturnsLabels()
        {
            var path = MakeTestFile(FullFileData);

            var fsr = new FileSettingsReader(Substitute.For <INuKeeperLogger>());

            var data = fsr.Read(path);

            Assert.That(data.Label.Count, Is.EqualTo(2));
            Assert.That(data.Label, Does.Contain("foo"));
            Assert.That(data.Label, Does.Contain("bar"));
        }
Пример #10
0
        public void EmptyConfigReturnsNoSettings()
        {
            var path = MakeTestFile("{}");

            var fsr = new FileSettingsReader(Substitute.For <INuKeeperLogger>());

            var data = fsr.Read(path);

            Assert.That(data, Is.Not.Null);
            Assert.That(data.Age, Is.Null);
            Assert.That(data.Api, Is.Null);
            Assert.That(data.Include, Is.Null);
            Assert.That(data.Exclude, Is.Null);
            Assert.That(data.Label, Is.Null);
        }
Пример #11
0
        public void MissingFileReturnsNoSettings()
        {
            var folder = TemporaryFolder();

            var fsr = new FileSettingsReader(Substitute.For <INuKeeperLogger>());

            var data = fsr.Read(folder.FullPath);

            Assert.That(data, Is.Not.Null);
            Assert.That(data.Age, Is.Null);
            Assert.That(data.Api, Is.Null);
            Assert.That(data.Include, Is.Null);
            Assert.That(data.Exclude, Is.Null);
            Assert.That(data.Label, Is.Null);
        }
Пример #12
0
        public void PopulatedConfigReturnsAllStringSettings()
        {
            var path = MakeTestFile(FullFileData);

            var fsr = new FileSettingsReader(Substitute.For <INuKeeperLogger>());

            var data = fsr.Read(path);

            Assert.That(data, Is.Not.Null);
            Assert.That(data.Age, Is.EqualTo("3d"));
            Assert.That(data.Api, Is.EqualTo("http://api.com"));
            Assert.That(data.Include, Is.EqualTo("fred"));
            Assert.That(data.Exclude, Is.EqualTo("fish"));
            Assert.That(data.IncludeRepos, Is.EqualTo("repoIn"));
            Assert.That(data.ExcludeRepos, Is.EqualTo("repoOut"));
            Assert.That(data.LogFile, Is.EqualTo("somefile.log"));
        }
Пример #13
0
        public void PopulatedConfigReturnsEnumSettings()
        {
            var path = MakeTestFile(FullFileData);

            var fsr = new FileSettingsReader(Substitute.For <INuKeeperLogger>());

            var data = fsr.Read(path);

            Assert.That(data.Change, Is.EqualTo(VersionChange.Minor));
            Assert.That(data.ForkMode, Is.EqualTo(ForkMode.PreferFork));
            Assert.That(data.UsePrerelease, Is.EqualTo(UsePrerelease.Never));

            Assert.That(data.Verbosity, Is.EqualTo(LogLevel.Detailed));
            Assert.That(data.LogDestination, Is.EqualTo(LogDestination.File));

            Assert.That(data.OutputDestination, Is.EqualTo(OutputDestination.Console));
            Assert.That(data.OutputFormat, Is.EqualTo(OutputFormat.Text));
        }
Пример #14
0
        public void ExtraKeysAreIgnored()
        {
            const string configData = @"{
               ""age"":""3d"",
               ""api"":""http://api.com"",
               ""something"":""nothing""
}";

            var path = MakeTestFile(configData);

            var fsr = new FileSettingsReader(Substitute.For <INuKeeperLogger>());

            var data = fsr.Read(path);

            Assert.That(data, Is.Not.Null);
            Assert.That(data.Age, Is.EqualTo("3d"));
            Assert.That(data.Api, Is.EqualTo("http://api.com"));
        }
        public void PopulatedConfigReturnsAllStringSettings()
        {
            var path = MakeTestFile(FullFileData);

            var fsr = new FileSettingsReader(Substitute.For <INuKeeperLogger>());

            var data = fsr.Read(path);

            Assert.That(data, Is.Not.Null);
            Assert.That(data.Age, Is.EqualTo("3d"));
            Assert.That(data.Api, Is.EqualTo("http://api.com"));
            Assert.That(data.Include, Is.EqualTo("fred"));
            Assert.That(data.Exclude, Is.EqualTo("fish"));
            Assert.That(data.IncludeRepos, Is.EqualTo("repoIn"));
            Assert.That(data.ExcludeRepos, Is.EqualTo("repoOut"));
            Assert.That(data.LogFile, Is.EqualTo("somefile.log"));
            Assert.That(data.OutputFileName, Is.EqualTo("out_42.txt"));
            Assert.That(data.BranchNameTemplate, Is.EqualTo("nukeeper/MyBranch"));
            Assert.That(data.DeleteBranchAfterMerge, Is.EqualTo(true));
        }
Пример #16
0
        public void ConfigKeysAreCaseInsensitive()
        {
            const string configData = @"{
               ""Age"":""3d"",
               ""API"":""http://api.com"",
               ""iNClude"":""fred"",
               ""excludE"":""fish"",
               ""IncluDeRepoS"":""repo2"",
               ""label"": [""mark"" ],
               ""MaxPackageUpdates"":4,
               ""MaxOpenPUllrequests"":10,
               ""MAXrepo"":3,
               ""vErBoSiTy"": ""Q"",
               ""CHANGE"": ""PATCH"",
               ""bRanCHNamETempLATe"": ""nukeeper/MyBranch"",
               ""deLeTEBranCHafTERMerge"": ""true""
            }";

            var path = MakeTestFile(configData);

            var fsr = new FileSettingsReader(Substitute.For <INuKeeperLogger>());

            var data = fsr.Read(path);

            Assert.That(data, Is.Not.Null);
            Assert.That(data.Age, Is.EqualTo("3d"));
            Assert.That(data.Api, Is.EqualTo("http://api.com"));
            Assert.That(data.Include, Is.EqualTo("fred"));
            Assert.That(data.Exclude, Is.EqualTo("fish"));
            Assert.That(data.IncludeRepos, Is.EqualTo("repo2"));
            Assert.That(data.Label.Count, Is.EqualTo(1));
            Assert.That(data.Label, Does.Contain("mark"));
            Assert.That(data.MaxPackageUpdates, Is.EqualTo(4));
            Assert.That(data.MaxOpenPullRequests, Is.EqualTo(10));
            Assert.That(data.MaxRepo, Is.EqualTo(3));
            Assert.That(data.Verbosity, Is.EqualTo(LogLevel.Quiet));
            Assert.That(data.Change, Is.EqualTo(VersionChange.Patch));
            Assert.That(data.BranchNameTemplate, Is.EqualTo("nukeeper/MyBranch"));
            Assert.That(data.DeleteBranchAfterMerge, Is.EqualTo(true));
        }
Пример #17
0
        public void EmptyConfigReturnsNoSettings()
        {
            var path = MakeTestFile("{}");

            var fsr = new FileSettingsReader(Substitute.For <INuKeeperLogger>());

            var data = fsr.Read(path);

            Assert.That(data, Is.Not.Null);
            Assert.That(data.Age, Is.Null);
            Assert.That(data.Api, Is.Null);
            Assert.That(data.Include, Is.Null);
            Assert.That(data.Exclude, Is.Null);
            Assert.That(data.Label, Is.Null);
            Assert.That(data.MaxPr, Is.Null);
            Assert.That(data.MaxRepo, Is.Null);
            Assert.That(data.Verbosity, Is.Null);
            Assert.That(data.Change, Is.Null);
            Assert.That(data.OutputDestination, Is.Null);
            Assert.That(data.OutputFormat, Is.Null);
            Assert.That(data.OutputFileName, Is.Null);
        }