Browse Source

Add NullArgumentException for Run with main window

pull/1662/head
Benedikt Schroeder 8 years ago
parent
commit
7e8f9fbf61
  1. 8
      src/Avalonia.Controls/Application.cs
  2. 12
      tests/Avalonia.Controls.UnitTests/ApplicationTests.cs

8
src/Avalonia.Controls/Application.cs

@ -243,14 +243,14 @@ namespace Avalonia
Dispatcher.UIThread.InvokeAsync(
() =>
{
if (mainWindow == null)
if (MainWindow != null)
{
return;
}
if (MainWindow != null)
if (mainWindow == null)
{
return;
throw new ArgumentNullException(nameof(mainWindow));
}
if (!mainWindow.IsVisible)
@ -283,7 +283,7 @@ namespace Avalonia
if (!IsExiting)
{
OnExit?.Invoke(this, EventArgs.Empty);
}
}
}
/// <summary>

12
tests/Avalonia.Controls.UnitTests/ApplicationTests.cs

@ -1,6 +1,7 @@
// Copyright (c) The Avalonia Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Collections.Generic;
using Avalonia.UnitTests;
using Xunit;
@ -103,5 +104,14 @@ namespace Avalonia.Controls.UnitTests
Assert.Empty(Application.Current.Windows);
}
}
[Fact]
public void Throws_ArgumentNullException_On_Run_If_MainWindow_Is_Null()
{
using (UnitTestApplication.Start(TestServices.StyledWindow))
{
Assert.Throws<ArgumentNullException>(() => { Application.Current.Run(null); });
}
}
}
}
}
Loading…
Cancel
Save