示例#1
0
        public void TestGeneralFrameworkMonikerGoodWithInvalidIncludePath()
        {
            string tempDirectory        = Path.Combine(Path.GetTempPath(), "TestGeneralFrameworkMonikerGoodWithInvalidIncludePath");
            string framework41Directory = Path.Combine(tempDirectory, Path.Combine("MyFramework", "v4.1") + Path.DirectorySeparatorChar);
            string redistListDirectory  = Path.Combine(framework41Directory, "RedistList");
            string redistListFile       = Path.Combine(redistListDirectory, "FrameworkList.xml");

            try
            {
                Directory.CreateDirectory(framework41Directory);
                Directory.CreateDirectory(redistListDirectory);

                string redistListContents =
                    "<FileList Redist='Microsoft-Windows-CLRCoreComp' IncludeFramework='..\\Mooses' Name='Chained oh noes'>" +
                    "<File AssemblyName='System.Xml' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                    "<File AssemblyName='net.r_eg.IeXod.Engine' Version='2.0.0.0' PublicKeyToken='4bbd2ef743db151e' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                    "</FileList >";

                File.WriteAllText(redistListFile, redistListContents);

                string     targetFrameworkMoniker = "MyFramework, Version=v4.1";
                MockEngine engine = new MockEngine();
                GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths();
                getReferencePaths.BuildEngine            = engine;
                getReferencePaths.TargetFrameworkMoniker = targetFrameworkMoniker;
                getReferencePaths.RootPath = tempDirectory;
                getReferencePaths.Execute();
                string[] returnedPaths = getReferencePaths.ReferenceAssemblyPaths;
                Assert.Empty(returnedPaths);
                string displayName = getReferencePaths.TargetFrameworkMonikerDisplayName;
                Assert.Null(displayName);
                FrameworkNameVersioning frameworkMoniker = new FrameworkNameVersioning(getReferencePaths.TargetFrameworkMoniker);
                string message = ResourceUtilities.FormatResourceStringStripCodeAndKeyword("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkMoniker.ToString());
                engine.AssertLogContains(message);
            }
            finally
            {
                if (Directory.Exists(framework41Directory))
                {
                    FileUtilities.DeleteWithoutTrailingBackslash(framework41Directory, true);
                }
            }
        }
示例#2
0
        public void Warning()
        {
            MockEngine e = new MockEngine(true);
            Warning    w = new Warning();

            w.BuildEngine = e;

            w.Text = "warningtext";
            w.File = "c:\\file";

            bool retval = w.Execute();

            Console.WriteLine("===");
            Console.WriteLine(e.Log);
            Console.WriteLine("===");

            Assert.True(retval);
            e.AssertLogContains("c:\\file(0,0): WARNING : warningtext");
            Assert.Equal(1, e.Warnings);
        }
示例#3
0
        public void Error()
        {
            MockEngine e   = new MockEngine(true);
            Error      err = new Error();

            err.BuildEngine = e;

            err.Text = "errortext";
            err.File = "c:\\file";

            bool retval = err.Execute();

            Console.WriteLine("===");
            Console.WriteLine(e.Log);
            Console.WriteLine("===");

            Assert.False(retval);
            e.AssertLogContains("c:\\file(0,0): ERROR : errortext");
            Assert.Equal(1, e.Errors);
        }
示例#4
0
        public void GetResolvedRuleSetPath_FullPath_NonExistent()
        {
            MockEngine mockEngine           = new MockEngine();
            ResolveCodeAnalysisRuleSet task = new ResolveCodeAnalysisRuleSet();

            task.BuildEngine = mockEngine;

            string codeAnalysisRuleSet = @"C:\foo\bar\CodeAnalysis.ruleset";

            task.CodeAnalysisRuleSet            = codeAnalysisRuleSet;
            task.MSBuildProjectDirectory        = null;
            task.CodeAnalysisRuleSetDirectories = null;

            bool   result          = task.Execute();
            string resolvedRuleSet = task.ResolvedCodeAnalysisRuleSet;

            Assert.True(result);
            Assert.Null(resolvedRuleSet);
            mockEngine.AssertLogContains("MSB3884");
        }
示例#5
0
        public void GetResolvedRuleSetPath_RelativePath_NoProject()
        {
            MockEngine mockEngine           = new MockEngine();
            ResolveCodeAnalysisRuleSet task = new ResolveCodeAnalysisRuleSet();

            task.BuildEngine = mockEngine;

            string subdirectoryName = Path.GetRandomFileName();

            task.CodeAnalysisRuleSet            = Path.Combine(subdirectoryName, "CodeAnalysis.ruleset");
            task.MSBuildProjectDirectory        = null;
            task.CodeAnalysisRuleSetDirectories = null;

            bool   result          = task.Execute();
            string resolvedRuleSet = task.ResolvedCodeAnalysisRuleSet;

            Assert.True(result);
            Assert.Null(resolvedRuleSet);
            mockEngine.AssertLogContains("MSB3884");
        }
示例#6
0
        public void GetResolvedRuleSetPath_SimpleNameAndDirectories_NonExistent()
        {
            MockEngine mockEngine           = new MockEngine();
            ResolveCodeAnalysisRuleSet task = new ResolveCodeAnalysisRuleSet();

            task.BuildEngine = mockEngine;

            string directory = Path.GetTempPath();

            task.CodeAnalysisRuleSet            = Path.GetRandomFileName() + ".ruleset";
            task.MSBuildProjectDirectory        = null;
            task.CodeAnalysisRuleSetDirectories = new[] { directory };

            bool   result          = task.Execute();
            string resolvedRuleSet = task.ResolvedCodeAnalysisRuleSet;

            Assert.True(result);
            Assert.Null(resolvedRuleSet);
            mockEngine.AssertLogContains("MSB3884");
        }
示例#7
0
        public void TestGeneralFrameworkMonikerNonExistent()
        {
            MockEngine engine = new MockEngine();
            GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths();

            getReferencePaths.BuildEngine = engine;
            // Make a framework which does not exist, intentional misspelling of framework
            getReferencePaths.TargetFrameworkMoniker = ".NetFramewok, Version=v99.0";
            bool success = getReferencePaths.Execute();

            Assert.False(success);
            string[] returnedPaths = getReferencePaths.ReferenceAssemblyPaths;
            Assert.Empty(returnedPaths);
            string displayName = getReferencePaths.TargetFrameworkMonikerDisplayName;

            Assert.Null(displayName);
            FrameworkNameVersioning frameworkMoniker = new FrameworkNameVersioning(getReferencePaths.TargetFrameworkMoniker);
            string message = ResourceUtilities.FormatResourceStringStripCodeAndKeyword("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkMoniker.ToString());

            engine.AssertLogContains("ERROR MSB3644: " + message);
        }
示例#8
0
        public void ErrorFromResourcesWithInvalidArguments()
        {
            MockEngine         e   = new MockEngine(true);
            ErrorFromResources err = new ErrorFromResources();

            err.BuildEngine = e;

            err.Resource  = "Copy.Error";
            err.Arguments = new string[] { "a.txt", "b.txt" };

            bool retval = err.Execute();

            Console.WriteLine("===");
            Console.WriteLine(e.Log);
            Console.WriteLine("===");

            Assert.False(retval);

            e.AssertLogDoesntContain("a.txt");
            e.AssertLogContains("MSB3861");
            Assert.Equal(1, e.Errors);
        }
示例#9
0
        public void ErrorFromResources()
        {
            MockEngine         e   = new MockEngine(true);
            ErrorFromResources err = new ErrorFromResources();

            err.BuildEngine = e;

            err.Resource = "Exec.MissingCommandError";

            bool retval = err.Execute();

            Console.WriteLine("===");
            Console.WriteLine(e.Log);
            Console.WriteLine("===");

            Assert.False(retval);

            string message = AssemblyResources.GetString(err.Resource);

            e.AssertLogContains(message);
            Assert.Equal(1, e.Errors);
        }
示例#10
0
        public void ErrorFromResourcesWithArguments()
        {
            MockEngine         e   = new MockEngine(true);
            ErrorFromResources err = new ErrorFromResources();

            err.BuildEngine = e;

            err.Resource  = "Copy.Error";
            err.Arguments = new string[] { "a.txt", "b.txt", "xyz" };

            bool retval = err.Execute();

            Console.WriteLine("===");
            Console.WriteLine(e.Log);
            Console.WriteLine("===");

            Assert.False(retval);

            string message = String.Format(AssemblyResources.GetString(err.Resource), err.Arguments);

            e.AssertLogContains(message);
            Assert.Equal(1, e.Errors);
        }
示例#11
0
文件: Exec_Tests.cs 项目: 3F/IeXod
        public void BogusCustomRegexesCauseOneErrorEach()
        {
            Exec exec;

            if (NativeMethodsShared.IsWindows)
            {
                exec = PrepareExec("echo Some output & echo Some output & echo Some output & echo Some output ");
            }
            else
            {
                exec = PrepareExec("echo Some output ; echo Some output ; echo Some output ; echo Some output ");
            }

            exec.CustomErrorRegularExpression   = "~!@#$%^_)(*&^%$#@@#XF &%^%T$REd((((([[[[";
            exec.CustomWarningRegularExpression = "*";
            exec.Execute();

            MockEngine e = (MockEngine)exec.BuildEngine;

            Console.WriteLine(e.Log);
            Assert.Equal(3, e.Errors);
            e.AssertLogContains("MSB3076");
        }
        public void TestVerifyProjectReferenceItem()
        {
            ResolveNonMSBuildProjectOutput rvpo = new ResolveNonMSBuildProjectOutput();

            ITaskItem[] taskItems = new ITaskItem[1];
            // bad GUID - this reference is invalid
            taskItems[0] = new TaskItem("projectReference");
            taskItems[0].SetMetadata(attributeProject, "{invalid guid}");

            MockEngine engine = new MockEngine(_output);

            rvpo.BuildEngine = engine;
            Assert.True(rvpo.VerifyProjectReferenceItems(taskItems, false /* treat problems as warnings */));
            Assert.Equal(1, engine.Warnings);
            Assert.Equal(0, engine.Errors);
            engine.AssertLogContains("MSB3107");

            engine           = new MockEngine(_output);
            rvpo.BuildEngine = engine;
            Assert.False(rvpo.VerifyProjectReferenceItems(taskItems, true /* treat problems as errors */));
            Assert.Equal(0, engine.Warnings);
            Assert.Equal(1, engine.Errors);
            engine.AssertLogContains("MSB3107");
        }
示例#13
0
        public void ErrorFromResourcesWithOverriddenCode()
        {
            MockEngine         e   = new MockEngine(true);
            ErrorFromResources err = new ErrorFromResources();

            err.BuildEngine = e;

            err.Resource = "Exec.MissingCommandError";
            err.Code     = "ABC1234";

            bool retval = err.Execute();

            Console.WriteLine("===");
            Console.WriteLine(e.Log);
            Console.WriteLine("===");

            Assert.False(retval);

            string message        = AssemblyResources.GetString(err.Resource);
            string updatedMessage = message.Replace("MSB3072", "ABC1234");

            e.AssertLogContains(updatedMessage);
            Assert.Equal(1, e.Errors);
        }
示例#14
0
文件: ResGen_Tests.cs 项目: 3F/IeXod
        /// <summary>
        /// Given a log and a resource string, acquires the text of that resource string and
        /// compares it to the log.  Asserts if the log does not contain the desired string.
        /// </summary>
        /// <param name="e">The MockEngine that contains the log we're checking</param>
        /// <param name="log">The TaskLoggingHelper that we use to load the string resource</param>
        /// <param name="errorResource">The name of the resource string to check the log for</param>
        /// <param name="args">Arguments needed to format the resource string properly</param>
        private void VerifyLogContainsResource(MockEngine e, TaskLoggingHelper log, string messageResource, params object[] args)
        {
            string message = log.FormatResourceString(messageResource, args);

            e.AssertLogContains(message);
        }