Skip to content

Commit

Permalink
- add additional test validation
Browse files Browse the repository at this point in the history
  • Loading branch information
PureWeen committed May 25, 2023
1 parent b3d6747 commit 68be1c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;

Expand Down Expand Up @@ -404,6 +405,12 @@ public async Task ExtraParametersDontGetRetained()
Assert.Equal("1234", testPage.SomeQueryParameter);
Assert.Equal(-1d, testPage.DoubleQueryParameter);
Assert.Null(testPage.ComplexObject);

// ensure that AppliedQueryAttributes is called with correct parameters each time
Assert.Equal(2, testPage.AppliedQueryAttributes.Count);
Assert.Equal(3, testPage.AppliedQueryAttributes[0].Count);
Assert.Equal(1, testPage.AppliedQueryAttributes[1].Count);
Assert.Equal($"{nameof(ShellTestPage.SomeQueryParameter)}", testPage.AppliedQueryAttributes[1].Keys.First());
}

[Fact]
Expand Down
8 changes: 7 additions & 1 deletion src/Controls/tests/Core.UnitTests/ShellTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected ShellSection MakeSimpleShellSection(string route, string contentRoute,
[QueryProperty("SomeQueryParameter", "SomeQueryParameter")]
[QueryProperty("CancelNavigationOnBackButtonPressed", "CancelNavigationOnBackButtonPressed")]
[QueryProperty("ComplexObject", "ComplexObject")]
public class ShellTestPage : ContentPage
public class ShellTestPage : ContentPage, IQueryAttributable
{
public string CancelNavigationOnBackButtonPressed { get; set; }
public ShellTestPage()
Expand Down Expand Up @@ -128,6 +128,12 @@ protected override bool OnBackButtonPressed()

return base.OnBackButtonPressed();
}

public List<IDictionary<string, object>> AppliedQueryAttributes = new List<IDictionary<string, object>>();
public void ApplyQueryAttributes(IDictionary<string, object> query)
{
AppliedQueryAttributes.Add(new Dictionary<string, object>(query));
}
}

protected ShellItem CreateShellItem(
Expand Down

0 comments on commit 68be1c6

Please sign in to comment.