提交 3e33564d 编写于 作者: J Jonathon Marolf

responding to tmeschter's feedback

上级 9119afc4
......@@ -98,8 +98,8 @@ protected void EditWinFormButtonProperty(string buttonName, string propertyName,
protected void EditWinFormsButtonEvent(string buttonName, string eventName, string eventHandlerName)
=> VisualStudio.Instance.Editor.EditWinFormButtonEvent(buttonName, eventName, eventHandlerName);
protected void VerifyWinFormButtonPropertySet(string buttonName, string propertyName, string expectedPropertyValue)
=> VisualStudio.Instance.Editor.VerifyWinFormButtonPropertySet(buttonName, propertyName, expectedPropertyValue);
protected string GetWinFormButtonPropertyValue(string buttonName, string propertyName)
=> VisualStudio.Instance.Editor.GetWinFormButtonPropertyValue(buttonName, propertyName);
protected void SelectTextInCurrentDocument(string text)
{
......
using Microsoft.CodeAnalysis;
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis;
using Microsoft.VisualStudio.IntegrationTest.Utilities;
using Microsoft.VisualStudio.IntegrationTest.Utilities.Common;
using Microsoft.VisualStudio.IntegrationTest.Utilities.Input;
......@@ -39,7 +41,7 @@ void M()
/// <param name=""i2"">an integer, anything you like.</param>
/// <returns>returns an object of type C</returns>
C Method(int i, int i2) { return null; }
/// <summary>
/// Hello Generic World!
/// </summary>
......@@ -48,7 +50,7 @@ void M()
/// <returns>Null</returns>
C GenericMethod<T1>(T1 i) { return null; }
C GenericMethod<T1, T2>(T1 i, T2 i2) { return null; }
/// <summary>
/// Complex Method Params
/// </summary>
......@@ -98,7 +100,7 @@ void M()
/// <param name=""i2"">an integer, anything you like.</param>
/// <returns>returns an object of type C</returns>
C Method(int i, int i2) { return null; }
/// <summary>
/// Hello Generic World!
/// </summary>
......@@ -107,7 +109,7 @@ void M()
/// <returns>Null</returns>
C GenericMethod<T1>(T1 i) { return null; }
C GenericMethod<T1, T2>(T1 i, T2 i2) { return null; }
/// <summary>
/// Complex Method Params
/// </summary>
......@@ -146,7 +148,7 @@ void M()
/// <param name=""i2"">an integer, anything you like.</param>
/// <returns>returns an object of type C</returns>
C Method(int i, int i2) { return null; }
/// <summary>
/// Hello Generic World!
/// </summary>
......@@ -155,7 +157,7 @@ void M()
/// <returns>Null</returns>
C GenericMethod<T1>(T1 i) { return null; }
C GenericMethod<T1, T2>(T1 i, T2 i2) { return null; }
/// <summary>
/// Complex Method Params
/// </summary>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.VisualStudio.IntegrationTest.Utilities;
using Microsoft.VisualStudio.IntegrationTest.Utilities.InProcess;
using Xunit;
namespace Roslyn.VisualStudio.IntegrationTests.CSharp
......@@ -49,7 +45,9 @@ public void Change_Control_Property_In_Code()
OpenFileWithDesigner(ProjectName, "Form1.cs");
AddWinFormButton("SomeButton");
EditWinFormButtonProperty(buttonName: "SomeButton", propertyName: "Text", propertyValue: "ButtonTextGoesHere");
VerifyWinFormButtonPropertySet(buttonName: "SomeButton", propertyName: "Text", expectedPropertyValue: "ButtonTextGoesHere");
var expectedPropertyValue = "ButtonTextGoesHere";
var actualPropertyValue = GetWinFormButtonPropertyValue(buttonName: "SomeButton", propertyName: "Text");
Assert.Equal(expectedPropertyValue, actualPropertyValue);
CloseFile(ProjectName, "Form1.cs", saveFile: true);
// Change the control's text in designer.cs code
OpenFile(ProjectName, "Form1.Designer.cs");
......@@ -61,7 +59,9 @@ public void Change_Control_Property_In_Code()
CloseFile(ProjectName, "Form1.Designer.cs", saveFile: true);
// Verify that the control text has changed in the designer
OpenFileWithDesigner(ProjectName, "Form1.cs");
VerifyWinFormButtonPropertySet(buttonName: "SomeButton", propertyName: "Text", expectedPropertyValue: "GibberishText");
expectedPropertyValue = "GibberishText";
actualPropertyValue = GetWinFormButtonPropertyValue(buttonName: "SomeButton", propertyName: "Text");
Assert.Equal(expectedPropertyValue, actualPropertyValue);
}
[Fact, Trait(Traits.Feature, Traits.Features.WinForms)]
......
......@@ -8,8 +8,8 @@
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.Windows.Automation;
using System.Windows.Forms;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Editor.Implementation.Suggestions;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
......@@ -159,7 +159,6 @@ public void PlaceCaret(string marker, int charsOffset, int occurrence, bool exte
if (occurrence > 0)
{
var result = EnvDTE.vsFindResult.vsFindResultNotFound;
for (var i = 0; i < occurrence; i++)
{
......@@ -770,16 +769,12 @@ void ComponentChanged(object sender, ComponentChangedEventArgs e)
}
}
public void VerifyWinFormButtonPropertySet(string buttonName, string propertyName, string expectedPropertyValue)
public string GetWinFormButtonPropertyValue(string buttonName, string propertyName)
{
var designerHost = (IDesignerHost)GetDTE().ActiveWindow.Object;
var button = designerHost.Container.Components[buttonName];
var properties = TypeDescriptor.GetProperties(button);
var actualPropertyValue = (string)properties[propertyName].GetValue(button);
if (actualPropertyValue != expectedPropertyValue)
{
throw new Exception($"Property value mismatch for control:property: {buttonName}:{propertyName}, expected: {expectedPropertyValue}, actual: {actualPropertyValue}");
}
return properties[propertyName].GetValue(button) as string;
}
}
}
......@@ -333,7 +333,12 @@ public void CloseFile(string projectName, string relativeFilePath, bool saveFile
var fileName = Path.GetFileName(filePath);
var dte = GetDTE();
var fileToClose = dte.Documents.Cast<EnvDTE.Document>().FirstOrDefault(document => document.Name.Equals(fileName));
var documents = dte.Documents.Cast<EnvDTE.Document>();
var fileToClose = documents.FirstOrDefault(document => document.Name.Equals(fileName));
if (fileToClose == null)
{
throw new InvalidOperationException($"File '{fileName}' not closed because it couldn't be found. Available files: {string.Join(", ", documents.Select(x => x.Name))}.");
}
if (saveFile)
{
SaveFile(fileName);
......
......@@ -115,8 +115,8 @@ public void EditWinFormButtonProperty(string buttonName, string propertyName, st
public void EditWinFormButtonEvent(string buttonName, string eventName, string eventHandlerName)
=> _inProc.EditWinFormButtonEvent(buttonName, eventName, eventHandlerName);
public void VerifyWinFormButtonPropertySet(string buttonName, string propertyName, string expectedPropertyValue)
=> _inProc.VerifyWinFormButtonPropertySet(buttonName, propertyName, expectedPropertyValue);
public string GetWinFormButtonPropertyValue(string buttonName, string propertyName)
=> _inProc.GetWinFormButtonPropertyValue(buttonName, propertyName);
/// <summary>
/// Sends key strokes to the active editor in Visual Studio. Various types are supported by this method:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册