public async Task FolderOperation_GetAccessToNotExistingFolder_ReturnsNotFound() { var response = await JohnApi.GetFolder(Guid.NewGuid()); response.EnsureSuccessStatusCode(); //Should not return Forbid status code response.StatusCode.Should().Be(HttpStatusCode.NotFound); }
public async Task FolderOperation_MoveFolder_MovedFolder() { var responseFirst = await JohnApi.GetFolder(_firstFolderId); responseFirst.EnsureSuccessStatusCode(); var jsonFirstFolder = JToken.Parse(await responseFirst.Content.ReadAsStringAsync()); var responseSecond = await JohnApi.GetFolder(_secondFolderId); responseSecond.EnsureSuccessStatusCode(); var jsonSecondFolder = JToken.Parse(await responseSecond.Content.ReadAsStringAsync()); var folders = new Dictionary <string, JToken> { { "first", jsonFirstFolder }, { "second", jsonSecondFolder } }; foreach (var dirFolder in folders) { var folder = dirFolder.Value; folder.Should().NotBeNullOrEmpty(); folder["parentId"].ToString().Should().BeEquivalentTo(JohnId.ToString()); } await JohnApi.MoveFolder(folders["first"]["id"].ToObject <Guid>(), folders["first"]["version"].ToObject <int>(), folders["second"]["id"].ToObject <Guid>()); Harness.WaitWhileFolderMoved(_firstFolderId); folders["first"] = JToken.Parse(await JohnApi.GetFolder(folders["first"]["id"].ToObject <Guid>()) .GetAwaiter() .GetResult() .Content .ReadAsStringAsync()); folders["second"] = JToken.Parse(await JohnApi.GetFolder(folders["second"]["id"].ToObject <Guid>()) .GetAwaiter() .GetResult() .Content .ReadAsStringAsync()); folders["first"].Should().ContainsJson($@" {{ 'id': '{folders["first"]["id"]}', 'createdBy': '{JohnId}', 'createdDateTime': *EXIST*, 'updatedBy': '{JohnId}', 'updatedDateTime': *EXIST*, 'parentId': '{folders["second"]["id"].ToObject<Guid>()}', 'ownedBy': '{JohnId}', 'name': 'folder 1', 'status': 'Created', 'version': 2 }}" ); }
public async Task FolderOperation_DeleteFolder_FolderIsDeleted() { var response = await JohnApi.GetFolder(_folderId); response.EnsureSuccessStatusCode(); var jsonFolder = JToken.Parse(await response.Content.ReadAsStringAsync()); await JohnApi.DeleteFolder(_folderId, jsonFolder["version"].ToObject <int>()); Harness.WaitWhileFolderDeleted(_folderId); var notFoundResponse = await JohnApi.GetFolder(_folderId); notFoundResponse.IsSuccessStatusCode.Should().Be(false); response.StatusCode.Should().Be(HttpStatusCode.Forbidden); }
public async Task FolderOperations_CreateNewFolder_ExpectedCreatedFolder() { var response = await JohnApi.GetFolder(_folderId); response.EnsureSuccessStatusCode(); var jsonFolder = JToken.Parse(await response.Content.ReadAsStringAsync()); jsonFolder.Should().ContainsJson($@" {{ 'id': '{_folderId}', 'createdBy': '{JohnId}', 'createdDateTime': *EXIST*, 'updatedBy': '{JohnId}', 'updatedDateTime': *EXIST*, 'ownedBy': '{JohnId}', 'name': 'new folder', 'status': 'Created', 'version': 1 }}" ); }