Skip to content

Commit

Permalink
Improve mock tests
Browse files Browse the repository at this point in the history
add mock testing setting file for running mock tests
add support for deleting via solution explorer
	send delete command to hierarchy node
	translate into proper interface calls
add start of some DTE mocks
Start adding some abstractions for different dialog types, add dialog
message loop
imporve running document table mocks
Implement more missing IVisualStudioInstance functionality
Update DragDropCopyCutPaste tests to use interface calls instead of using
keyboard/UI directly
  • Loading branch information
dino committed May 12, 2015
1 parent e002b67 commit 0fe720c
Show file tree
Hide file tree
Showing 17 changed files with 1,280 additions and 95 deletions.
23 changes: 23 additions & 0 deletions Build/default.Mock.testsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<TestSettings name="default" id="5C570F72-6E22-4F5C-B7D0-E8D3A7D6AB71" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<Description>Local test runs with the VS 2013 Experimental Hive</Description>
<Execution>
<Timeouts runTimeout="7200000" testTimeout="300000" />
<TestTypeSpecific>
<UnitTestRunConfig testTypeId="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b">
<AssemblyResolution>
<TestDirectory useLoadContext="true" />
</AssemblyResolution>
</UnitTestRunConfig>
</TestTypeSpecific>
<AgentRule name="LocalMachineDefaultRole">
</AgentRule>
</Execution>
<Properties>
<Property name="VSApplication" value="Mock"/>
<Property name="VSExecutable" value="devenv"/>
<Property name="VSVersion" value="12.0"/>
<Property name="VSHive" value="Exp"/>
<Property name="VSDebugMixedMode" value="false"/>
</Properties>
</TestSettings>
5 changes: 5 additions & 0 deletions Common/Tests/MockVsTests/CommandTargetExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public static void Tab(this IOleCommandTarget target) {
target.Exec(ref guid, (int)VSConstants.VSStd2KCmdID.TAB, 0, IntPtr.Zero, IntPtr.Zero);
}

public static void Delete(this IOleCommandTarget target) {
var guid = VSConstants.VSStd2K;
target.Exec(ref guid, (int)VSConstants.VSStd2KCmdID.DELETE, 0, IntPtr.Zero, IntPtr.Zero);
}

public static void Backspace(this IOleCommandTarget target) {
var guid = VSConstants.VSStd2K;
target.Exec(ref guid, (int)VSConstants.VSStd2KCmdID.BACKSPACE, 0, IntPtr.Zero, IntPtr.Zero);
Expand Down
319 changes: 319 additions & 0 deletions Common/Tests/MockVsTests/MockDTE.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,319 @@
/* ****************************************************************************
*
* Copyright (c) Microsoft Corporation.
*
* This source code is subject to terms and conditions of the Apache License, Version 2.0. A
* copy of the license can be found in the License.html file at the root of this distribution. If
* you cannot locate the Apache License, Version 2.0, please send an email to
* [email protected]. By using this source code in any fashion, you are agreeing to be bound
* by the terms of the Apache License, Version 2.0.
*
* You must not remove this notice, or any other, from this software.
*
* ***************************************************************************/

using System;
using System.Collections.Generic;
using EnvDTE;

namespace Microsoft.VisualStudioTools.MockVsTests {
internal class MockDTE : EnvDTE.DTE {
internal readonly MockVs _vs;

public MockDTE(MockVs vs) {
_vs = vs;
}

public Document ActiveDocument {
get {
throw new NotImplementedException();
}
}

public object ActiveSolutionProjects {
get {
throw new NotImplementedException();
}
}

public Window ActiveWindow {
get {
throw new NotImplementedException();
}
}

public AddIns AddIns {
get {
throw new NotImplementedException();
}
}

public DTE Application {
get {
throw new NotImplementedException();
}
}

public object CommandBars {
get {
throw new NotImplementedException();
}
}

public string CommandLineArguments {
get {
throw new NotImplementedException();
}
}

public Commands Commands {
get {
throw new NotImplementedException();
}
}

public ContextAttributes ContextAttributes {
get {
throw new NotImplementedException();
}
}

public Debugger Debugger {
get {
throw new NotImplementedException();
}
}

public vsDisplay DisplayMode {
get {
throw new NotImplementedException();
}

set {
throw new NotImplementedException();
}
}

public Documents Documents {
get {
throw new NotImplementedException();
}
}

public DTE DTE {
get {
return this;
}
}

public string Edition {
get {
throw new NotImplementedException();
}
}

public Events Events {
get {
throw new NotImplementedException();
}
}

public string FileName {
get {
throw new NotImplementedException();
}
}

public Find Find {
get {
throw new NotImplementedException();
}
}

public string FullName {
get {
throw new NotImplementedException();
}
}

public Globals Globals {
get {
throw new NotImplementedException();
}
}

public ItemOperations ItemOperations {
get {
throw new NotImplementedException();
}
}

public int LocaleID {
get {
throw new NotImplementedException();
}
}

public Macros Macros {
get {
throw new NotImplementedException();
}
}

public DTE MacrosIDE {
get {
throw new NotImplementedException();
}
}

public Window MainWindow {
get {
throw new NotImplementedException();
}
}

public vsIDEMode Mode {
get {
throw new NotImplementedException();
}
}

public string Name {
get {
throw new NotImplementedException();
}
}

public ObjectExtenders ObjectExtenders {
get {
throw new NotImplementedException();
}
}

public string RegistryRoot {
get {
throw new NotImplementedException();
}
}

public SelectedItems SelectedItems {
get {
throw new NotImplementedException();
}
}

public Solution Solution {
get {
return new MockDTESolution(this);
}
}

public SourceControl SourceControl {
get {
throw new NotImplementedException();
}
}

public StatusBar StatusBar {
get {
throw new NotImplementedException();
}
}

public bool SuppressUI {
get {
throw new NotImplementedException();
}

set {
throw new NotImplementedException();
}
}

public UndoContext UndoContext {
get {
throw new NotImplementedException();
}
}

public bool UserControl {
get {
throw new NotImplementedException();
}

set {
throw new NotImplementedException();
}
}

public string Version {
get {
throw new NotImplementedException();
}
}

public WindowConfigurations WindowConfigurations {
get {
throw new NotImplementedException();
}
}

public Windows Windows {
get {
throw new NotImplementedException();
}
}

public void ExecuteCommand(string CommandName, string CommandArgs = "") {
throw new NotImplementedException();
}

public object GetObject(string Name) {
throw new NotImplementedException();
}

public bool get_IsOpenFile(string ViewKind, string FileName) {
throw new NotImplementedException();
}

public Properties get_Properties(string Category, string Page) {
Properties res;
Dictionary<string, Properties> pages;
if (_properties.TryGetValue(Category, out pages) &&
pages.TryGetValue(Page, out res)) {
return res;
}
return null;
}

public wizardResult LaunchWizard(string VSZFile, ref object[] ContextParams) {
throw new NotImplementedException();
}

public Window OpenFile(string ViewKind, string FileName) {
throw new NotImplementedException();
}

public void Quit() {
throw new NotImplementedException();
}

public string SatelliteDllPath(string Path, string Name) {
throw new NotImplementedException();
}

Dictionary<string, Dictionary<string, Properties>> _properties = new Dictionary<string, Dictionary<string, Properties>>() {
{
"Environment",
new Dictionary<string, Properties>() {
{
"ProjectsAndSolution",
new MockDTEProperties() {
{ "MSBuildOutputVerbosity", 2 }
}
}
}
}
};
}
}
Loading

0 comments on commit 0fe720c

Please sign in to comment.