public async Task Handler_RemoveTag_BuildTagRemoved()
        {
            build.AddTag("new_Tag");
            build.AddTag("new_Tag_2");
            await eventStore.AppendToStream <Build>(build.Id, build.GetUncommitedChanges());

            var command = new UpdateBuildTags()
            {
                BuildId = build.Id,
                Tags    = Array.Empty <string>()
            };

            await updateBuildTagsHandler.Handle(command, CancellationToken.None);

            var editedBuild = await RestoreBuild();

            Assert.Equal(command.Tags, editedBuild.Tags);
            Assert.Equal(ArtifactState.Updated, editedBuild.ArtifactState);
        }
Beispiel #2
0
        private void UpdateTags(Build build, UpdateBuildTags command)
        {
            (IList <string> newTags, IList <string> tagsToDelete) =
                collectionsComparer
                .Compare(build.Tags, command.Tags);

            if (!newTags.Any() && !tagsToDelete.Any())
            {
                return;
            }

            foreach (string tag in tagsToDelete)
            {
                build.RemoveTag(tag);
            }

            foreach (string newTag in newTags)
            {
                build.AddTag(newTag);
            }

            build.UpdateArtifactState(ArtifactState.Updated);
        }