Skip to content

Commit 1156abb

Browse files
committed
Added & modified unit tests (#2013)
1 parent 1612ccb commit 1156abb

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

src/Controls/tests/Core.UnitTests/NavigationProxyTests.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Collections.Generic;
23
using System.Linq;
34
using System.Threading.Tasks;
@@ -99,17 +100,28 @@ public void Constructor()
99100
}
100101

101102
[Fact]
102-
public async Task PushesIntoNextInner()
103+
public async Task PushesWithoutInner()
103104
{
104105
var page = new ContentPage();
105106
var navProxy = new NavigationProxy();
106107

107-
await navProxy.PushAsync(page);
108+
Assert.ThrowsAsync<InvalidOperationException>(async () => await navProxy.PushAsync(page));
109+
}
108110

109-
var navTest = new NavigationTest();
110-
navProxy.Inner = navTest;
111+
[Fact]
112+
public async Task PushesIntoNextInner()
113+
{
114+
var proxy = new NavigationProxy();
115+
var inner = new NavigationTest();
116+
var page1 = new ContentPage();
117+
var page2 = new ContentPage();
118+
119+
proxy.Inner = inner;
120+
121+
await proxy.PushAsync(page1);
122+
await proxy.PushAsync(page2);
111123

112-
Assert.Equal(page, navTest.LastPushed);
124+
Assert.Equal(page2, inner.LastPushed);
113125
}
114126

115127
[Fact]

src/Controls/tests/Core.UnitTests/NavigationUnitTest.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,15 @@ public async Task PopModalWithEmptyStackThrows()
839839
Assert.ThrowsAsync<InvalidOperationException>(() => window.Navigation.PopModalAsync());
840840
}
841841

842+
[Fact]
843+
public async Task PushWithoutWrappingIntoNavigationPage()
844+
{
845+
var window = new TestWindow(new ContentPage());
846+
var contentPage1 = new ContentPage();
847+
var navigationPage = new TestNavigationPage(true, contentPage1);
848+
Assert.ThrowsAsync<InvalidOperationException>(() => window.Navigation.PushAsync(contentPage1));
849+
}
850+
842851
[Fact]
843852
public async Task TabBarSetsOnFlyoutPageInsideModalPage()
844853
{

0 commit comments

Comments
 (0)