|
| 1 | +using ScmBackup.Configuration; |
| 2 | +using ScmBackup.Hosters; |
| 3 | +using ScmBackup.Tests.Hosters; |
| 4 | +using System; |
| 5 | +using System.Collections.Generic; |
| 6 | +using System.Linq; |
| 7 | +using System.Text; |
| 8 | +using Xunit; |
| 9 | + |
| 10 | +namespace ScmBackup.Tests |
| 11 | +{ |
| 12 | + public class IncludingHosterApiCallerTests |
| 13 | + { |
| 14 | + ConfigSource source; |
| 15 | + IncludingHosterApiCaller sut; |
| 16 | + |
| 17 | + public IncludingHosterApiCallerTests() |
| 18 | + { |
| 19 | + this.source = new ConfigSource { Title = "foo" }; |
| 20 | + |
| 21 | + var repos = new List<HosterRepository>(); |
| 22 | + repos.Add(new HosterRepository("foo.bar", "bar", "http://clone", ScmType.Git)); |
| 23 | + repos.Add(new HosterRepository("foo.baz", "baz", "http://clone", ScmType.Git)); |
| 24 | + |
| 25 | + var caller = new FakeHosterApiCaller(); |
| 26 | + caller.Lists.Add(this.source, repos); |
| 27 | + |
| 28 | + this.sut = new IncludingHosterApiCaller(caller); |
| 29 | + } |
| 30 | + |
| 31 | + [Fact] |
| 32 | + public void IncludesRepo() |
| 33 | + { |
| 34 | + this.source.IncludeRepos = new List<string> { "bar" }; |
| 35 | + |
| 36 | + var list = this.sut.GetRepositoryList(this.source); |
| 37 | + |
| 38 | + Assert.Single(list); |
| 39 | + Assert.Equal("bar", list.First().ShortName); |
| 40 | + } |
| 41 | + |
| 42 | + [Fact] |
| 43 | + public void BackupsEverythingWhenNotSet() |
| 44 | + { |
| 45 | + // don't set this.source.IncludeRepos |
| 46 | + |
| 47 | + var list = this.sut.GetRepositoryList(this.source); |
| 48 | + |
| 49 | + Assert.Equal(2, list.Count); |
| 50 | + } |
| 51 | + } |
| 52 | +} |
0 commit comments