public void VerifyAddParametersAcrossLanguages()
        {
            SetUpEditor(@"
using VBProject;

class CSharpTest
{
    public void TestMethod()
    {
        VBClass x = new VBClass();
        x.Method$$(0, ""str"", 3.0);
    }
}");
            var vbProject = new ProjectUtils.Project("VBProject");

            VisualStudio.SolutionExplorer.AddProject(vbProject, WellKnownProjectTemplates.ClassLibrary, LanguageNames.VisualBasic);
            VisualStudio.Editor.SetText(@"
Public Class VBClass
    Public Function Method(a As Integer, b As String, c As Double) As Integer
        Return 1
    End Function
End Class
");
            VisualStudio.SolutionExplorer.SaveAll();
            var project            = new ProjectUtils.Project(ProjectName);
            var vbProjectReference = new ProjectUtils.ProjectReference("VBProject");

            VisualStudio.SolutionExplorer.AddProjectReference(project, vbProjectReference);
            VisualStudio.SolutionExplorer.OpenFile(project, "Class1.cs");

            VisualStudio.Workspace.WaitForAsyncOperations(Helper.HangMitigatingTimeout, FeatureAttribute.Workspace);

            ChangeSignatureDialog.Invoke();
            ChangeSignatureDialog.VerifyOpen();
            ChangeSignatureDialog.ClickAddButton();

            AddParameterDialog.VerifyOpen();
            AddParameterDialog.FillTypeField("String");
            AddParameterDialog.FillNameField("d");
            AddParameterDialog.FillCallSiteField(@"""str2""");
            AddParameterDialog.ClickOK();
            AddParameterDialog.VerifyClosed();

            ChangeSignatureDialog.ClickOK();
            ChangeSignatureDialog.VerifyClosed();
            var actualText = VisualStudio.Editor.GetText();

            Assert.Contains(@"x.Method(0, ""str"", 3.0, ""str2"")", actualText);
            VisualStudio.SolutionExplorer.OpenFile(vbProject, "Class1.vb");
            actualText = VisualStudio.Editor.GetText();
            var expectedText = @"
Public Class VBClass
    Public Function Method(a As Integer, b As String, c As Double, d As String) As Integer
        Return 1
    End Function
End Class";

            Assert.Contains(expectedText, actualText);
        }
Example #2
0
        public void VerifyAddParametersAcrossLanguages()
        {
            SetUpEditor(@"
Class VBTest
    Sub TestMethod()
        Dim x As New CSharpClass
        x.Method$$(0, ""str"", 3.0)
    End Sub
End Class");
            var csharpProject = new ProjectUtils.Project("CSharpProject");

            VisualStudio.SolutionExplorer.AddProject(csharpProject, WellKnownProjectTemplates.ClassLibrary, LanguageNames.CSharp);
            VisualStudio.Editor.SetText(@"
public class CSharpClass
{
    public int Method(int a, string b, double c)
    {
        return 1;
    }
}");
            VisualStudio.SolutionExplorer.SaveAll();
            var project = new ProjectUtils.Project(ProjectName);
            var csharpProjectReference = new ProjectUtils.ProjectReference("CSharpProject");

            VisualStudio.SolutionExplorer.AddProjectReference(project, csharpProjectReference);
            VisualStudio.SolutionExplorer.OpenFile(project, "Class1.vb");

            VisualStudio.Workspace.WaitForAsyncOperations(Helper.HangMitigatingTimeout, FeatureAttribute.Workspace);

            ChangeSignatureDialog.Invoke();
            ChangeSignatureDialog.VerifyOpen();
            ChangeSignatureDialog.ClickAddButton();

            AddParameterDialog.VerifyOpen();
            AddParameterDialog.FillTypeField("string");
            AddParameterDialog.FillNameField("d");
            AddParameterDialog.FillCallSiteField(@"""str2""");
            AddParameterDialog.ClickOK();
            AddParameterDialog.VerifyClosed();

            ChangeSignatureDialog.ClickOK();
            ChangeSignatureDialog.VerifyClosed();
            var actualText = VisualStudio.Editor.GetText();

            Assert.Contains(@"x.Method(0, ""str"", 3.0, ""str2"")", actualText);
            VisualStudio.SolutionExplorer.OpenFile(csharpProject, "Class1.cs");
            actualText = VisualStudio.Editor.GetText();
            var expectedText = @"
public class CSharpClass
{
    public int Method(int a, string b, double c, string d)
    {
        return 1;
    }
}";

            Assert.Contains(expectedText, actualText);
        }
 public void RemoveProjectReference(
     ProjectUtils.Project projectName,
     ProjectUtils.ProjectReference projectReferenceName
     )
 {
     _inProc.RemoveProjectReference(projectName.Name, projectReferenceName.Name);
     _instance.Workspace.WaitForAsyncOperations(
         Helper.HangMitigatingTimeout,
         FeatureAttribute.Workspace
         );
 }
 public void AddProjectReference(
     ProjectUtils.Project fromProjectName,
     ProjectUtils.ProjectReference toProjectName
     )
 {
     _inProc.AddProjectReference(fromProjectName.Name, toProjectName.Name);
     _instance.Workspace.WaitForAsyncOperations(
         Helper.HangMitigatingTimeout,
         FeatureAttribute.Workspace
         );
 }
Example #5
0
        public void VerifyCrossLanguageGlobalUndo()
        {
            SetUpEditor(@"using VBProject;

class Program
{
    static void Main(string[] args)
    {
        VBClass vb = new VBClass();
        vb.Method$$(1, y: ""hello"");
        vb.Method(2, ""world"");
    }
}");

            var vbProject          = new ProjectUtils.Project("VBProject");
            var vbProjectReference = new ProjectUtils.ProjectReference(vbProject.Name);
            var project            = new ProjectUtils.Project(ProjectName);

            VisualStudio.SolutionExplorer.AddProject(vbProject, WellKnownProjectTemplates.ClassLibrary, LanguageNames.VisualBasic);
            VisualStudio.Editor.SetText(@"
Public Class VBClass
    Public Sub Method(x As Integer, y As String)
    End Sub
End Class");

            VisualStudio.SolutionExplorer.SaveAll();
            VisualStudio.SolutionExplorer.AddProjectReference(fromProjectName: project, toProjectName: vbProjectReference);
            VisualStudio.SolutionExplorer.OpenFile(project, "Class1.cs");

            ChangeSignatureDialog.Invoke();
            ChangeSignatureDialog.VerifyOpen();
            ChangeSignatureDialog.SelectParameter("String y");
            ChangeSignatureDialog.ClickUpButton();
            ChangeSignatureDialog.ClickOK();
            ChangeSignatureDialog.VerifyClosed();
            var actuaText = VisualStudio.Editor.GetText();

            Assert.Contains(@"vb.Method(y: ""hello"", x: 1);", actuaText);

            VisualStudio.SolutionExplorer.OpenFile(vbProject, "Class1.vb");
            actuaText = VisualStudio.Editor.GetText();
            Assert.Contains(@"Public Sub Method(y As String, x As Integer)", actuaText);

            VisualStudio.Editor.Undo();
            actuaText = VisualStudio.Editor.GetText();
            Assert.Contains(@"Public Sub Method(x As Integer, y As String)", actuaText);

            VisualStudio.SolutionExplorer.OpenFile(project, "Class1.cs");
            actuaText = VisualStudio.Editor.GetText();
            Assert.Contains(@"vb.Method(2, ""world"");", actuaText);
        }
Example #6
0
        public virtual void ProjectReference()
        {
            var project = new ProjectUtils.Project(ProjectName);
            var csProj2 = new ProjectUtils.Project("CSProj2");

            VisualStudio.SolutionExplorer.AddProject(csProj2, projectTemplate: DefaultProjectTemplate, languageName: LanguageName);
            var projectName = new ProjectUtils.ProjectReference(ProjectName);

            VisualStudio.SolutionExplorer.AddProjectReference(fromProjectName: csProj2, toProjectName: projectName);
            VisualStudio.SolutionExplorer.AddFile(project, "Program.cs", open: true, contents: "public class Class1 { }");
            VisualStudio.SolutionExplorer.AddFile(csProj2, "Program.cs", open: true, contents: "public class Class2 { Class1 c; }");
            VisualStudio.SolutionExplorer.OpenFile(csProj2, "Program.cs");
            VisualStudio.Editor.PlaceCaret("Class1");
            VisualStudio.Editor.Verify.CurrentTokenType("class name");
            VisualStudio.SolutionExplorer.RemoveProjectReference(projectReferenceName: projectName, projectName: csProj2);
            VisualStudio.Editor.Verify.CurrentTokenType("identifier");
        }
Example #7
0
        public virtual void ProjectReference()
        {
            var project = new ProjectUtils.Project(ProjectName);
            var csProj2 = new ProjectUtils.Project("CSProj2");

            this.AddProject(project: csProj2, projectTemplate: DefaultProjectTemplate, languageName: LanguageName);
            var projectName = new ProjectUtils.ProjectReference(ProjectName);

            this.AddProjectReference(fromProjectName: csProj2, toProjectName: projectName);
            this.AddFile("Program.cs", project: project, open: true, contents: "public class Class1 { }");
            this.AddFile("Program.cs", project: csProj2, open: true, contents: "public class Class2 { Class1 c; }");
            this.OpenFile("Program.cs", project: csProj2);
            this.PlaceCaret("Class1");
            this.VerifyCurrentTokenType("class name");
            this.RemoveProjectReference(projectReferenceName: projectName, projectName: csProj2);
            this.VerifyCurrentTokenType("identifier");
        }
Example #8
0
        public void VerifyReorderAndRemoveParametersAcrossLanguages()
        {
            SetUpEditor(@"
Class VBTest
    Sub TestMethod()
        Dim x As New CSharpClass
        x.Method$$(0, ""str"", 3.0)
    End Sub
End Class");
            var csharpProject = new ProjectUtils.Project("CSharpProject");

            VisualStudio.SolutionExplorer.AddProject(csharpProject, WellKnownProjectTemplates.ClassLibrary, LanguageNames.CSharp);
            VisualStudio.Editor.SetText(@"
public class CSharpClass
{
    /// <summary>
    /// A method in CSharp.
    /// </summary>
    /// <param name=""a"">parameter a</param>
    /// <param name=""b"">parameter b</param>
    /// <param name=""c"">parameter c</param>
    /// <returns>One</returns>
    public int Method(int a, string b, double c)
    {
        return 1;
    }
}");
            VisualStudio.SolutionExplorer.SaveAll();
            var project = new ProjectUtils.Project(ProjectName);
            var csharpProjectReference = new ProjectUtils.ProjectReference("CSharpProject");

            VisualStudio.SolutionExplorer.AddProjectReference(project, csharpProjectReference);
            VisualStudio.SolutionExplorer.OpenFile(project, "Class1.vb");

            VisualStudio.Workspace.WaitForAsyncOperations(Helper.HangMitigatingTimeout, FeatureAttribute.Workspace);

            ChangeSignatureDialog.Invoke();
            ChangeSignatureDialog.VerifyOpen();
            ChangeSignatureDialog.SelectParameter("int a");
            ChangeSignatureDialog.ClickRemoveButton();
            ChangeSignatureDialog.SelectParameter("string b");
            ChangeSignatureDialog.ClickRemoveButton();
            ChangeSignatureDialog.SelectParameter("double c");
            ChangeSignatureDialog.ClickRemoveButton();
            ChangeSignatureDialog.SelectParameter("string b");
            ChangeSignatureDialog.ClickDownButton();
            ChangeSignatureDialog.ClickRestoreButton();
            ChangeSignatureDialog.ClickOK();
            ChangeSignatureDialog.VerifyClosed();
            var actualText = VisualStudio.Editor.GetText();

            Assert.Contains(@"x.Method(""str"")", actualText);
            VisualStudio.SolutionExplorer.OpenFile(csharpProject, "Class1.cs");
            actualText = VisualStudio.Editor.GetText();
            var expectedText = @"
public class CSharpClass
{
    /// <summary>
    /// A method in CSharp.
    /// </summary>
    /// <param name=""b"">parameter b</param>
    /// 
    /// 
    /// <returns>One</returns>
    public int Method(string b)
    {
        return 1;
    }
}";

            Assert.Contains(expectedText, actualText);
        }
 public static void RemoveProjectReference(this AbstractIntegrationTest test, ProjectUtils.ProjectReference projectReferenceName, ProjectUtils.Project projectName)
 {
     test.VisualStudio.Instance.SolutionExplorer.RemoveProjectReference(projectName.Name, projectReferenceName.Name);
     test.WaitForAsyncOperations(FeatureAttribute.Workspace);
 }