Esempio n. 1
0
        public void CustomHosts_Matching5()
        {
            var engine = new MockEngine();

            var task = new MockGetSourceLinkUrlGitTask()
            {
                BuildEngine = engine,
                SourceRoot  = new MockItem("/src/", KVP("RepositoryUrl", "http://subdomain.contoso.com:100/a/b"), KVP("SourceControl", "git"), KVP("RevisionId", "0123456789abcdefABCDEF000000000000000000")),
                Hosts       = new[]
                {
                    new MockItem("contoso.com", KVP("ContentUrl", "https://domain.com:1")),
                    new MockItem("contoso.com:123", KVP("ContentUrl", "https://domain.com:2")),
                    new MockItem("contoso.com:123", KVP("ContentUrl", "https://domain.com:3")),
                    new MockItem("z.contoso.com", KVP("ContentUrl", "https://domain.com:4")),
                    new MockItem("z.contoso.com:123", KVP("ContentUrl", "https://domain.com:5")),
                    new MockItem("z.contoso.com:123", KVP("ContentUrl", "https://domain.com:6")),
                }
            };

            bool result = task.Execute();

            AssertEx.AssertEqualToleratingWhitespaceDifferences("", engine.Log);
            AssertEx.AreEqual("ContentUrl='https://domain.com:1/' GitUrl='http://subdomain.contoso.com:100/a/b' RelativeUrl='/a/b' RevisionId='0123456789abcdefABCDEF000000000000000000'", task.SourceLinkUrl);
            Assert.True(result);
        }
Esempio n. 2
0
        public void TrimmingGitOnlyWhenSuffix()
        {
            var engine = new MockEngine();

            var task = new MockGetSourceLinkUrlGitTask()
            {
                BuildEngine = engine,
                SourceRoot  = new MockItem("/src/", KVP("RepositoryUrl", "http://contoso.com/a/.git"), KVP("SourceControl", "git"), KVP("RevisionId", "0000000000000000000000000000000000000000")),
                Hosts       = new[] { new MockItem("contoso.com") }
            };

            bool result = task.Execute();

            AssertEx.AssertEqualToleratingWhitespaceDifferences("", engine.Log);
            AssertEx.AreEqual("ContentUrl='http://contoso.com/host-default' GitUrl='http://contoso.com/a/.git' RelativeUrl='/a/.git' RevisionId='0000000000000000000000000000000000000000'", task.SourceLinkUrl);
            Assert.True(result);
        }
Esempio n. 3
0
        public void SourceRootNotApplicable_SourceLinkUrlSet()
        {
            var engine = new MockEngine();

            var task = new MockGetSourceLinkUrlGitTask()
            {
                BuildEngine = engine,
                SourceRoot  = new MockItem("/src/", KVP("RepositoryUrl", "http://contoso.com/a/b"), KVP("SourceControl", "git"), KVP("SourceLinkUrl", "x"), KVP("RevisionId", "12345")),
                Hosts       = new[] { new MockItem("github.com", KVP("ContentUrl", "https://contoso.com")) }
            };

            bool result = task.Execute();

            AssertEx.AssertEqualToleratingWhitespaceDifferences("", engine.Log);
            Assert.Equal("N/A", task.SourceLinkUrl);
            Assert.True(result);
        }
Esempio n. 4
0
        public void RepositoryUrl_Errors(string url)
        {
            var engine = new MockEngine();

            var task = new MockGetSourceLinkUrlGitTask()
            {
                BuildEngine = engine,
                SourceRoot  = new MockItem("/src/", KVP("RepositoryUrl", url), KVP("SourceControl", "git")),
            };

            bool result = task.Execute();

            AssertEx.AssertEqualToleratingWhitespaceDifferences(
                "ERROR : " + string.Format(CommonResources.ValueOfWithIdentityIsInvalid, "SourceRoot.RepositoryUrl", "/src/", url), engine.Log);

            Assert.False(result);
        }
Esempio n. 5
0
        public void HostsContentUrl_Errors(string url)
        {
            var engine = new MockEngine();

            var task = new MockGetSourceLinkUrlGitTask()
            {
                BuildEngine = engine,
                SourceRoot  = new MockItem("x", KVP("RepositoryUrl", "http://abc.com"), KVP("SourceControl", "git")),
                Hosts       = new[] { new MockItem("abc.com", KVP("ContentUrl", url)) }
            };

            bool result = task.Execute();

            AssertEx.AssertEqualToleratingWhitespaceDifferences(
                "ERROR : " + string.Format(CommonResources.ValuePassedToTaskParameterNotValidHostUri, "Hosts", url), engine.Log);

            Assert.False(result);
        }
Esempio n. 6
0
        public void ImplicitHost_PortWithDefaultContentUrl()
        {
            var engine = new MockEngine();

            var task = new MockGetSourceLinkUrlGitTask()
            {
                BuildEngine      = engine,
                SourceRoot       = new MockItem("/src/", KVP("RepositoryUrl", "http://subdomain.contoso.com:1234/a/b"), KVP("SourceControl", "git"), KVP("RevisionId", "0123456789abcdefABCDEF000000000000000000")),
                RepositoryUrl    = "http://contoso.com",
                IsSingleProvider = true,
            };

            bool result = task.Execute();

            AssertEx.AssertEqualToleratingWhitespaceDifferences("", engine.Log);
            AssertEx.AreEqual("ContentUrl='http://contoso.com:1234/repo-default' GitUrl='http://subdomain.contoso.com:1234/a/b' RelativeUrl='/a/b' RevisionId='0123456789abcdefABCDEF000000000000000000'", task.SourceLinkUrl);
            Assert.True(result);
        }
Esempio n. 7
0
        public void SourceRootNotApplicable_SourceLinkUrlEmpty()
        {
            var engine = new MockEngine();

            var task = new MockGetSourceLinkUrlGitTask()
            {
                BuildEngine = engine,
                SourceRoot  = new MockItem("x", KVP("RepositoryUrl", ""), KVP("SourceControl", "git")),
            };

            bool result = task.Execute();

            AssertEx.AssertEqualToleratingWhitespaceDifferences(
                "WARNING : " + string.Format(CommonResources.UnableToDetermineRepositoryUrl), engine.Log);

            Assert.Equal("N/A", task.SourceLinkUrl);
            Assert.True(result);
        }
Esempio n. 8
0
        public void RevisionId_Errors(string revisionId)
        {
            var engine = new MockEngine();

            var task = new MockGetSourceLinkUrlGitTask()
            {
                BuildEngine = engine,
                SourceRoot  = new MockItem("/src/", KVP("RepositoryUrl", "http://contoso.com/a/b"), KVP("SourceControl", "git"), KVP("RevisionId", revisionId)),
                Hosts       = new[] { new MockItem("contoso.com", KVP("ContentUrl", "https://contoso.com")) }
            };

            bool result = task.Execute();

            AssertEx.AssertEqualToleratingWhitespaceDifferences(
                "ERROR : " + string.Format(CommonResources.ValueOfWithIdentityIsNotValidCommitHash, "SourceRoot.RevisionId", "/src/", revisionId), engine.Log);

            Assert.False(result);
        }
Esempio n. 9
0
        public void ImplicitHost_Local(string repositoryUrl)
        {
            var engine = new MockEngine();

            var task = new MockGetSourceLinkUrlGitTask()
            {
                BuildEngine      = engine,
                SourceRoot       = new MockItem("x", KVP("RepositoryUrl", "http://abc.com"), KVP("SourceControl", "git")),
                RepositoryUrl    = repositoryUrl,
                IsSingleProvider = true,
            };

            bool result = task.Execute();

            AssertEx.AssertEqualToleratingWhitespaceDifferences(
                "ERROR : " + string.Format(CommonResources.ValuePassedToTaskParameterNotValidHostUri, "RepositoryUrl", repositoryUrl), engine.Log);

            Assert.False(result);
        }
Esempio n. 10
0
        public void CustomHosts_Matching6()
        {
            var engine = new MockEngine();

            var task = new MockGetSourceLinkUrlGitTask()
            {
                BuildEngine      = engine,
                SourceRoot       = new MockItem("/src/", KVP("RepositoryUrl", "http://subdomain.contoso.com/a/b"), KVP("SourceControl", "git"), KVP("RevisionId", "0123456789abcdefABCDEF000000000000000000")),
                RepositoryUrl    = "https://contoso.com/collection/project/_git/repo",
                IsSingleProvider = true,
                Hosts            = new[]
                {
                    new MockItem("contoso.com", KVP("ContentUrl", "https://zzz.com")),
                }
            };

            bool result = task.Execute();

            AssertEx.AssertEqualToleratingWhitespaceDifferences("", engine.Log);
            AssertEx.AreEqual("ContentUrl='https://zzz.com/' GitUrl='http://subdomain.contoso.com/a/b' RelativeUrl='/a/b' RevisionId='0123456789abcdefABCDEF000000000000000000'", task.SourceLinkUrl);
            Assert.True(result);
        }