Skip to content

Instantly share code, notes, and snippets.

public class ViewNavigationService : INavigationService
{
private readonly object _sync = new object();
private readonly Dictionary<string, Type> _pagesByKey = new Dictionary<string, Type>();
private readonly Stack<NavigationPage> _navigationPageStack =
new Stack<NavigationPage>();
private NavigationPage CurrentNavigationPage => _navigationPageStack.Peek();
public void Configure(string pageKey, Type pageType)
{
public interface INavigationService
{
string CurrentPageKey { get; }
void Configure(string pageKey, Type pageType);
Task GoBack();
Task NavigateModalAsync(string pageKey, bool animated = true);
Task NavigateModalAsync(string pageKey, object parameter, bool animated = true);
Task NavigateAsync(string pageKey, bool animated = true);
Task NavigateAsync(string pageKey, object parameter, bool animated = true);
public partial class App : Application
{
public App()
{
InitializeComponent();
var mainPage = new NavigationPage(new MainPage());
MainPage = mainPage;
}
// ....
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.6</TargetFramework>
<PackageTargetFallback>$(PackageTargetFallback);portable-win+net45+wp8+win81+wpa8</PackageTargetFallback>
</PropertyGroup>
</Project>
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
. "$here\$sut"
$mockReply = @("Monday.txt", "Tuesday.txt", "Wednesday.txt")
Describe "HasEntryInDirectory" {
Context "If the filename exists in the directory" {
Mock Get-ChildItem {return $mockReply}
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
. "$here\$sut"
$mockReply = @("Monday.txt", "Tuesday.txt", "Wednesday.txt")
Describe "HasEntryInDirectory" {
Context "If the filename exists in the directory" {
Mock Get-ChildItem {return $mockReply}
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
. "$here\$sut"
$mockReply = @("Monday.txt", "Tuesday.txt", "Wednesday.txt")
Describe "HasEntryInDirectory" {
Context "If the filename exists in the directory" {
Mock Get-ChildItem {return $mockReply}
function HasEntryInDirectory($filename, $path) {
$entries = Get-ChildItem -Path $path
$entries -contains $filename
}
using System;
using System.IO;
using System.Linq;
using Moq;
using Xunit;
namespace CSharpSample
{
public interface IDirectory
{
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
. "$here\$sut"
Describe "IsEvenNumber" {
Context "When an even number is passed to the function" {
$result = IsEvenNumber(42)
It "Returns true" {