Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaned up redundant or empty tests #348

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion components/Behaviors/tests/Behaviors.Tests.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<Import_RootNamespace>BehaviorsExperiment.Tests</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)ExampleBehaviorsTestClass.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ExampleBehaviorsTestPage.xaml.cs">
<DependentUpon>ExampleBehaviorsTestPage.xaml</DependentUpon>
</Compile>
Expand Down
41 changes: 0 additions & 41 deletions components/Behaviors/tests/ExampleBehaviorsTestClass.cs

This file was deleted.

11 changes: 0 additions & 11 deletions components/Behaviors/tests/ExampleBehaviorsTestPage.xaml

This file was deleted.

16 changes: 0 additions & 16 deletions components/Behaviors/tests/ExampleBehaviorsTestPage.xaml.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,95 +10,13 @@ namespace HeaderedControls.Tests;
[TestClass]
public partial class HeaderedContentControlTestClass : VisualUITestBase
{
// If you don't need access to UI objects directly or async code, use this pattern.
[TestMethod]
public void SimpleSynchronousExampleTest()
{
var assembly = typeof(HeaderedContentControl).Assembly;
var type = assembly.GetType(typeof(HeaderedContentControl).FullName ?? string.Empty);

Assert.IsNotNull(type, "Could not find HeaderedContentControl type.");
Assert.AreEqual(typeof(HeaderedContentControl), type, "Type of HeaderedContentControl does not match expected type.");
}

// The UIThreadTestMethod can also easily grab a XAML Page for us by passing its type as a parameter.
// This lets us actually test a control as it would behave within an actual application.
// The page will already be loaded by the time your test is called.
[UIThreadTestMethod]
public void SimpleUIExamplePageTest(HeaderedContentControlTestPage page)
{
// You can use the Toolkit Visual Tree helpers here to find the component by type or name:
var component = page.FindDescendant<HeaderedContentControl>();

Assert.IsNotNull(component);

var componentByName = page.FindDescendant("HeaderedContentControl");

Assert.IsNotNull(componentByName);
}

// You can still do async work with a UIThreadTestMethod as well.
[UIThreadTestMethod]
public async Task SimpleAsyncUIExamplePageTest(HeaderedContentControlTestPage page)
{
// This helper can be used to wait for a rendering pass to complete.
await CompositionTargetHelper.ExecuteAfterCompositionRenderingAsync(() => { });

var component = page.FindDescendant<HeaderedContentControl>();

Assert.IsNotNull(component);
}

//// ----------------------------- ADVANCED TEST SCENARIOS -----------------------------

// If you need to use DataRow, you can use this pattern with the UI dispatch still.
// Otherwise, checkout the UIThreadTestMethod attribute above.
// See https://github.com/CommunityToolkit/Labs-Windows/issues/186
[TestMethod]
public async Task ComplexAsyncUIExampleTest()
{
await EnqueueAsync(() =>
{
var component = new HeaderedContentControl();
Assert.IsNotNull(component);
});
}

// If you want to load other content not within a XAML page using the UIThreadTestMethod above.
// Then you can do that using the Load/UnloadTestContentAsync methods.
[TestMethod]
public async Task ComplexAsyncLoadUIExampleTest()
{
await EnqueueAsync(async () =>
{
var component = new HeaderedContentControl();
Assert.IsNotNull(component);
Assert.IsFalse(component.IsLoaded);

await LoadTestContentAsync(component);

Assert.IsTrue(component.IsLoaded);

await UnloadTestContentAsync(component);

Assert.IsFalse(component.IsLoaded);
});
}

// You can still use the UIThreadTestMethod to remove the extra layer for the dispatcher as well:
[UIThreadTestMethod]
public async Task ComplexAsyncLoadUIExampleWithoutDispatcherTest()
{
var component = new HeaderedContentControl();
Assert.IsNotNull(component);
Assert.IsFalse(component.IsLoaded);

await LoadTestContentAsync(component);

Assert.IsTrue(component.IsLoaded);

await UnloadTestContentAsync(component);

Assert.IsFalse(component.IsLoaded);
}
}
93 changes: 0 additions & 93 deletions components/HeaderedControls/tests/HeaderedItemsControlTestClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,103 +10,10 @@ namespace HeaderedControls.Tests;
[TestClass]
public partial class HeaderedItemsControlTestClass : VisualUITestBase
{
// If you don't need access to UI objects directly or async code, use this pattern.
[TestMethod]
public void SimpleSynchronousExampleTest()
{
var assembly = typeof(HeaderedItemsControl).Assembly;
var type = assembly.GetType(typeof(HeaderedItemsControl).FullName ?? string.Empty);

Assert.IsNotNull(type, "Could not find HeaderedItemsControl type.");
Assert.AreEqual(typeof(HeaderedItemsControl), type, "Type of HeaderedItemsControl does not match expected type.");
}

// The UIThreadTestMethod automatically dispatches to the UI for us to work with UI objects.
[UIThreadTestMethod]
public void SimpleUIAttributeExampleTest()
{
var component = new HeaderedItemsControl();
Assert.IsNotNull(component);
}

// The UIThreadTestMethod can also easily grab a XAML Page for us by passing its type as a parameter.
// This lets us actually test a control as it would behave within an actual application.
// The page will already be loaded by the time your test is called.
[UIThreadTestMethod]
public void SimpleUIExamplePageTest(HeaderedItemsControlTestPage page)
{
// You can use the Toolkit Visual Tree helpers here to find the component by type or name:
var component = page.FindDescendant<HeaderedItemsControl>();

Assert.IsNotNull(component);

var componentByName = page.FindDescendant("HeaderedItemsControl");

Assert.IsNotNull(componentByName);
}

// You can still do async work with a UIThreadTestMethod as well.
[UIThreadTestMethod]
public async Task SimpleAsyncUIExamplePageTest(HeaderedItemsControlTestPage page)
{
// This helper can be used to wait for a rendering pass to complete.
await CompositionTargetHelper.ExecuteAfterCompositionRenderingAsync(() => { });

var component = page.FindDescendant<HeaderedItemsControl>();

Assert.IsNotNull(component);
}

//// ----------------------------- ADVANCED TEST SCENARIOS -----------------------------

// If you need to use DataRow, you can use this pattern with the UI dispatch still.
// Otherwise, checkout the UIThreadTestMethod attribute above.
// See https://github.com/CommunityToolkit/Labs-Windows/issues/186
[TestMethod]
public async Task ComplexAsyncUIExampleTest()
{
await EnqueueAsync(() =>
{
var component = new HeaderedItemsControl();
Assert.IsNotNull(component);
});
}

// If you want to load other content not within a XAML page using the UIThreadTestMethod above.
// Then you can do that using the Load/UnloadTestContentAsync methods.
[TestMethod]
public async Task ComplexAsyncLoadUIExampleTest()
{
await EnqueueAsync(async () =>
{
var component = new HeaderedItemsControl();
Assert.IsNotNull(component);
Assert.IsFalse(component.IsLoaded);

await LoadTestContentAsync(component);

Assert.IsTrue(component.IsLoaded);

await UnloadTestContentAsync(component);

Assert.IsFalse(component.IsLoaded);
});
}

// You can still use the UIThreadTestMethod to remove the extra layer for the dispatcher as well:
[UIThreadTestMethod]
public async Task ComplexAsyncLoadUIExampleWithoutDispatcherTest()
{
var component = new HeaderedItemsControl();
Assert.IsNotNull(component);
Assert.IsFalse(component.IsLoaded);

await LoadTestContentAsync(component);

Assert.IsTrue(component.IsLoaded);

await UnloadTestContentAsync(component);

Assert.IsFalse(component.IsLoaded);
}
}
93 changes: 0 additions & 93 deletions components/HeaderedControls/tests/HeaderedTreeViewTestClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,103 +10,10 @@ namespace HeaderedControls.Tests;
[TestClass]
public partial class HeaderedTreeViewTestClass : VisualUITestBase
{
// If you don't need access to UI objects directly or async code, use this pattern.
[TestMethod]
public void SimpleSynchronousExampleTest()
{
var assembly = typeof(HeaderedTreeView).Assembly;
var type = assembly.GetType(typeof(HeaderedTreeView).FullName ?? string.Empty);

Assert.IsNotNull(type, "Could not find HeaderedTreeView type.");
Assert.AreEqual(typeof(HeaderedTreeView), type, "Type of HeaderedTreeView does not match expected type.");
}

// The UIThreadTestMethod automatically dispatches to the UI for us to work with UI objects.
[UIThreadTestMethod]
public void SimpleUIAttributeExampleTest()
{
var component = new HeaderedTreeView();
Assert.IsNotNull(component);
}

// The UIThreadTestMethod can also easily grab a XAML Page for us by passing its type as a parameter.
// This lets us actually test a control as it would behave within an actual application.
// The page will already be loaded by the time your test is called.
[UIThreadTestMethod]
public void SimpleUIExamplePageTest(HeaderedTreeViewTestPage page)
{
// You can use the Toolkit Visual Tree helpers here to find the component by type or name:
var component = page.FindDescendant<HeaderedTreeView>();

Assert.IsNotNull(component);

var componentByName = page.FindDescendant("HeaderedTreeView");

Assert.IsNotNull(componentByName);
}

// You can still do async work with a UIThreadTestMethod as well.
[UIThreadTestMethod]
public async Task SimpleAsyncUIExamplePageTest(HeaderedTreeViewTestPage page)
{
// This helper can be used to wait for a rendering pass to complete.
await CompositionTargetHelper.ExecuteAfterCompositionRenderingAsync(() => { });

var component = page.FindDescendant<HeaderedTreeView>();

Assert.IsNotNull(component);
}

//// ----------------------------- ADVANCED TEST SCENARIOS -----------------------------

// If you need to use DataRow, you can use this pattern with the UI dispatch still.
// Otherwise, checkout the UIThreadTestMethod attribute above.
// See https://github.com/CommunityToolkit/Labs-Windows/issues/186
[TestMethod]
public async Task ComplexAsyncUIExampleTest()
{
await EnqueueAsync(() =>
{
var component = new HeaderedTreeView();
Assert.IsNotNull(component);
});
}

// If you want to load other content not within a XAML page using the UIThreadTestMethod above.
// Then you can do that using the Load/UnloadTestContentAsync methods.
[TestMethod]
public async Task ComplexAsyncLoadUIExampleTest()
{
await EnqueueAsync(async () =>
{
var component = new HeaderedTreeView();
Assert.IsNotNull(component);
Assert.IsFalse(component.IsLoaded);

await LoadTestContentAsync(component);

Assert.IsTrue(component.IsLoaded);

await UnloadTestContentAsync(component);

Assert.IsFalse(component.IsLoaded);
});
}

// You can still use the UIThreadTestMethod to remove the extra layer for the dispatcher as well:
[UIThreadTestMethod]
public async Task ComplexAsyncLoadUIExampleWithoutDispatcherTest()
{
var component = new HeaderedTreeView();
Assert.IsNotNull(component);
Assert.IsFalse(component.IsLoaded);

await LoadTestContentAsync(component);

Assert.IsTrue(component.IsLoaded);

await UnloadTestContentAsync(component);

Assert.IsFalse(component.IsLoaded);
}
}
Loading
Loading