Add option to only notify on failed tests
This commit is contained in:
		
							parent
							
								
									801a83bcbc
								
							
						
					
					
						commit
						610f82311d
					
				
					 7 changed files with 43 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -22,7 +22,12 @@ namespace VitaliiGanzha.VsDingExtension
 | 
			
		|||
        [Category("Beeps")]
 | 
			
		||||
        [DisplayName("Tests")]
 | 
			
		||||
        [Description("Beep when a test run is completed")]
 | 
			
		||||
        public bool IsBuildOnTestComplete { get; set; }
 | 
			
		||||
        public bool IsBeepOnTestComplete { get; set; }
 | 
			
		||||
 | 
			
		||||
        [Category("Beeps")]
 | 
			
		||||
        [DisplayName("Failed Tests")]
 | 
			
		||||
        [Description("Beep only when a test failed")]
 | 
			
		||||
        public bool IsBeepOnTestFailed { get; set; }
 | 
			
		||||
 | 
			
		||||
        [DisplayName("Only when in background")]
 | 
			
		||||
        [Description("Beep only when Visual Studio does not have focus")]
 | 
			
		||||
| 
						 | 
				
			
			@ -36,7 +41,8 @@ namespace VitaliiGanzha.VsDingExtension
 | 
			
		|||
        {
 | 
			
		||||
            IsBeepOnBreakpointHit = true;
 | 
			
		||||
            IsBeepOnBuildComplete = true;
 | 
			
		||||
            IsBuildOnTestComplete = true;
 | 
			
		||||
            IsBeepOnTestComplete = true;
 | 
			
		||||
            IsBeepOnTestFailed = false;
 | 
			
		||||
            ShowTrayNotifications = true;
 | 
			
		||||
            IsBeepOnlyWhenVisualStudioIsInBackground = false;
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								VsDingExtensionProject/Resources.Designer.cs
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								VsDingExtensionProject/Resources.Designer.cs
									
										
									
										generated
									
									
									
								
							| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
//------------------------------------------------------------------------------
 | 
			
		||||
// <auto-generated>
 | 
			
		||||
//     This code was generated by a tool.
 | 
			
		||||
//     Runtime Version:4.0.30319.18449
 | 
			
		||||
//     Runtime Version:4.0.30319.42000
 | 
			
		||||
//
 | 
			
		||||
//     Changes to this file may cause incorrect behavior and will be lost if
 | 
			
		||||
//     the code is regenerated.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,15 @@
 | 
			
		|||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
 | 
			
		||||
  <PropertyGroup>
 | 
			
		||||
    <MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
 | 
			
		||||
    <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
 | 
			
		||||
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">12.0</VisualStudioVersion>
 | 
			
		||||
    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
 | 
			
		||||
    <TargetFrameworkProfile />
 | 
			
		||||
    <FileUpgradeFlags>
 | 
			
		||||
    </FileUpgradeFlags>
 | 
			
		||||
    <UpgradeBackupLocation>
 | 
			
		||||
    </UpgradeBackupLocation>
 | 
			
		||||
    <OldToolsVersion>12.0</OldToolsVersion>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
  <PropertyGroup>
 | 
			
		||||
    <ApplicationIcon>speaker.ico</ApplicationIcon>
 | 
			
		||||
| 
						 | 
				
			
			@ -58,6 +63,9 @@
 | 
			
		|||
    <Reference Include="Microsoft.VisualStudio.Shell.Interop.12.0">
 | 
			
		||||
      <EmbedInteropTypes>true</EmbedInteropTypes>
 | 
			
		||||
    </Reference>
 | 
			
		||||
    <Reference Include="Microsoft.VisualStudio.TestWindow.Core">
 | 
			
		||||
      <HintPath>$(DevEnvDir)\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.Core.dll</HintPath>
 | 
			
		||||
    </Reference>
 | 
			
		||||
    <Reference Include="Microsoft.VisualStudio.TestWindow.Interfaces">
 | 
			
		||||
      <HintPath>$(DevEnvDir)\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.Interfaces.dll</HintPath>
 | 
			
		||||
    </Reference>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,9 +15,10 @@
 | 
			
		|||
    using Microsoft.VisualStudio.ComponentModelHost;
 | 
			
		||||
    using Microsoft.VisualStudio.Shell;
 | 
			
		||||
    using Microsoft.VisualStudio.TestWindow.Extensibility;
 | 
			
		||||
    using Microsoft.VisualStudio.TestWindow.Controller;
 | 
			
		||||
 | 
			
		||||
    using Process = System.Diagnostics.Process;
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    [PackageRegistration(UseManagedResourcesOnly = true)]
 | 
			
		||||
    [InstalledProductRegistration("#110", "#112", "1.1", IconResourceID = 400)]
 | 
			
		||||
    [Guid(GuidList.guidVsDingExtensionProjectPkgString)]
 | 
			
		||||
| 
						 | 
				
			
			@ -67,7 +68,7 @@
 | 
			
		|||
                }
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            debugEvents.OnEnterBreakMode += delegate(dbgEventReason reason, ref dbgExecutionAction action)
 | 
			
		||||
            debugEvents.OnEnterBreakMode += delegate (dbgEventReason reason, ref dbgExecutionAction action)
 | 
			
		||||
            {
 | 
			
		||||
                if (reason != dbgEventReason.dbgEventReasonStep && Options.IsBeepOnBreakpointHit)
 | 
			
		||||
                {
 | 
			
		||||
| 
						 | 
				
			
			@ -163,9 +164,20 @@
 | 
			
		|||
 | 
			
		||||
        private void OperationStateOnStateChanged(object sender, OperationStateChangedEventArgs operationStateChangedEventArgs)
 | 
			
		||||
        {
 | 
			
		||||
            if (Options.IsBuildOnTestComplete && operationStateChangedEventArgs.State.HasFlag(TestOperationStates.TestExecutionFinished))
 | 
			
		||||
            if (Options.IsBeepOnTestComplete && operationStateChangedEventArgs.State.HasFlag(TestOperationStates.TestExecutionFinished))
 | 
			
		||||
            {
 | 
			
		||||
                HandleEventSafe(testCompleteSoundPlayer, "Test execution has been completed.");
 | 
			
		||||
                if (Options.IsBeepOnTestFailed)
 | 
			
		||||
                {
 | 
			
		||||
                    var testOperation = ((TestRunRequest)operationStateChangedEventArgs.Operation);
 | 
			
		||||
                    if (testOperation.DominantTestState == TestState.Failed)
 | 
			
		||||
                    {
 | 
			
		||||
                        HandleEventSafe(testCompleteSoundPlayer, "Test execution failed!");
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    HandleEventSafe(testCompleteSoundPlayer, "Test execution has been completed.");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
| 
						 | 
				
			
			@ -180,7 +192,7 @@
 | 
			
		|||
            var procId = Process.GetCurrentProcess().Id;
 | 
			
		||||
            int activeProcId;
 | 
			
		||||
            GetWindowThreadProcessId(activatedHandle, out activeProcId);
 | 
			
		||||
            return activeProcId == procId;            
 | 
			
		||||
            return activeProcId == procId;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Dispose()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue