Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prism v9.0.271-pre Navigation Region Tests #138

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Upgrading-Prism.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ As we all know, not everything is straight forward between these two XAML techno
### Changes

* `Samples` folder renamed to `e2e`
* Prism.Dialogs - _See section for more info_
* Prism.Dialogs
* _Various updates, see section before for more info_
* `NavigationResult` returns the property `Success` instead of `Result`

#### Dialogs

Expand Down Expand Up @@ -112,6 +114,13 @@ As we all know, not everything is straight forward between these two XAML techno
| RegionManagerRequestNavigateFixture.cs
| RegionViewRegistryFixture.cs

### Future Feature Work To Add

| Project | Class |
|-|-|
| Prism.Avalonia.Tests | ItemsControlRegionAdapterFixture
| Prism.Avalonia.Tests | SelectorRegionAdapterFixture

## Upgrading from Prism 7.2 to 8.1

* Basis of comparison: [Prism Library v7.2.0.1422...v8.1.97](https://github.com/PrismLibrary/Prism/compare/v7.2.0.1422...v8.1.97)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ private static void ClearChildViews(IRegion region)
{
foreach (var view in region.Views)
{
AvaloniaObject dependencyObject = view as AvaloniaObject;
if (dependencyObject != null)
AvaloniaObject avaloniaObject = view as AvaloniaObject;
if (avaloniaObject != null)
{
if (GetClearChildViews(dependencyObject))
if (GetClearChildViews(avaloniaObject))
{
dependencyObject.ClearValue(RegionManager.RegionManagerProperty);
avaloniaObject.ClearValue(RegionManager.RegionManagerProperty);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public AvaloniaObject HostControl
{
throw new InvalidOperationException(Resources.HostControlCannotBeSetAfterAttach);
}

hostControl = value;
}
}
Expand Down Expand Up @@ -126,16 +127,16 @@ public void OnUpdatingRegions(object sender, EventArgs e)
TryRegisterRegion();
}

private IRegionManager FindRegionManager(AvaloniaObject dependencyObject)
private IRegionManager FindRegionManager(AvaloniaObject avaloniaObject)
{
var regionmanager = RegionManagerAccessor.GetRegionManager(dependencyObject);
var regionmanager = RegionManagerAccessor.GetRegionManager(avaloniaObject);
if (regionmanager != null)
{
return regionmanager;
}

//TODO: this is should be ok in Avalonia. I have to test it
AvaloniaObject parent = ((dependencyObject as Visual)?.GetVisualParent() ?? null) as AvaloniaObject;
AvaloniaObject parent = ((avaloniaObject as Visual)?.GetVisualParent() ?? null) as AvaloniaObject;
if (parent != null)
{
return FindRegionManager(parent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Data;
using System.Windows.Controls.Primitives;
using Avalonia.Controls.Primitives;

namespace Prism.Navigation.Regions.Behaviors
{
Expand Down
2 changes: 1 addition & 1 deletion src/Prism.Avalonia/Navigation/Regions/Region.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ protected virtual ObservableCollection<ItemMetadata> ItemMetadataCollection
/// <overloads>Adds a new view to the region.</overloads>
/// <summary>Adds a new view to the region.</summary>
/// <param name="viewName">The view to add.</param>
/// <returns>The <see cref="IRegionManager"/> that is set on the view if it is a <see cref="DependencyObject"/>. It will be the current region manager when using this overload.</returns>
/// <returns>The <see cref="IRegionManager"/> that is set on the view if it is a <see cref="AvaloniaObject"/>. It will be the current region manager when using this overload.</returns>
public IRegionManager Add(string viewName)
{
var view = ContainerLocator.Container.Resolve<object>(viewName);
Expand Down
148 changes: 0 additions & 148 deletions tests/Avalonia/Prism.Avalonia.Tests/ExceptionExtensionsFixture.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using Avalonia;
using Avalonia;

namespace Prism.Avalonia.Tests.Mocks
{
/// <summary>MockAvaloniaObject.</summary>
/// <remarks>TODO: Rename to MockAvaloniaObject.</remarks>
public class MockDependencyObject : AvaloniaObject
{
}
Expand Down
21 changes: 10 additions & 11 deletions tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockPresentationRegion.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.ComponentModel;
using System.ComponentModel;

namespace Prism.Avalonia.Tests.Mocks
{
Expand All @@ -11,6 +11,9 @@ public MockPresentationRegion()
{
Behaviors = new MockRegionBehaviorCollection();
}

public IRegionManager Add(string viewName) => throw new NotImplementedException();

public IRegionManager Add(object view)
{
MockViews.Items.Add(view);
Expand Down Expand Up @@ -74,7 +77,7 @@ public object Context
}
}

public NavigationParameters NavigationParameters
public INavigationParameters NavigationParameters
{
get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); }
Expand All @@ -83,22 +86,19 @@ public NavigationParameters NavigationParameters
private string name;
public string Name
{
get { return this.name; }
get { return name; }
set
{
this.name = value;
this.OnPropertyChange("Name");
name = value;
OnPropertyChange("Name");
}
}

public event PropertyChangedEventHandler PropertyChanged;

public void OnPropertyChange(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

public bool Navigate(Uri source)
Expand All @@ -111,7 +111,7 @@ public void RequestNavigate(Uri target, Action<NavigationResult> navigationCallb
throw new NotImplementedException();
}

public void RequestNavigate(Uri target, Action<NavigationResult> navigationCallback, NavigationParameters navigationParameters)
public void RequestNavigate(Uri target, Action<NavigationResult> navigationCallback, INavigationParameters navigationParameters)
{
throw new NotImplementedException();
}
Expand All @@ -127,7 +127,6 @@ public IRegionNavigationService NavigationService
set { throw new System.NotImplementedException(); }
}


public Comparison<object> SortComparison
{
get
Expand Down
8 changes: 5 additions & 3 deletions tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegion.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.ComponentModel;
using System.ComponentModel;

namespace Prism.Avalonia.Tests.Mocks
{
Expand Down Expand Up @@ -26,14 +26,16 @@ public object Context
set { throw new System.NotImplementedException(); }
}

public NavigationParameters NavigationParameters
public INavigationParameters NavigationParameters
{
get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); }
}

public string Name { get; set; }

public IRegionManager Add(string viewName) => throw new NotImplementedException();

public IRegionManager Add(object view)
{
this.views.Add(view);
Expand Down Expand Up @@ -87,7 +89,7 @@ public void RequestNavigate(System.Uri target, System.Action<NavigationResult> n
throw new System.NotImplementedException();
}

public void RequestNavigate(System.Uri target, System.Action<NavigationResult> navigationCallback, NavigationParameters navigationParameters)
public void RequestNavigate(System.Uri target, System.Action<NavigationResult> navigationCallback, INavigationParameters navigationParameters)
{
throw new System.NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Avalonia;
using Avalonia;

namespace Prism.Avalonia.Tests.Mocks
{
Expand Down
12 changes: 6 additions & 6 deletions tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections;
using System.Collections;

namespace Prism.Avalonia.Tests.Mocks
{
Expand Down Expand Up @@ -33,7 +33,7 @@ public IRegionManager RegisterViewWithRegion(string regionName, Type viewType)
throw new NotImplementedException();
}

public IRegionManager RegisterViewWithRegion(string regionName, Func<object> getContentDelegate)
public IRegionManager RegisterViewWithRegion(string regionName, Func<IContainerProvider, object> getContentDelegate)
{
throw new NotImplementedException();
}
Expand All @@ -58,22 +58,22 @@ public void RequestNavigate(string regionName, string source)
throw new NotImplementedException();
}

public void RequestNavigate(string regionName, Uri target, Action<NavigationResult> navigationCallback, NavigationParameters navigationParameters)
public void RequestNavigate(string regionName, Uri target, Action<NavigationResult> navigationCallback, INavigationParameters navigationParameters)
{
throw new NotImplementedException();
}

public void RequestNavigate(string regionName, string target, Action<NavigationResult> navigationCallback, NavigationParameters navigationParameters)
public void RequestNavigate(string regionName, string target, Action<NavigationResult> navigationCallback, INavigationParameters navigationParameters)
{
throw new NotImplementedException();
}

public void RequestNavigate(string regionName, Uri target, NavigationParameters navigationParameters)
public void RequestNavigate(string regionName, Uri target, INavigationParameters navigationParameters)
{
throw new NotImplementedException();
}

public void RequestNavigate(string regionName, string target, NavigationParameters navigationParameters)
public void RequestNavigate(string regionName, string target, INavigationParameters navigationParameters)
{
throw new NotImplementedException();
}
Expand Down
Loading