public async void PostAsync_CalledWithItem_ReturnsReponse() { // Given var client = new Mock <IRestClient>(); var response = new OrganizationResponse { Item = new Organization { Name = "blah blah" } }; var request = new OrganizationRequest { Item = new Organization { Name = "blah blah" } }; client.Setup(b => b.PostAsync <OrganizationResponse>( It.IsAny <Uri>(), request, "application/json", It.IsAny <string>(), It.IsAny <string>())) .Returns(TaskHelper.CreateTaskFromResult(response)); var resource = new OrganizationResource(client.Object); // When var result = await resource.PostAsync(request); // Then Assert.Equal(result, response); }
public async void PostAsync_Called_BuildsUri() { // Given var request = new OrganizationRequest { Item = new Organization { Name = "blah blah" } }; var resource = new OrganizationResource(_client.Object); // When await resource.PostAsync(request); // Then _client.Setup(b => b.BuildUri(It.IsAny <string>(), "")); }
public async void PostAsync_CalledWithItem_ReturnsReponse() { // Given var response = new OrganizationResponse { Item = new Organization { Name = "blah blah" } }; var request = new OrganizationRequest { Item = new Organization { Name = "blah blah" } }; _client.Setup(b => b.PostAsync<OrganizationResponse>( It.IsAny<Uri>(), request, "application/json", It.IsAny<string>(), It.IsAny<string>())) .Returns(TaskHelper.CreateTaskFromResult(response)); var resource = new OrganizationResource(_client.Object); // When var result = await resource.PostAsync(request); // Then Assert.That(result, Is.EqualTo(response)); }
public async void PostAsync_Called_BuildsUri() { // Given var request = new OrganizationRequest { Item = new Organization { Name = "blah blah" } }; var resource = new OrganizationResource(_client.Object); // When await resource.PostAsync(request); // Then _client.Setup(b => b.BuildUri(It.IsAny<string>(), "")); }