public void Can_Update_Key_For_Item() { // Arrange var page = new Page { Name = "New Page" }; var model = new FakeModel(); var culture = new CultureInfo("en"); var site = new Site("English", culture); site.Trie = CreateTrie(); var session = new Mock<IAsyncDocumentSession>(); session.Setup(documentSession => documentSession.StoreAsync(page, CancellationToken.None)); session.Setup(documentSession => documentSession.LoadAsync<Site>("sites/en", CancellationToken.None)) .ReturnsAsync(site); // Act var operation = new AsyncLocalizationOperation(session.Object, culture); operation.Page = new Page { Id = "articles/1" }; Task task = Task.Run(() => operation.ForModel(model).ForUrl("/changed-slug").StoreAsync(page)); task.Wait(); // Assert Assert.True(task.IsCompleted); Assert.Equal(3, site.Trie.Count); Assert.True(site.Trie.Keys.Contains("/changed-slug")); }
public void Can_Resolve_Path_To_Page_To_Specified_Culture() { // Arrange var trie = CreateTrie(); var currentRequestCulture = new Mock<RequestCulture>("en"); var trieResolver = new Mock<IRouteResolverTrie>(MockBehavior.Strict); trieResolver.Setup(t => t.LoadTrieAsync(It.IsAny<RequestCulture>())) .ReturnsAsync(trie); var mapper = new Mock<IControllerMapper>(MockBehavior.Strict); var page = new Page { Id = "articles/1" }; var virtualPathResolver = new DefaultVirtualPathResolver(trieResolver.Object, mapper.Object); var virtualPathContext = CreateVirtualPathContext(new { page, culture = "sv" }); var defaultRequestCulture = new RequestCulture("en"); // Act var result = virtualPathResolver.Resolve(virtualPathContext, defaultRequestCulture, currentRequestCulture.Object); // Assert Assert.NotNull(result); Assert.True(result.HasValue); Assert.Equal("/sv/article", result.Value); }