Skip to content

Commit

Permalink
Setup to add back usage of the Extensions in tests via source package…
Browse files Browse the repository at this point in the history
… helper (test)

Add back some of the removed tests to the test project for extensions
Adds nuget.config
  • Loading branch information
michael-hawker committed Apr 5, 2023
1 parent 1345a23 commit 78a440c
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 10 deletions.
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<RepositoryDirectory>$(MSBuildThisFileDirectory)</RepositoryDirectory>
<ToolingDirectory>$(RepositoryDirectory)\tooling</ToolingDirectory>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<ToolkitExtensionSourceProject>$(RepositoryDirectory)\components\Extensions\src\CommunityToolkit.WinUI.Extensions.csproj</ToolkitExtensionSourceProject>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:ExtensionsExperiment.Tests"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="using:CommunityToolkit.WinUI"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d">

Expand Down
6 changes: 3 additions & 3 deletions components/Extensions/tests/BitmapIconExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using CommunityToolkit.Tests;
using CommunityToolkit.Tooling.TestGen;
using CommunityToolkit.WinUI;
using ExtensionsExperiment.Tests;

namespace ExtensionsComponent.Tests;
Expand All @@ -15,8 +16,7 @@ public partial class BitmapIconExtensionTests : VisualUITestBase
[UIThreadTestMethod]
public void BitmapIconExtension_MarkupExtension_ProvideImage(BitmapIconExtensionTestPage page)
{
// TODO: Temp until we get a package for this.
var button = CommunityToolkit.WinUI.DependencyObjectExtensions.FindDescendant(page, "ColorButton") as Button;
var button = page.FindDescendant("ColorButton") as Button;

Assert.IsNotNull(button, $"Could not find the {nameof(Button)} control in tree.");

Expand All @@ -37,7 +37,7 @@ public void BitmapIconExtension_MarkupExtension_ProvideImage(BitmapIconExtension
public void BitmapIconExtension_MarkupExtension_ProvideImageAsMonochrome(BitmapIconExtensionTestPage page)
{
// TODO: Temp until we get a package for this.
var button = CommunityToolkit.WinUI.DependencyObjectExtensions.FindDescendant(page, "MonochromeButton") as Button;
var button = page.FindDescendant("MonochromeButton") as Button;

Assert.IsNotNull(button, $"Could not find the {nameof(Button)} control in tree.");

Expand Down
9 changes: 5 additions & 4 deletions components/Extensions/tests/DispatcherQueueExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if WINAPPSDK
using CommunityToolkit.Tests;
using CommunityToolkit.Tooling.TestGen;
using CommunityToolkit.WinUI;

#if WINAPPSDK
using DispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue;
using DispatcherQueuePriority = Microsoft.UI.Dispatching.DispatcherQueuePriority;
#else
Expand Down Expand Up @@ -48,7 +49,7 @@ public void Test_DispatcherQueueHelper_Action_Ok_UIThread()
[TestMethod]
public async Task Test_DispatcherQueueHelper_Action_Ok_NonUIThread()
{
var taskSource = new TaskCompletionSource<object>();
var taskSource = new TaskCompletionSource<object?>();
await App.DispatcherQueue.EnqueueAsync(
async () =>
{
Expand Down Expand Up @@ -118,7 +119,7 @@ public void Test_DispatcherQueueHelper_FuncOfT_Ok_UIThread()
[TestMethod]
public async Task Test_DispatcherQueueHelper_FuncOfT_Ok_NonUIThread()
{
var taskSource = new TaskCompletionSource<object>();
var taskSource = new TaskCompletionSource<object?>();
await App.DispatcherQueue.EnqueueAsync(
async () =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if WINAPPSDK
using CommunityToolkit.Tests;
using CommunityToolkit.Tooling.TestGen;
using CommunityToolkit.WinUI;

#if WINAPPSDK
using DispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue;
using DispatcherQueuePriority = Microsoft.UI.Dispatching.DispatcherQueuePriority;
using DispatcherQueueTimer = Microsoft.UI.Dispatching.DispatcherQueueTimer;
Expand Down
12 changes: 12 additions & 0 deletions components/Extensions/tests/Extensions.Tests.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@
<Import_RootNamespace>ExtensionsExperiment.Tests</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)BitmapIconExtensionTestPage.xaml.cs">
<DependentUpon>BitmapIconExtensionTestPage.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)BitmapIconExtensionTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DispatcherQueueExtensionTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DispatcherQueueTimerExtensionTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helpers\ObjectWithNullableBoolProperty.cs" />
</ItemGroup>
<ItemGroup>
<Page Include="$(MSBuildThisFileDirectory)BitmapIconExtensionTestPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
</Project>
10 changes: 10 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="MainLatest" value="https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-MainLatest/nuget/v3/index.json" protocolVersion="3" />
</packageSources>
<disabledPackageSources>
<clear />
</disabledPackageSources>
</configuration>

0 comments on commit 78a440c

Please sign in to comment.