-
-
Notifications
You must be signed in to change notification settings - Fork 517
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
namespace Fluent.Tests.Controls | ||
{ | ||
using Fluent.Tests.Helper; | ||
using Fluent.Tests.TestClasses; | ||
using NUnit.Framework; | ||
|
||
[TestFixture] | ||
public class BackstageTests | ||
{ | ||
/// <summary> | ||
/// This test ensures that the <see cref="BackstageAdorner"/> is destroyed as soon as the <see cref="Backstage"/> is unloaded. | ||
/// </summary> | ||
[Test] | ||
public void Adorner_should_be_destroyed_on_unload() | ||
{ | ||
var backstage = new Backstage | ||
{ | ||
Content = new Button() | ||
}; | ||
|
||
using (var window = new TestRibbonWindow(backstage)) | ||
{ | ||
Assert.That(backstage.IsLoaded, Is.True); | ||
|
||
Assert.That(backstage.GetPrivateFieldValue("adorner"), Is.Null); | ||
|
||
backstage.IsOpen = true; | ||
|
||
Assert.That(backstage.GetPrivateFieldValue("adorner"), Is.Not.Null); | ||
|
||
backstage.IsOpen = false; | ||
|
||
Assert.That(backstage.GetPrivateFieldValue("adorner"), Is.Not.Null); | ||
|
||
window.Content = null; | ||
|
||
UIHelper.DoEvents(); | ||
|
||
Assert.That(backstage.GetPrivateFieldValue("adorner"), Is.Null); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{11E74323-57EB-4F25-AB3B-0759B1F978ED}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Fluent.Tests</RootNamespace> | ||
<AssemblyName>Fluent.Tests</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>..\build\bin\NET 4.5\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<CodeAnalysisRuleSet>..\Fluent.Ribbon.ruleset</CodeAnalysisRuleSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>..\build\bin\NET 4.5\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="nunit.framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\NUnit.3.5.0\lib\net45\nunit.framework.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="PresentationCore" /> | ||
<Reference Include="PresentationFramework" /> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> | ||
<Reference Include="System.Xaml" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="WindowsBase" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="..\Shared\GlobalAssemblyInfo.cs"> | ||
<Link>Properties\GlobalAssemblyInfo.cs</Link> | ||
</Compile> | ||
<Compile Include="Controls\BackstageTests.cs" /> | ||
<Compile Include="Helper\ReflectionHelper.cs" /> | ||
<Compile Include="Helper\UIHelper.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="TestClasses\TestRibbonWindow.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Fluent.Ribbon\Fluent.Ribbon.NET 4.5.csproj"> | ||
<Project>{4C92FCF4-3561-499F-BC5B-F2F089863047}</Project> | ||
<Name>Fluent.Ribbon.NET 4.5</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
|
||
namespace Fluent.Tests.Helper | ||
{ | ||
using System.Reflection; | ||
|
||
public static class ReflectionHelper | ||
{ | ||
public static object GetPrivateFieldValue(this object obj, string fieldName) | ||
{ | ||
return GetPrivateFieldInfo(obj.GetType(), fieldName).GetValue(obj); | ||
} | ||
|
||
private static FieldInfo GetPrivateFieldInfo(Type type, string fieldName) | ||
{ | ||
return type.GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace Fluent.Tests.Helper | ||
{ | ||
using System; | ||
using System.Windows.Threading; | ||
|
||
public static class UIHelper | ||
{ | ||
public static void DoEvents() | ||
{ | ||
Dispatcher.CurrentDispatcher.DoEvents(); | ||
} | ||
|
||
public static void DoEvents(this Dispatcher dispatcher) | ||
{ | ||
dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate { })); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System.Reflection; | ||
using System.Threading; | ||
using NUnit.Framework; | ||
|
||
[assembly: AssemblyTitle("Fluent.Ribbon.Tests")] | ||
[assembly: AssemblyDescription("")] | ||
|
||
[assembly: Apartment(ApartmentState.STA)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
namespace Fluent.Tests.TestClasses | ||
{ | ||
using System; | ||
using System.Diagnostics; | ||
|
||
public class TestRibbonWindow : RibbonWindow, IDisposable | ||
{ | ||
public TestRibbonWindow() | ||
: this(null) | ||
{ | ||
} | ||
|
||
public TestRibbonWindow(object content) | ||
{ | ||
this.Content = content; | ||
|
||
this.ShowActivated = false; | ||
this.ShowInTaskbar = false; | ||
|
||
if (Debugger.IsAttached == false) | ||
{ | ||
this.Left = int.MinValue; | ||
this.Top = int.MinValue; | ||
} | ||
|
||
this.Show(); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
this.Close(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="NUnit" version="3.5.0" targetFramework="net45" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters