public async Task SortBy_LastAccessed() { FakeClock.Run(); var articles = new List <ArticleViewModel> { }; articles.Add(await SetupArticle()); articles.Add(await SetupArticle()); articles.Add(await SetupArticle()); var upsertRequest = new ArticleReadingProgressUpsert() { ConlluTokenPointer = new() { DocumentIndex = 0, ParagraphIndex = 1, SentenceIndex = 2, TokenIndex = 3, }, ReadRatio = 0.5m, }; await ArticlesController.UpsertReadingProgress(articles[1].Id, upsertRequest); await ArticlesController.UpsertReadingProgress(articles[2].Id, upsertRequest); await ArticlesController.UpsertReadingProgress(articles[0].Id, upsertRequest); (await List(null, SortBy.LastAccessed)) .Items .Select(x => x.Id) .ShouldBe(new List <Guid> { articles[0].Id, articles[2].Id, articles[1].Id, }); }
public async Task SortBy_OrderInCollection() { FakeClock.Run(); var articles = new List <ArticleViewModel> { await SetupArticle(), }; var articleCollectionId = articles.First().ArticleCollectionId; // Mess around with the state. articles.Add(await SetupArticle(articleCollectionId: articleCollectionId)); articles.Add(await SetupArticle()); articles.Add(await SetupArticle(articleCollectionId: articleCollectionId)); await ArticlesController.Update(articles[0].Id, new ArticleUpdate { Name = "Name", Text = "Text", }); // Should throw because article's order only applies within the belonging collection await List(null, SortBy.OrderInCollection) .ShouldThrowAsync <ValidationException>(); (await List(articleCollectionId, SortBy.OrderInCollection)) .Items .Select(x => x.Id) .ShouldBe(new List <Guid> { articles[0].Id, articles[1].Id, // No [2] because it belongs to another collection articles[3].Id, }); }