ApplicationTests.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright (c) The Avalonia Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using System;
  4. using System.Collections.Generic;
  5. using Avalonia.Threading;
  6. using Avalonia.UnitTests;
  7. using Xunit;
  8. namespace Avalonia.Controls.UnitTests
  9. {
  10. public class ApplicationTests
  11. {
  12. [Fact]
  13. public void Throws_ArgumentNullException_On_Run_If_MainWindow_Is_Null()
  14. {
  15. using (UnitTestApplication.Start(TestServices.StyledWindow))
  16. {
  17. Assert.Throws<ArgumentNullException>(() => { Application.Current.Run(null); });
  18. }
  19. }
  20. [Fact]
  21. public void Raises_ResourcesChanged_When_Event_Handler_Added_After_Resources_Has_Been_Accessed()
  22. {
  23. // Test for #1765.
  24. using (UnitTestApplication.Start())
  25. {
  26. var resources = Application.Current.Resources;
  27. var raised = false;
  28. Application.Current.ResourcesChanged += (s, e) => raised = true;
  29. resources["foo"] = "bar";
  30. Assert.True(raised);
  31. }
  32. }
  33. }
  34. }