public async Task DoesNotDeleteOnDryRun()
        {
            Settings.Nondestructive = true;

            var tags    = _fixture.CreateMany <Tag>(10);
            var project = _fixture.Create <Project>();
            var repo    = _fixture.Create <Repository>();

            Rules.Setup(r => r.Load()).Returns(new RuleSet
            {
                DefaultRule = new Rule
                {
                    Project = new Regex(".*"),
                    Repo    = new Regex(".*"),
                    Tag     = new Regex(".*"),
                    Keep    = 3
                }
            }.EnsureDefaults());

            Harbor.Setup(h => h.GetAllProjects()).ReturnsAsync(new[] { project });
            Harbor.Setup(h => h.GetRepositories(It.IsAny <int>())).ReturnsAsync(new[] { repo });
            Harbor.Setup(h => h.GetTags(It.IsAny <string>())).ReturnsAsync(tags);

            await _sut.Process();

            Harbor.Verify(h => h.DeleteTag(It.IsAny <string>(), It.IsAny <string>()), Times.Never);
        }
Beispiel #2
0
 public bool Create(Harbor harbor)
 {
     if (FindByCode(harbor.Code) != null)
     {
         return(false);
     }
     harbor.IdHarbor = GenerateId();
     return(pm.Persist <Harbor>(harbor));
 }
Beispiel #3
0
        public async Task KeepsSpecifiedNumberOfTagsViaDefault()
        {
            var tags = _fixture.CreateMany <Tag>(_ruleSet.DefaultRule.Keep + 5);

            Harbor.Setup(h => h.GetTags(It.IsAny <string>())).ReturnsAsync(tags);

            await _sut.Process();

            Harbor.Verify(h => h.DeleteTag(It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(5));
        }
Beispiel #4
0
        public RuleTests()
        {
            Settings.Nondestructive = false;

            _project    = _fixture.Create <Project>();
            _repository = _fixture.Create <Repository>();

            Harbor.Setup(h => h.GetAllProjects()).ReturnsAsync(() => new[] { _project });
            Harbor.Setup(h => h.GetRepositories(It.IsAny <int>())).ReturnsAsync(() => new[] { _repository });
        }
 /// <summary>
 /// Used to set up merchants
 /// </summary>
 /// <param name="myHarbor"></param>
 public void Setup(Harbor myHarbor)
 {
     this.activeShipInventory = HexGridController.player.PlayerData.Resources;
     this.myHarbor            = myHarbor;
     foreach (InteractableResourceView viewer in resourceViewers)
     {
         UpdateUI(viewer.ResourceType, true);
     }
     SetTexts();
 }
Beispiel #6
0
        public async Task RuleExcludesTag(Tag t)
        {
            _fixture.Inject(new Regex(".*"));
            _ruleSet.Rules.Add(_fixture.Build <Rule>().WithAutoProperties().With(r => r.Ignore, new[] { t.Name }).Create());

            Harbor.Setup(h => h.GetTags(It.IsAny <string>())).ReturnsAsync(new[] { t });

            await _sut.Process();

            Serilog.Verify(l => l.Information("Tag {repo}:{name} skipped because it was found in an ignore list that applies to {repo}", t.Repository, t.Name, _repository.Name), Times.Once);
            Harbor.Verify(h => h.DeleteTag(It.IsAny <string>(), It.IsAny <string>()), Times.Never);
        }
Beispiel #7
0
        public async Task UnmatchedTagsAreKeptImplicitly()
        {
            _ruleSet.DefaultRule.Tag = new Regex("^$");

            var tags = _fixture.CreateMany <Tag>(10);

            Harbor.Setup(h => h.GetTags(It.IsAny <string>())).ReturnsAsync(tags);

            await _sut.Process();

            Harbor.Verify(h => h.DeleteTag(It.IsAny <string>(), It.IsAny <string>()), Times.Never);
            Serilog.Verify(l => l.Warning("The default rule did not match all remaining tags for {@repo}. {count} remaining tags will be kept", _repository, 10), Times.Once);
        }
Beispiel #8
0
        public async Task KeepsTagIgnoredByDefaultRule()
        {
            _ruleSet.DefaultRule.Ignore = new[] { "latest" };

            var tags = _fixture.CreateMany <Tag>(10).Append(_fixture.Build <Tag>().WithAutoProperties().With(t => t.Name, "latest").Create());

            Harbor.Setup(h => h.GetTags(It.IsAny <string>())).ReturnsAsync(tags);

            await _sut.Process();

            Harbor.Verify(h => h.DeleteTag(It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(5));
            Harbor.Verify(h => h.DeleteTag(It.IsAny <string>(), "latest"), Times.Never);
        }
Beispiel #9
0
 public void TestMethod1()
 {
     Harbor leratHarbor = new Harbor("Lerat", @"./Resources/HarborMap.jpg");
     Assert.IsTrue(leratHarbor.Map.Exists);
     Assert.IsFalse(string.IsNullOrEmpty(leratHarbor.Name));
 }