| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- using Avalonia.UnitTests;
- using Xunit;
- namespace Avalonia.Controls.UnitTests;
- public class NavigationEventArgsTests
- {
- public class NavigatedToEventArgsTests : ScopedTestBase
- {
- [Fact]
- public void Properties_RoundTrip()
- {
- var prev = new ContentPage { Header = "Prev" };
- var args = new NavigatedToEventArgs(prev, NavigationType.Push);
- Assert.Same(prev, args.PreviousPage);
- Assert.Equal(NavigationType.Push, args.NavigationType);
- }
- [Fact]
- public void NullPreviousPage_IsAllowed()
- {
- var args = new NavigatedToEventArgs(null, NavigationType.PopToRoot);
- Assert.Null(args.PreviousPage);
- }
- }
- public class NavigatedFromEventArgsTests : ScopedTestBase
- {
- [Fact]
- public void Properties_RoundTrip()
- {
- var dest = new ContentPage { Header = "Dest" };
- var args = new NavigatedFromEventArgs(dest, NavigationType.Pop);
- Assert.Same(dest, args.DestinationPage);
- Assert.Equal(NavigationType.Pop, args.NavigationType);
- }
- }
- public class NavigatingFromEventArgsTests : ScopedTestBase
- {
- [Fact]
- public void Cancel_DefaultIsFalse()
- {
- var args = new NavigatingFromEventArgs(null, NavigationType.Push);
- Assert.False(args.Cancel);
- }
- [Fact]
- public void Cancel_CanBeSetTrue()
- {
- var args = new NavigatingFromEventArgs(null, NavigationType.Push) { Cancel = true };
- Assert.True(args.Cancel);
- }
- }
- public class NavigationEventArgsConstructionTests : ScopedTestBase
- {
- [Fact]
- public void Properties_RoundTrip()
- {
- var page = new ContentPage();
- var args = new NavigationEventArgs(page, NavigationType.Push);
- Assert.Same(page, args.Page);
- Assert.Equal(NavigationType.Push, args.NavigationType);
- }
- }
- public class ModalPushedEventArgsTests : ScopedTestBase
- {
- [Fact]
- public void Properties_RoundTrip()
- {
- var modal = new ContentPage();
- var args = new ModalPushedEventArgs(modal);
- Assert.Same(modal, args.Modal);
- }
- }
- public class ModalPoppedEventArgsTests : ScopedTestBase
- {
- [Fact]
- public void Properties_RoundTrip()
- {
- var modal = new ContentPage();
- var args = new ModalPoppedEventArgs(modal);
- Assert.Same(modal, args.Modal);
- }
- }
- public class PageSelectionChangedEventArgsTests : ScopedTestBase
- {
- [Fact]
- public void Properties_RoundTrip()
- {
- var prev = new ContentPage { Header = "Tab 1" };
- var current = new ContentPage { Header = "Tab 2" };
- var args = new PageSelectionChangedEventArgs(SelectingMultiPage.SelectionChangedEvent, prev, current);
- Assert.Same(prev, args.PreviousPage);
- Assert.Same(current, args.CurrentPage);
- }
- }
- public class NavigationTypeEnumTests : ScopedTestBase
- {
- [Fact]
- public void AllValuesAreDefined()
- {
- var values = System.Enum.GetValues<NavigationType>();
- Assert.Contains(NavigationType.Push, values);
- Assert.Contains(NavigationType.Pop, values);
- Assert.Contains(NavigationType.PopToRoot, values);
- Assert.Contains(NavigationType.Insert, values);
- Assert.Contains(NavigationType.Remove, values);
- Assert.Contains(NavigationType.Replace, values);
- }
- }
- }
|