Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Simplfy finding test page attribute.
  • Loading branch information
Rosuavio committed Jun 23, 2021
commit 442db50dd3ffc87724fd252aa60077a613618392
18 changes: 4 additions & 14 deletions UITests/UITests.Tests.Shared/UITestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,12 @@ public async Task TestInitialize()
var theClassName = TestContext.FullyQualifiedTestClassName;
#endif
var currentlyRunningClassType = AppDomain.CurrentDomain.GetAssemblies().SelectMany(a => a.GetTypes()).FirstOrDefault(f => f.FullName == theClassName);
if (!(Type.GetType(theClassName) is Type type))
{
Verify.Fail("Type is null. TestClassName : " + theClassName);
return;
}

if (!(type.GetMethod(testName) is MethodInfo method))
{
Verify.Fail("Mothod is null. TestClassName : " + theClassName + " Testname: " + testName);
return;
}

if (!(method.GetCustomAttribute(typeof(TestPageAttribute), true) is TestPageAttribute attribute))
if (!(Type.GetType(theClassName) is Type type
&& type.GetMethod(testName) is MethodInfo method
&& method.GetCustomAttribute(typeof(TestPageAttribute), true) is TestPageAttribute attribute))
{
Verify.Fail("Attribute is null. TestClassName : " + theClassName);
return;
throw new Exception("Could not find " + nameof(TestPageAttribute) + " on test method.");
}

var pageName = attribute.XamlFile;
Expand Down