Example #1
0
        public void UnderlinedIfIgnored()
        {
            Microsoft.Build.Evaluation.Project msbuildProj = Utilities.SetupMSBuildProject();

            // Set up a project so the project column can be populated.
            MockSolution   solution = _serviceProvider.GetService(typeof(SVsSolution)) as MockSolution;
            MockIVsProject project  = new MockIVsProject(msbuildProj.FullPath);

            solution.AddProject(project);

            CodeSweep.VSPackage.TaskProvider_Accessor providerAccessor = new CodeSweep.VSPackage.TaskProvider_Accessor(_serviceProvider);

            string projectDrive = Path.GetPathRoot(msbuildProj.FullPath);

            CodeSweep.VSPackage.Task_Accessor accessor = new CodeSweep.VSPackage.Task_Accessor("term", 1, "class", "comment", "replacement", projectDrive + "\\dir\\file.ext", 2, 3, msbuildProj.FullPath, "full line text", providerAccessor, null);

            accessor.Ignored = true;

            uint   type;
            uint   flags;
            object val;
            string accName;

            foreach (object fieldObj in Enum.GetValues(typeof(TaskFields)))
            {
                accessor.GetColumnValue((int)fieldObj, out type, out flags, out val, out accName);
                Assert.IsTrue((flags & (int)__VSTASKVALUEFLAGS.TVF_STRIKETHROUGH) != 0, "Strikethrough flag not set for ignored task field " + (int)fieldObj);
            }
        }
Example #2
0
        public void GetColumnValueTest()
        {
            Microsoft.Build.Evaluation.Project msbuildProj = Utilities.SetupMSBuildProject();

            // Set up a project so the project column can be populated.
            MockSolution   solution = _serviceProvider.GetService(typeof(SVsSolution)) as MockSolution;
            MockIVsProject project  = new MockIVsProject(msbuildProj.FullPath);

            solution.AddProject(project);

            CodeSweep.VSPackage.TaskProvider_Accessor providerAccessor = new CodeSweep.VSPackage.TaskProvider_Accessor(_serviceProvider);

            CodeSweep.VSPackage.Task_Accessor accessor = new CodeSweep.VSPackage.Task_Accessor("term", 1, "class", "comment with link:  http://www.microsoft.com", "replacement", "z:\\dir\\file.ext", 2, 3, msbuildProj.FullPath, "full line text", providerAccessor, null);

            uint   type;
            uint   flags;
            object val;
            string accName;

            int hr = accessor.GetColumnValue((int)TaskFields.Priority, out type, out flags, out val, out accName);

            Assert.AreEqual(VSConstants.S_OK, hr, "GetColumnValue did not return S_OK for the Priority column.");
            Assert.AreEqual(__VSTASKVALUETYPE.TVT_IMAGE, (__VSTASKVALUETYPE)type, "Type of Priority column is incorrect.");
            Assert.AreEqual(__VSTASKVALUEFLAGS.TVF_HORZ_CENTER, (__VSTASKVALUEFLAGS)flags, "Flags for Priority column are incorrect.");
            Assert.AreEqual(typeof(int), val.GetType(), "Value of Priority column has wrong type.");
            Assert.IsTrue((int)val >= 0 && (int)val <= 2, "Image index for Priority column is out of range.");
            string[] imageAccText = new string[] { "High", "Medium", "Low" };
            Assert.AreEqual(imageAccText[(int)val], accName, "Accessibility text of Priority column is incorrect.");

            hr = accessor.GetColumnValue((int)TaskFields.PriorityNumber, out type, out flags, out val, out accName);

            Assert.AreEqual(VSConstants.S_OK, hr, "GetColumnValue did not return S_OK for the PriorityNumber column.");
            Assert.AreEqual(__VSTASKVALUETYPE.TVT_BASE10, (__VSTASKVALUETYPE)type, "Type of PriorityNumber column is incorrect.");
            Assert.AreEqual(0, (int)flags, "Flags for PriorityNumber column are incorrect.");
            Assert.AreEqual(typeof(int), val.GetType(), "Value of PriorityNumber column has wrong type.");
            Assert.AreEqual(1, (int)val, "Value of PriorityNumber column is incorrect.");
            Assert.AreEqual("", accName, "Accessibility text of PriorityNumber column is incorrect.");

            hr = accessor.GetColumnValue((int)TaskFields.Term, out type, out flags, out val, out accName);

            Assert.AreEqual(VSConstants.S_OK, hr, "GetColumnValue did not return S_OK for the Term column.");
            Assert.AreEqual(__VSTASKVALUETYPE.TVT_TEXT, (__VSTASKVALUETYPE)type, "Type of Term column is incorrect.");
            Assert.AreEqual(0, (int)flags, "Flags for Term column are incorrect.");
            Assert.AreEqual(typeof(string), val.GetType(), "Value of Term column has wrong type.");
            Assert.AreEqual("term", (string)val, "Value of Term column is incorrect.");
            Assert.AreEqual("", accName, "Accessibility text of Term column is incorrect.");

            hr = accessor.GetColumnValue((int)TaskFields.Class, out type, out flags, out val, out accName);

            Assert.AreEqual(VSConstants.S_OK, hr, "GetColumnValue did not return S_OK for the Class column.");
            Assert.AreEqual(__VSTASKVALUETYPE.TVT_TEXT, (__VSTASKVALUETYPE)type, "Type of Class column is incorrect.");
            Assert.AreEqual(0, (int)flags, "Flags for Class column are incorrect.");
            Assert.AreEqual(typeof(string), val.GetType(), "Value of Class column has wrong type.");
            Assert.AreEqual("class", (string)val, "Value of Class column is incorrect.");
            Assert.AreEqual("", accName, "Accessibility text of Class column is incorrect.");

            hr = accessor.GetColumnValue((int)TaskFields.Replacement, out type, out flags, out val, out accName);

            Assert.AreEqual(VSConstants.S_OK, hr, "GetColumnValue did not return S_OK for the Replacement column.");
            Assert.AreEqual(__VSTASKVALUETYPE.TVT_TEXT, (__VSTASKVALUETYPE)type, "Type of Replacement column is incorrect.");
            Assert.AreEqual(0, (int)flags, "Flags for Replacement column are incorrect.");
            Assert.AreEqual(typeof(string), val.GetType(), "Value of Replacement column has wrong type.");
            Assert.AreEqual("replacement", (string)val, "Value of Replacement column is incorrect.");
            Assert.AreEqual("", accName, "Accessibility text of Replacement column is incorrect.");

            hr = accessor.GetColumnValue((int)TaskFields.Comment, out type, out flags, out val, out accName);

            Assert.AreEqual(VSConstants.S_OK, hr, "GetColumnValue did not return S_OK for the Comment column.");
            Assert.AreEqual(__VSTASKVALUETYPE.TVT_LINKTEXT, (__VSTASKVALUETYPE)type, "Type of Comment column is incorrect.");
            Assert.AreEqual(0, (int)flags, "Flags for Comment column are incorrect.");
            Assert.AreEqual(typeof(string), val.GetType(), "Value of Comment column has wrong type.");
            Assert.AreEqual("comment with link:  @http://www.microsoft.com@", (string)val, "Value of Comment column is incorrect.");
            Assert.AreEqual("", accName, "Accessibility text of Comment column is incorrect.");

            hr = accessor.GetColumnValue((int)TaskFields.File, out type, out flags, out val, out accName);

            Assert.AreEqual(VSConstants.S_OK, hr, "GetColumnValue did not return S_OK for the File column.");
            Assert.AreEqual(__VSTASKVALUETYPE.TVT_TEXT, (__VSTASKVALUETYPE)type, "Type of File column is incorrect.");
            Assert.AreEqual(__VSTASKVALUEFLAGS.TVF_FILENAME, (__VSTASKVALUEFLAGS)flags, "Flags for File column are incorrect.");
            Assert.AreEqual(typeof(string), val.GetType(), "Value of File column has wrong type.");
            Assert.AreEqual("z:\\dir\\file.ext", (string)val, "Value of File column is incorrect.");
            Assert.AreEqual("", accName, "Accessibility text of File column is incorrect.");

            hr = accessor.GetColumnValue((int)TaskFields.Line, out type, out flags, out val, out accName);

            Assert.AreEqual(VSConstants.S_OK, hr, "GetColumnValue did not return S_OK for the Line column.");
            Assert.AreEqual(__VSTASKVALUETYPE.TVT_BASE10, (__VSTASKVALUETYPE)type, "Type of Line column is incorrect.");
            Assert.AreEqual(0, (int)flags, "Flags for Line column are incorrect.");
            Assert.AreEqual(typeof(int), val.GetType(), "Value of Line column has wrong type.");
            Assert.AreEqual(3, (int)val, "Value of Line column is incorrect.");
            Assert.AreEqual("", accName, "Accessibility text of Line column is incorrect.");

            hr = accessor.GetColumnValue((int)TaskFields.Project, out type, out flags, out val, out accName);

            Assert.AreEqual(VSConstants.S_OK, hr, "GetColumnValue did not return S_OK for the Project column.");
            Assert.AreEqual(__VSTASKVALUETYPE.TVT_TEXT, (__VSTASKVALUETYPE)type, "Type of Project column is incorrect.");
            Assert.AreEqual(0, (int)flags, "Flags for Project column are incorrect.");
            Assert.AreEqual(typeof(string), val.GetType(), "Value of Project column has wrong type.");
            string uniqueName;

            solution.GetUniqueUINameOfProject(project, out uniqueName);
            Assert.AreEqual(uniqueName, (string)val, "Value of Project column is incorrect.");
            Assert.AreEqual("", accName, "Accessibility text of Project column is incorrect.");
        }