public void ProjectWithNUnitFrameworkReferenceCaseInsensitive()
        {
            IProject             project = new MockCSharpProject();
            ReferenceProjectItem referenceProjectItem = new ReferenceProjectItem(project);

            referenceProjectItem.Include = "nunit.framework";
            ProjectService.AddProjectItem(project, referenceProjectItem);

            Assert.IsTrue(TestProject.IsTestProject(project));
        }
        public void ProjectWithNUnitFrameworkReferenceSpecificVersion()
        {
            IProject             project = new MockCSharpProject();
            ReferenceProjectItem referenceProjectItem = new ReferenceProjectItem(project);

            referenceProjectItem.Include = "NUnit.Framework, Version=2.2.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77";
            ProjectService.AddProjectItem(project, referenceProjectItem);

            Assert.IsTrue(TestProject.IsTestProject(project));
        }
        public bool ReferenceExists(string name)
        {
            ReferenceProjectItem referenceProjectItem = FindReference(name);

            if (referenceProjectItem != null)
            {
                return(true);
            }
            return(false);
        }
        public void RemoveReference(string name)
        {
            ReferenceProjectItem referenceProjectItem = FindReference(name);

            if (referenceProjectItem != null)
            {
                projectService.RemoveProjectItem(project, referenceProjectItem);
                projectService.Save(project);
                LogRemovedReferenceFromProject(referenceProjectItem);
            }
        }
        public void Init()
        {
            project = new MockCSharpProject();

            command.Run(project);

            if (project.Items.Count > 0)
            {
                referenceProjectItem = project.Items[0] as ReferenceProjectItem;
            }
        }
 static string[] GetReferenceProjectItemAsStrings(ReferenceProjectItem referenceItem)
 {
     if (referenceItem == null)
     {
         return(new string[2]);
     }
     return(new string[] {
         "Include: " + referenceItem.Include,
         "HintPath: " + referenceItem.HintPath
     });
 }
        void CreateReference(string name)
        {
            project              = new TestableDTEProject();
            msbuildProject       = project.TestableProject;
            referenceProjectItem = msbuildProject.AddReference(name);
            fakeProjectService   = project.FakeProjectService;
            CreateReference(project, referenceProjectItem);
            IWorkbench workbench = MockRepository.GenerateStub <IWorkbench>();

            ICSharpCode.SharpDevelop.SD.Services.AddService(typeof(IWorkbench), workbench);
        }
        ReferenceProjectItem AddReferenceToProject(string reference, string fileName)
        {
            IProject dummyProject = MockRepository.GenerateStub <IProject>();

            dummyProject.Stub(p => p.SyncRoot).Return(new object());
            var projectItem = new ReferenceProjectItem(dummyProject, reference);

            projectItem.FileName = FileName.Create(fileName);
            projectReferences.Add(projectItem);
            return(projectItem);
        }
Esempio n. 9
0
 public static IProjectContent GetProjectContentForReference(ReferenceProjectItem item)
 {
     if (item is ProjectReferenceProjectItem)
     {
         if (((ProjectReferenceProjectItem)item).ReferencedProject == null)
         {
             return(null);
         }
         return(ParserService.GetProjectContent(((ProjectReferenceProjectItem)item).ReferencedProject));
     }
     return(GetRegistryForReference(item).GetProjectContentForReference(item.Include, item.FileName));
 }
        public void ResolvePath_AssemblyReferenceNameIsInDifferentCase_ReturnsFullPathToTestAssembly()
        {
            CreateResolver();
            ReferenceProjectItem reference = AddReferenceToProject("test");
            string expectedFileName        = @"d:\projects\MyProject\lib\Test.dll";

            reference.HintPath = expectedFileName;

            string result = resolver.ResolvePath("TEST");

            Assert.AreEqual(expectedFileName, result);
        }
Esempio n. 11
0
        public void GetReferences_ProjectHasGacReference_ReturnsGacReference()
        {
            CreateProjectWithMSBuildProject();
            ReferenceProjectItem refItem = AddGacReferenceToProject("System.Xml");
            IEnumerable <ReferenceProjectItem> references = project.GetReferences();

            var expectedReferences = new ReferenceProjectItem[] {
                refItem
            };

            CollectionAssert.AreEqual(expectedReferences, references);
        }
Esempio n. 12
0
        protected override ParseProjectContent CreateProjectContent()
        {
            ParseProjectContent  pc    = base.CreateProjectContent();
            ReferenceProjectItem vbRef = new ReferenceProjectItem(this, "Microsoft.VisualBasic");

            if (vbRef != null)
            {
                pc.AddReferencedContent(AssemblyParserService.GetProjectContentForReference(vbRef));
            }
            MyNamespaceBuilder.BuildNamespace(this, pc);
            return(pc);
        }
        public void ResolvePath_ProjectHasOneReferenceToTestAssemblyWithFileNameSet_ReturnsFullPathToTestAssembly()
        {
            CreateResolver();
            ReferenceProjectItem reference = AddReferenceToProject("Test");
            string expectedFileName        = @"d:\projects\MyProject\lib\Test.dll";

            reference.FileName = expectedFileName;

            string result = resolver.ResolvePath("Test");

            Assert.AreEqual(expectedFileName, result);
        }
        public void Init()
        {
            // Create a project to display.
            project      = new MockCSharpProject();
            project.Name = "TestProject";
            ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project);

            nunitFrameworkReferenceItem.Include = "NUnit.Framework";
            ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem);

            // Add a test class.
            projectContent = new MockProjectContent();
            MockClass c = new MockClass(projectContent, "RootNamespace.MyTestFixture");

            c.Attributes.Add(new MockAttribute("TestFixture"));
            MockMethod test1Method = new MockMethod(c, "Test1");

            test1Method.Attributes.Add(new MockAttribute("Test"));
            c.Methods.Add(test1Method);

            // Test 2 method is from a duplicate test class.
            MockMethod test2Method = new MockMethod(c, "Test2");

            test2Method.Attributes.Add(new MockAttribute("Test"));
            c.Methods.Add(test2Method);
            projectContent.Classes.Add(c);

            testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport();
            testProject    = new TestProject(project, projectContent, testFrameworks);

            // Make sure test methods are created, otherwise
            // the Test2 method will never be looked at due to lazy evaluation
            // of test method.
            int count = testProject.TestClasses[0].TestMethods.Count;

            // Change the name of the second test class.
            DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent);

            oldUnit.Classes.Add(c);
            c.Methods.Remove(test2Method);             // Remove duplicate test class method.

            // Create new compilation unit with inner class that has its method renamed.
            DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent);
            MockClass newTestClass         = new MockClass(projectContent, "RootNamespace.MyNewTestFixture");

            newTestClass.Attributes.Add(new MockAttribute("TestFixture"));
            projectContent.Classes.Add(newTestClass);
            newTestClass.Methods.Add(test2Method);
            newUnit.Classes.Add(newTestClass);

            testProject.UpdateParseInfo(oldUnit, newUnit);
        }
Esempio n. 15
0
        public void ClassOccursBeforeNamespaceOnInitialLoad()
        {
            MockCSharpProject project = new MockCSharpProject();

            project.Name = "TestProject";
            ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project);

            nunitFrameworkReferenceItem.Include = "NUnit.Framework";
            ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem);
            List <IProject> projects = new List <IProject>();

            projects.Add(project);

            // Add a test class with a TestFixture attributes.
            TestClass testClass = CreateTestClass("MyTests.MyTestFixture");

            projectContent.Classes.Add(testClass.Class);

            // Add a second class with no namespace.
            testClass = CreateTestClass("AppleTestFixture");
            projectContent.Classes.Add(testClass.Class);

            // Add another class that exists in a namespace inside
            // MyTests.
            testClass = CreateTestClass("MyTests.ZebraTests.AddZebra");
            projectContent.Classes.Add(testClass.Class);

            // Load the project into the tree.
            treeView.Clear();
            treeView.AddProject(project);
            projectNode = (TestProjectTreeNode)treeView.Nodes[0];
            projectNode.PerformInitialization();

            ExtTreeNode treeNode = (ExtTreeNode)projectNode.LastNode;

            treeNode.PerformInitialization();

            // Get the class node without a root namespace and
            // the my tests namespace node.
            TestClassTreeNode     appleTestFixtureNode = projectNode.FirstNode as TestClassTreeNode;
            TestNamespaceTreeNode myTestsNamespaceNode = projectNode.LastNode as TestNamespaceTreeNode;

            // Get the zebra namespace tree node.
            TestNamespaceTreeNode zebraTestsNamespaceNode = treeNode.LastNode as TestNamespaceTreeNode;

            Assert.IsNotNull(appleTestFixtureNode);
            Assert.AreEqual(appleTestFixtureNode.Text, "AppleTestFixture");
            Assert.IsNotNull(myTestsNamespaceNode);
            Assert.AreEqual(myTestsNamespaceNode.Text, "MyTests");
            Assert.IsNotNull(zebraTestsNamespaceNode);
            Assert.AreEqual(zebraTestsNamespaceNode.Text, "ZebraTests");
        }
        public override void Run()
        {
            ReferenceNode node = Owner as ReferenceNode;

            if (node != null)
            {
                ReferenceProjectItem item = node.ReferenceProjectItem;
                if (item != null)
                {
                    ParserService.RefreshProjectContentForReference(item);
                }
            }
        }
        public override void Run()
        {
            var node = Owner as ReferenceNode;

            if (node != null)
            {
                ReferenceProjectItem item = node.ReferenceProjectItem;
                if (item != null)
                {
                    SD.AssemblyParserService.RefreshAssembly(item.FileName);
                }
            }
        }
        public void UnknownProjectHasReferenceRemoved()
        {
            IProject             project = new MockCSharpProject();
            ReferenceProjectItem refItem = new ReferenceProjectItem(project);

            refItem.Include = "System";

            ProjectService.AddProjectItem(project, refItem);

            treeView.ProjectItemRemoved(refItem);

            Assert.AreEqual(1, treeView.Nodes.Count);
        }
Esempio n. 19
0
 void AddReference(ReferenceProjectItem reference, bool updateInterDependencies)
 {
     try {
         AddReferencedContent(ParserService.GetProjectContentForReference(reference));
         if (updateInterDependencies)
         {
             UpdateReferenceInterDependencies();
         }
         OnReferencedContentsChanged(EventArgs.Empty);
     } catch (Exception e) {
         MessageService.ShowError(e);
     }
 }
Esempio n. 20
0
        public override void FixtureSetUp()
        {
            base.FixtureSetUp();
            MSBuildBasedProject project = WebReferenceTestHelper.CreateTestProject("C#");

            project.FileName = FileName.Create("c:\\projects\\test\\foo.csproj");

            // Web references item.
            WebReferencesProjectItem webReferencesItem = new WebReferencesProjectItem(project);

            webReferencesItem.Include = "Web References\\";
            ProjectService.AddProjectItem(project, webReferencesItem);

            // Web reference url.
            WebReferenceUrl webReferenceUrl = new WebReferenceUrl(project);

            webReferenceUrl.Include       = "http://localhost/test.asmx";
            webReferenceUrl.UpdateFromURL = "http://localhost/test.asmx";
            webReferenceUrl.RelPath       = "Web References\\localhost";
            ProjectService.AddProjectItem(project, webReferenceUrl);

            FileProjectItem discoFileItem = new FileProjectItem(project, ItemType.None);

            discoFileItem.Include = "Web References\\localhost\\test.disco";
            ProjectService.AddProjectItem(project, discoFileItem);

            FileProjectItem wsdlFileItem = new FileProjectItem(project, ItemType.None);

            wsdlFileItem.Include = "Web References\\localhost\\test.wsdl";
            ProjectService.AddProjectItem(project, wsdlFileItem);

            // Proxy
            FileProjectItem proxyItem = new FileProjectItem(project, ItemType.Compile);

            proxyItem.Include       = "Web References\\localhost\\Reference.cs";
            proxyItem.DependentUpon = "Reference.map";
            ProjectService.AddProjectItem(project, proxyItem);

            // Reference map.
            FileProjectItem mapItem = new FileProjectItem(project, ItemType.None);

            mapItem.Include = "Web References\\localhost\\Reference.map";
            ProjectService.AddProjectItem(project, mapItem);

            // System.Web.Services reference.
            ReferenceProjectItem webServicesReferenceItem = new ReferenceProjectItem(project, "System.Web.Services");

            ProjectService.AddProjectItem(project, webServicesReferenceItem);

            projectItems = WebReference.GetFileItems(project, "localhost");
        }
        public void RemoveReference_ReferenceBeingRemovedHasFileExtension_ReferenceRemovedFromProject()
        {
            CreateTestProject();
            ProjectHelper.AddReference(project, "nunit.framework");
            CreateProjectSystem(project);

            string fileName = @"d:\projects\packages\nunit\nunit.framework.dll";

            projectSystem.RemoveReference(fileName);

            ReferenceProjectItem referenceItem = ProjectHelper.GetReference(project, "nunit.framework");

            Assert.IsNull(referenceItem);
        }
Esempio n. 22
0
        public void IsTestProjectReturnsTrueForProjectWithNUnitFrameworkAssemblyReferenceIgnoringNonReferenceProjectItems()
        {
            MockCSharpProject project = new MockCSharpProject();

            FileProjectItem fileItem = new FileProjectItem(project, ItemType.Compile, "test.cs");

            ProjectService.AddProjectItem(project, fileItem);

            ReferenceProjectItem nunitFrameworkRef = new ReferenceProjectItem(project, "nunit.framework");

            ProjectService.AddProjectItem(project, nunitFrameworkRef);

            Assert.IsTrue(testFramework.IsTestProject(project));
        }
Esempio n. 23
0
        public void IsTestProjectReturnsTrueForProjectWithNUnitFrameworkAssemblyReference()
        {
            MockCSharpProject project = new MockCSharpProject();

            ReferenceProjectItem systemRef = new ReferenceProjectItem(project, "System");

            ProjectService.AddProjectItem(project, systemRef);

            ReferenceProjectItem nunitFrameworkRef = new ReferenceProjectItem(project, "NUnit.Framework");

            ProjectService.AddProjectItem(project, nunitFrameworkRef);

            Assert.IsTrue(testFramework.IsTestProject(project));
        }
        public void RemoveReference_ReferenceCaseAddedToProjectDifferentToReferenceNameBeingRemoved_ReferenceRemovedFromProject()
        {
            CreateTestProject();
            ProjectHelper.AddReference(project, "nunit.framework");
            CreateProjectSystem(project);

            string fileName = @"NUNIT.FRAMEWORK.DLL";

            projectSystem.RemoveReference(fileName);

            ReferenceProjectItem referenceItem = ProjectHelper.GetReference(project, "nunit.framework");

            Assert.IsNull(referenceItem);
        }
Esempio n. 25
0
        List <ReferenceProjectItem> GetReferences(IProject project)
        {
            List <ReferenceProjectItem> references = new List <ReferenceProjectItem>();

            foreach (ProjectItem item in project.Items)
            {
                ReferenceProjectItem reference = item as ReferenceProjectItem;
                if (reference != null)
                {
                    references.Add(reference);
                }
            }
            return(references);
        }
Esempio n. 26
0
        public void Init()
        {
            // Create a project to display in the test tree view.
            MockCSharpProject project = new MockCSharpProject();

            project.Name = "TestProject";
            ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project);

            nunitFrameworkReferenceItem.Include = "NUnit.Framework";
            ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem);
            List <IProject> projects = new List <IProject>();

            projects.Add(project);

            // Add a test class with a TestFixture attributes.
            projectContent          = new MockProjectContent();
            projectContent.Language = LanguageProperties.None;
            TestClass testClass = CreateTestClass("MyTests.MyTestFixture");

            projectContent.Classes.Add(testClass.Class);

            // Add two methods to the test class only
            // one of which has test attributes.
            MockMethod testMethod = new MockMethod("NameExists");

            testMethod.Attributes.Add(new MockAttribute("Test"));
            testMethod.DeclaringType = testClass.Class;
            testClass.Class.Methods.Add(testMethod);

            // Init mock project content to be returned.
            treeView = new DummyParserServiceTestTreeView();
            treeView.ProjectContentForProject = projectContent;

            // Load the projects into the test tree view.
            treeView.AddProjects(projects);
            projectNode = (TestProjectTreeNode)treeView.Nodes[0];
            testProject = projectNode.TestProject;

            // Initialise the root node so the child nodes are created.
            projectNode.PerformInitialization();
            myTestsNamespaceNode = (TestNamespaceTreeNode)projectNode.FirstNode;

            // Initialise the first namespace node.
            myTestsNamespaceNode.PerformInitialization();
            testFixtureNode = (TestClassTreeNode)myTestsNamespaceNode.FirstNode;

            // Initialise the test method tree nodes.
            testFixtureNode.PerformInitialization();
        }
        public void RemoveReference_ReferenceBeingRemovedHasFileExtensionAndProjectHasReferenceIncludingAssemblyVersion_ReferenceRemovedFromProject()
        {
            CreateTestProject();
            string include = "nunit.framework, Version=2.6.2.0, Culture=neutral, PublicKeyToken=8cc8392e8503e009";

            ProjectHelper.AddReference(project, include);
            CreateProjectSystem(project);
            string fileName = @"d:\projects\packages\nunit\nunit.framework.dll";

            projectSystem.RemoveReference(fileName);

            ReferenceProjectItem referenceItem = ProjectHelper.GetReference(project, "nunit.framework");

            Assert.IsNull(referenceItem);
        }
Esempio n. 28
0
 /// <summary>
 /// Determines whether the project is a test project. A project
 /// is considered to be a test project if it contains a reference
 /// to the NUnit.Framework assembly.
 /// </summary>
 public bool IsTestProject(IProject project)
 {
     if (project != null)
     {
         foreach (ProjectItem projectItem in project.Items)
         {
             ReferenceProjectItem referenceProjectItem = projectItem as ReferenceProjectItem;
             if (IsNUnitFrameworkAssemblyReference(referenceProjectItem))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
        public void AddFrameworkReference_SystemXmlToBeAdded_ReferenceAddedToProject()
        {
            CreateTestProject();
            CreateProjectSystem(project);

            projectSystem.AddFrameworkReference("System.Xml");

            ReferenceProjectItem referenceItem = ProjectHelper.GetReference(project, "System.Xml");

            ReferenceProjectItem expectedReferenceItem = new ReferenceProjectItem(project);

            expectedReferenceItem.Include = "System.Xml";

            ReferenceProjectItemAssert.AreEqual(expectedReferenceItem, referenceItem);
        }
Esempio n. 30
0
        protected override ParseProjectContent CreateProjectContent()
        {
            if (BooCompilerPC == null)
            {
                ReferenceProjectItem booCompilerItem = new ReferenceProjectItem(this, typeof(Boo.Lang.Compiler.AbstractAstAttribute).Assembly.Location);
                BooCompilerPC = AssemblyParserService.GetProjectContentForReference(booCompilerItem);
            }

            ParseProjectContent pc = base.CreateProjectContent();

            pc.DefaultImports = new DefaultUsing(pc);
            pc.DefaultImports.Usings.Add("Boo.Lang");
            pc.DefaultImports.Usings.Add("Boo.Lang.Builtins");
            pc.DefaultImports.Usings.Add("Boo.Lang.Extensions");
            return(pc);
        }