Exemplo n.º 1
0
        public async Task ExtractFileContainerArtifactFailsIfVstsDropJsonNotFoundTest()
        {
            // given
            var expectedContent = "somestuff";
            var entryName       = string.Format("{0}/RANDOMNAME", Guid.NewGuid());
            var buildClient     = new MockBuildClient()
            {
                ContentStream = GetZippedStream(expectedContent, entryName)
            };
            var gitClient      = new MockGitClient();
            var releaseClient  = new MockReleaseClient();
            var artifactHelper = new VstsArtifactsHelper(buildClient: buildClient, releaseClient: releaseClient, gitClient: gitClient, projectId: Guid.NewGuid(), repoName: "someRepo");

            // when
            var throws = false;

            try
            {
                await artifactHelper.ExtractFileContainerArtifact("someArtifact", 123, default(CancellationToken));
            }
            catch (VstsArtifactsNotFoundException ex)
            {
                if (ex.Message.Contains("not found "))
                {
                    throws = true;
                }
            }

            // then
            Assert.IsTrue(throws);
        }
Exemplo n.º 2
0
        public async Task ExtractFileContainerArtifactTest()
        {
            // given
            var expectedContent = "somestuff";
            var entryName       = string.Format("{0}/{1}", Guid.NewGuid(), VstsArtifactsHelper.VstsDropJsonFileName);
            var buildClient     = new MockBuildClient()
            {
                ContentStream = GetZippedStream(expectedContent, entryName)
            };
            var releaseClient  = new MockReleaseClient();
            var gitClient      = new MockGitClient();
            var artifactHelper = new VstsArtifactsHelper(buildClient: buildClient, releaseClient: releaseClient, gitClient: gitClient, projectId: Guid.NewGuid(), repoName: "someRepo");

            // when
            var contentString = await artifactHelper.ExtractFileContainerArtifact("someArtifact", 123, default(CancellationToken));

            // then
            Assert.AreEqual(expectedContent, contentString);
        }