public async Task ItemCreateLinkRequest_PostAsync() { using (var httpResponseMessage = new HttpResponseMessage()) using (var responseStream = new MemoryStream()) using (var streamContent = new StreamContent(responseStream)) { httpResponseMessage.Content = streamContent; var requestUrl = Constants.Authentication.OneDriveConsumerBaseUrl + "/drive/items/id/action.createLink"; this.httpProvider.Setup( provider => provider.SendAsync( It.Is<HttpRequestMessage>( request => request.RequestUri.ToString().StartsWith(requestUrl)))) .Returns(Task.FromResult(httpResponseMessage)); var expectedPermission = new Permission { Id = "id", Link = new SharingLink { Type = "edit" } }; this.serializer.Setup( serializer => serializer.SerializeObject(It.IsAny<ItemCreateLinkRequestBody>())) .Returns("request body value"); this.serializer.Setup( serializer => serializer.DeserializeObject<Permission>(It.IsAny<string>())) .Returns(expectedPermission); var permission = await this.oneDriveClient.Drive.Items["id"].CreateLink("edit").Request().PostAsync(); Assert.IsNotNull(permission, "Permission not returned."); Assert.AreEqual(expectedPermission, permission, "Unexpected permission returned."); } }
/// <summary> /// Creates the specified Permission using PUT. /// </summary> /// <param name="permission">The Permission to create.</param> /// <returns>The created Permission.</returns> public async Task<Permission> CreateAsync(Permission permission) { this.ContentType = "application/json"; this.Method = "PUT"; var entity = await this.SendAsync<Permission>(permission); this.InitializeCollectionProperties(entity); return entity; }
/// <summary> /// Creates the specified Permission using PUT. /// </summary> /// <param name="permissionToCreate">The Permission to create.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created Permission.</returns> public async System.Threading.Tasks.Task<Permission> CreateAsync(Permission permissionToCreate, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "PUT"; var newEntity = await this.SendAsync<Permission>(permissionToCreate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(newEntity); return newEntity; }
/// <summary> /// Initializes any collection properties after deserialization, like next requests for paging. /// </summary> /// <param name="permission">The <see cref="Permission"/> with the collection properties to initialize.</param> private void InitializeCollectionProperties(Permission permission) { }
/// <summary> /// Adds the specified Permission to the collection via POST. /// </summary> /// <param name="permission">The Permission to add.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created Permission.</returns> public System.Threading.Tasks.Task<Permission> AddAsync(Permission permission, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; return this.SendAsync<Permission>(permission, cancellationToken); }
/// <summary> /// Adds the specified Permission to the collection via POST. /// </summary> /// <param name="permission">The Permission to add.</param> /// <returns>The created Permission.</returns> public System.Threading.Tasks.Task<Permission> AddAsync(Permission permission) { return this.AddAsync(permission, CancellationToken.None); }
/// <summary> /// Creates the specified Permission using PUT. /// </summary> /// <param name="permissionToCreate">The Permission to create.</param> /// <returns>The created Permission.</returns> public System.Threading.Tasks.Task<Permission> CreateAsync(Permission permissionToCreate) { return this.CreateAsync(permissionToCreate, CancellationToken.None); }
/// <summary> /// Adds the specified Permission to the collection via POST. /// </summary> /// <param name="permission">The Permission to add.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created Permission.</returns> public System.Threading.Tasks.Task <Permission> AddAsync(Permission permission, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; return(this.SendAsync <Permission>(permission, cancellationToken)); }
/// <summary> /// Adds the specified Permission to the collection via POST. /// </summary> /// <param name="permission">The Permission to add.</param> /// <returns>The created Permission.</returns> public System.Threading.Tasks.Task <Permission> AddAsync(Permission permission) { return(this.AddAsync(permission, CancellationToken.None)); }
/// <summary> /// Creates the specified Permission using PUT. /// </summary> /// <param name="permissionToCreate">The Permission to create.</param> /// <returns>The created Permission.</returns> public System.Threading.Tasks.Task <Permission> CreateAsync(Permission permissionToCreate) { return(this.CreateAsync(permissionToCreate, CancellationToken.None)); }
/// <summary> /// Initializes any collection properties after deserialization, like next requests for paging. /// </summary> /// <param name="permissionToInitialize">The <see cref="Permission"/> with the collection properties to initialize.</param> private void InitializeCollectionProperties(Permission permissionToInitialize) { }