public void TestCancelGetItemByPath() { var request = ItemWebApiRequestBuilder.ReadItemsRequestWithPath(testData.Items.Home.Path).Build(); var cancelToken = CreateCancelTokenWithDelay(10); ScItemsResponse response = null; TestDelegate testCode = async() => { var task = session.ReadItemAsync(request, cancelToken); response = await task; }; var exception = Assert.Catch <OperationCanceledException>(testCode); Assert.IsNull(response); // Desktop (Windows) : "A task was canceled." // iOS : "The Task was canceled" Assert.IsTrue(exception.Message.ToLowerInvariant().Contains("task was canceled")); // @adk : CancellationToken class comparison or scheduling works differently on iOS // Assert.AreEqual(cancelToken, exception.CancellationToken); }
public async void TestGetItemWithDbLanguageAndVersionFromRequest() { const string Db = "master"; const string Language = "da"; const int Version = 1; var request = ItemWebApiRequestBuilder.ReadItemsRequestWithId(testData.Items.ItemWithVersions.Id) .Database(Db) .Language(Language) .Version(Version) .Payload(PayloadType.Content) .Build(); var response = await sessionAuthenticatedUser.ReadItemAsync(request); testData.AssertItemsCount(1, response); var resultItem = response[0]; testData.AssertItemsAreEqual(testData.Items.ItemWithVersions, resultItem); var source = new ItemSource(Db, Language, Version); testData.AssertItemSourcesAreEqual(source, resultItem.Source); Assert.AreEqual("Danish version 1 master", resultItem["Title"].RawValue); }