コード例 #1
0
ファイル: WhichUtilL0.cs プロジェクト: zafields/vsts-agent
        public void WhichReturnsNullWhenNotFound()
        {
            using (TestHostContext hc = new TestHostContext(this))
            {
                //Arrange
                Tracing trace     = hc.GetTrace();
                var     whichUtil = new WhichUtil();
                whichUtil.Initialize(hc);

                // Act.
                string nosuch = whichUtil.Which("no-such-file-cf7e351f");

                trace.Info($"result: {nosuch ?? string.Empty}");

                // Assert.
                Assert.True(string.IsNullOrEmpty(nosuch), "Path should not be resolved");
            }
        }
コード例 #2
0
ファイル: WhichUtilL0.cs プロジェクト: zafields/vsts-agent
        public void UseWhichFindGit()
        {
            using (TestHostContext hc = new TestHostContext(this))
            {
                //Arrange
                Tracing trace     = hc.GetTrace();
                var     whichTool = new WhichUtil();
                whichTool.Initialize(hc);

                // Act.
                string gitPath = whichTool.Which("git");

                trace.Info($"Which(\"git\") returns: {gitPath ?? string.Empty}");

                // Assert.
                Assert.True(!string.IsNullOrEmpty(gitPath) && File.Exists(gitPath), $"Unable to find Git through: {nameof(WhichUtil.Which)}");
            }
        }
コード例 #3
0
ファイル: WhichUtilL0.cs プロジェクト: zafields/vsts-agent
        public void WhichThrowsWhenRequireAndNotFound()
        {
            using (TestHostContext hc = new TestHostContext(this))
            {
                //Arrange
                Tracing trace     = hc.GetTrace();
                var     whichUtil = new WhichUtil();
                whichUtil.Initialize(hc);

                // Act.
                try
                {
                    whichUtil.Which("no-such-file-cf7e351f", require: true);
                    throw new Exception("which should have thrown");
                }
                catch (FileNotFoundException ex)
                {
                    Assert.Equal("no-such-file-cf7e351f", ex.FileName);
                }
            }
        }