本文整理汇总了C#中Context.NavigateTo方法的典型用法代码示例。如果您正苦于以下问题:C# Context.NavigateTo方法的具体用法?C# Context.NavigateTo怎么用?C# Context.NavigateTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context.NavigateTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PropertiesPopulatedWhenNavigatedTo
public void PropertiesPopulatedWhenNavigatedTo()
{
using (var context = new Context())
{
context.Cafes.Add(
new Cafe
{
Id = "1",
Name = "Cafe A",
Address = "1 Main Street",
PostCode = "A1 11A",
Latitude = 15,
Longitude = -10,
CoffeeRating = 3.5,
AtmosphereRating = 4.75,
NumberOfVotes = 200
});
context.NavigateTo(cafeId: "1");
Assert.AreEqual("Cafe A", context.ViewModel.Name, "Name");
Assert.AreEqual("1 Main Street, A1 11A", context.ViewModel.Address, "Address");
Assert.AreEqual(15, context.ViewModel.Latitude, "Latitude");
Assert.AreEqual(-10, context.ViewModel.Longitude, "Longitude");
Assert.AreEqual(3.5, context.ViewModel.CoffeeRating, "CoffeeRating");
Assert.AreEqual(4.75, context.ViewModel.AtmosphereRating, "AtmosphereRating");
Assert.AreEqual(200, context.ViewModel.NumberOfVotes, "NumberOfVotes");
}
}
示例2: PhotosPopulatedWhenNavigatedTo
public void PhotosPopulatedWhenNavigatedTo()
{
using (var context = new Context())
{
var cafe = new Cafe
{
Id = "1",
Photos = new[]
{
new Photo
{
SubmittedBy = "Tom",
NumberOfVotes = 2
},
new Photo
{
SubmittedBy = "Dick",
NumberOfVotes = 5
},
new Photo
{
SubmittedBy = "Harry",
NumberOfVotes = 3
}
}
};
context.Cafes.Add(cafe);
context.NavigateTo(cafe.Id);
var expected = cafe.Photos
.OrderByDescending(photo => photo.NumberOfVotes)
.ToArray();
CollectionAssert.AreEqual(
expected.Select(p => p.SubmittedBy).ToArray(),
context.ViewModel.Photos.Select(p => p.SubmittedBy).ToArray());
}
}
示例3: ReviewsPopulatedWhenNavigatedTo
public void ReviewsPopulatedWhenNavigatedTo()
{
using (var context = new Context())
{
var cafe = new Cafe { Id = "1" };
context.Cafes.Add(cafe);
context.Reviews[cafe] = new List<Review>
{
new Review { Comment = "Good!" },
new Review { Comment = "Bad!" },
new Review { Comment = "Ugly!" }
};
context.NavigateTo(cafe.Id);
CollectionAssert.AreEquivalent(
context.Reviews[cafe].Select(r => r.Comment).ToArray(),
context.ViewModel.Reviews.Select(r => r.Comment).ToArray());
}
}
示例4: ShareNotExecutableBeforeOrAfterNavigating
public void ShareNotExecutableBeforeOrAfterNavigating()
{
using (var context = new Context())
{
var cafe = new Cafe { Name = "A" };
context.Cafes.Add(cafe);
Assert.IsFalse(context.ViewModel.Share.CanExecute(null));
context.NavigateTo(cafe.Id);
Assert.IsTrue(context.ViewModel.Share.CanExecute(null));
context.ViewModel.OnNavigatedFrom();
Assert.IsFalse(context.ViewModel.Share.CanExecute(null));
}
}
示例5: ShareCafe
public void ShareCafe()
{
using (var context = new Context())
{
var cafe = new Cafe
{
Name = "Coffee Shop",
Address = "1 Main Street",
PostCode = "X1 XXX"
};
context.Cafes.Add(cafe);
context.NavigateTo(cafe.Id);
context.ViewModel.Share.Execute(null);
Assert.AreEqual(1, context.ShareSource.SharedPackages.Count);
Assert.AreEqual("Coffee Shop", context.ShareSource.SharedPackages.Last().Title);
Assert.AreEqual("1 Main Street, X1 XXX", context.ShareSource.SharedPackages.Last().Text);
}
}
示例6: NavigateToMap
public void NavigateToMap()
{
using (var context = new Context())
{
var cafe = new Cafe
{
Id = "1",
Name = "Coffee Shop",
Longitude = 45.15,
Latitude = 15.45
};
context.Cafes.Add(cafe);
context.NavigateTo(cafe.Id);
context.ViewModel.NavigateToMap.Execute(null);
Assert.AreEqual("Map", context.NavigationService.Current.Location);
Assert.AreEqual("1", context.NavigationService.Current.Parameters["Id"]);
}
}
示例7: ShowDirections
public void ShowDirections()
{
using (var context = new Context())
{
var cafe = new Cafe
{
Id = "1",
Name = "Coffee Shop",
Longitude = 45.15,
Latitude = 15.45
};
context.Cafes.Add(cafe);
context.NavigateTo(cafe.Id);
context.ViewModel.ShowDirections.Execute(null);
Assert.IsNotNull(context.MapLauncher.LastLaunch);
Assert.AreEqual("Coffee Shop", context.MapLauncher.LastLaunch.Name);
Assert.AreEqual(45.15, context.MapLauncher.LastLaunch.Longitude);
Assert.AreEqual(15.45, context.MapLauncher.LastLaunch.Latitude);
}
}
示例8: IsAuthenticationRequired
public async Task IsAuthenticationRequired()
{
using (var context = new Context())
{
context.IdentityService.ClearCurrentIdentity();
var cafe = new Cafe { Id = "1" };
context.Cafes.Add(cafe);
context.NavigateTo(cafe.Id);
Assert.IsTrue(context.ViewModel.IsAuthenticationRequired);
context.IdentityService.AuthenticationRequested +=
(sender, args) => args.Success("Me");
await context.IdentityService.AuthenticateAsync();
Assert.IsFalse(context.ViewModel.IsAuthenticationRequired);
}
using (var context = new Context())
{
context.IdentityService.SetCurrentIdentity("Me");
var cafe = new Cafe { Id = "1" };
context.Cafes.Add(cafe);
context.NavigateTo(cafe.Id);
Assert.IsFalse(context.ViewModel.IsAuthenticationRequired);
}
}
示例9: SubmittedIdentityReviewDoesNotUpdatesReviewCollectionIfNoComment
public void SubmittedIdentityReviewDoesNotUpdatesReviewCollectionIfNoComment()
{
using (var context = new Context())
{
var cafe = new Cafe { Id = "1" };
context.Cafes.Add(cafe);
context.NavigateTo(cafe.Id);
Assert.AreEqual(0, context.ViewModel.Reviews.Count);
context.IdentityService.SetCurrentIdentity("UserA");
context.ViewModel.CurrentIdentityReview.CoffeeRating = 3;
context.ViewModel.CurrentIdentityReview.Submit.Execute(null);
Assert.IsFalse(context.ViewModel.Reviews.Any());
}
}
示例10: SubmittedIdentityReviewUpdatesReviewCollectionIfCommentSupplied
public void SubmittedIdentityReviewUpdatesReviewCollectionIfCommentSupplied()
{
using (var context = new Context())
{
context.IdentityService.SetCurrentIdentity("Me"); ;
var cafe = new Cafe { Id = "1" };
context.Cafes.Add(cafe);
context.NavigateTo(cafe.Id);
context.ViewModel.CurrentIdentityReview.Comment = "My review";
context.ViewModel.CurrentIdentityReview.Submit.Execute(null);
Assert.AreEqual(1, context.ViewModel.Reviews.Count);
var review = context.ViewModel.Reviews.First();
Assert.AreEqual("My review", review.Comment);
Assert.AreEqual("Me", review.SubmittedBy);
context.ViewModel.CurrentIdentityReview.Comment = "My updated review!";
context.ViewModel.CurrentIdentityReview.Submit.Execute(null);
Assert.AreEqual(1, context.ViewModel.Reviews.Count);
review = context.ViewModel.Reviews.First();
Assert.AreEqual("My updated review!", review.Comment);
Assert.AreEqual("Me", review.SubmittedBy);
}
}
示例11: SubmittedIdentityReviewUpdatesVoteSummary
public void SubmittedIdentityReviewUpdatesVoteSummary()
{
using (var context = new Context())
{
context.IdentityService.SetCurrentIdentity("Me");
var cafe = new Cafe { Id = "1" };
context.Cafes.Add(cafe);
context.Reviews[cafe] = new List<Review>
{
new Review
{
Id = Guid.NewGuid().ToString(),
CoffeeRating = 2,
AtmosphereRating = 4,
SubmittedBy = "SomebodyElse"
}
};
context.NavigateTo(cafe.Id);
context.ViewModel.CurrentIdentityReview.CoffeeRating = 4;
context.ViewModel.CurrentIdentityReview.AtmosphereRating = 2;
context.ViewModel.CurrentIdentityReview.Submit.Execute(null);
Assert.AreEqual(2, context.ViewModel.NumberOfVotes);
Assert.AreEqual(3, context.ViewModel.CoffeeRating);
Assert.AreEqual(3, context.ViewModel.AtmosphereRating);
}
}
示例12: ReviewsSortedNewestToOldest
public void ReviewsSortedNewestToOldest()
{
using (var context = new Context())
{
var cafe = new Cafe { Id = "1" };
context.Cafes.Add(cafe);
context.Reviews[cafe] = new List<Review>
{
new Review
{
Comment = "Yesterday",
SubmittedDate = DateTime.Today.AddDays(-1)
},
new Review
{
Comment = "Ancient!",
SubmittedDate = DateTime.Today.AddYears(-5)
},
new Review
{
Comment = "Today",
SubmittedDate = DateTime.Today
}
};
context.NavigateTo(cafe.Id);
Assert.AreEqual("Today", context.ViewModel.Reviews[0].Comment);
Assert.AreEqual("Yesterday", context.ViewModel.Reviews[1].Comment);
Assert.AreEqual("Ancient!", context.ViewModel.Reviews[2].Comment);
}
}
示例13: IdentityReviewResetIfNoReviewByCurrentIdentity
public void IdentityReviewResetIfNoReviewByCurrentIdentity()
{
using (var context = new Context())
{
var cafe = new Cafe { Id = "1" };
context.Cafes.Add(cafe);
context.Reviews[cafe] = new List<Review>
{
new Review
{
Comment = "Somebody else's opinion",
CoffeeRating = 1,
AtmosphereRating = 3,
SubmittedBy = "SomebodyElse"
}
};
context.IdentityService.SetCurrentIdentity("SomebodyElse"); ;
context.NavigateTo(cafe.Id);
context.IdentityService.SetCurrentIdentity("Me"); ;
context.NavigateTo(cafe.Id);
Assert.IsNull(context.ViewModel.CurrentIdentityReview.Comment);
Assert.IsNull(context.ViewModel.CurrentIdentityReview.CoffeeRating);
Assert.IsNull(context.ViewModel.CurrentIdentityReview.AtmosphereRating);
}
}
示例14: IdentityReviewPopulatedWithLatestReviewByCurrentIdentity
public void IdentityReviewPopulatedWithLatestReviewByCurrentIdentity()
{
using (var context = new Context())
{
context.IdentityService.SetCurrentIdentity("Me");
var cafe = new Cafe { Id = "1" };
context.Cafes.Add(cafe);
context.Reviews[cafe] = new List<Review>
{
new Review
{
Comment = "My latest review!",
CoffeeRating = 2,
AtmosphereRating = 4,
SubmittedBy = "Me",
SubmittedDate = DateTime.Today.AddMonths(-1)
},
new Review
{
Comment = "My ancient review",
CoffeeRating = 1,
AtmosphereRating = 1,
SubmittedBy = "Me",
SubmittedDate = DateTime.Today.AddYears(-3)
}
};
context.NavigateTo(cafe.Id);
Assert.AreEqual("My latest review!", context.ViewModel.CurrentIdentityReview.Comment);
Assert.AreEqual(2, context.ViewModel.CurrentIdentityReview.CoffeeRating);
Assert.AreEqual(4, context.ViewModel.CurrentIdentityReview.AtmosphereRating);
}
}
示例15: ReviewsWithoutCommentsSkippedWhenPopulating
public void ReviewsWithoutCommentsSkippedWhenPopulating()
{
using (var context = new Context())
{
var cafe = new Cafe { Id = "1" };
context.Cafes.Add(cafe);
context.Reviews[cafe] = new List<Review>
{
new Review { Comment = null, CoffeeRating = 5 },
new Review { Comment = null, AtmosphereRating = 3 }
};
context.NavigateTo(cafe.Id);
Assert.IsFalse(context.ViewModel.Reviews.Any());
}
}