Skip to content

Commit

Permalink
Add WUX exceptions unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Aug 6, 2024
1 parent d8e1765 commit 76d2e8e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Tests/AuthoringWuxConsumptionTest/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ TEST(AuthoringWuxTest, PropertyChanged)
EXPECT_TRUE(eventTriggered);
}

TEST(AuthoringWuxTest, XamlExceptionTypes)
{
EXPECT_TRUE(XamlExceptionTypes::VerifyExceptionTypes());
}

int main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
Expand Down
18 changes: 18 additions & 0 deletions src/Tests/AuthoringWuxTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using WinRT;

#pragma warning disable CA1416

Expand Down Expand Up @@ -168,4 +169,21 @@ void IList.RemoveAt(int index)
_list.RemoveAt(index);
}
}

public static class XamlExceptionTypes
{
public static bool VerifyExceptionTypes()
{
const int E_XAMLPARSEFAILED = unchecked((int)0x802B000A);
const int E_LAYOUTCYCLE = unchecked((int)0x802B0014);
const int E_ELEMENTNOTENABLED = unchecked((int)0x802B001E);
const int E_ELEMENTNOTAVAILABLE = unchecked((int)0x802B001F);

return
ExceptionHelpers.GetExceptionForHR(E_XAMLPARSEFAILED)?.GetType() == typeof(Windows.UI.Xaml.Markup.XamlParseException) &&
ExceptionHelpers.GetExceptionForHR(E_LAYOUTCYCLE)?.GetType() == typeof(Windows.UI.Xaml.LayoutCycleException) &&
ExceptionHelpers.GetExceptionForHR(E_ELEMENTNOTENABLED)?.GetType() == typeof(Windows.UI.Xaml.Automation.ElementNotEnabledException) &&
ExceptionHelpers.GetExceptionForHR(E_ELEMENTNOTAVAILABLE)?.GetType() == typeof(Windows.UI.Xaml.Automation.ElementNotAvailableException);
}
}
}

0 comments on commit 76d2e8e

Please sign in to comment.