public async void GetAsync_Called_CallsBuildUriWithFieldId() { // Given _client.Setup(b => b.BuildUri(It.IsAny <string>(), It.Is <string>(s => s.Contains("321")))).Returns(new Uri("http://search")); var resource = new OrganizationResource(_client.Object); // When await resource.GetAsync(321); // Then _client.Verify(c => c.BuildUri(It.Is <string>(s => s.Contains("321")), "")); }
public async void GetAsync_Called_CallsBuildUriWithFieldId() { // Given _client.Setup(b => b.BuildUri(It.IsAny<string>(), It.Is<string>(s => s.Contains("321")))).Returns(new Uri("http://search")); var resource = new OrganizationResource(_client.Object); // When await resource.GetAsync(321); // Then _client.Verify(c => c.BuildUri(It.Is<string>(s => s.Contains("321")), "")); }
public async void GetAsync_Called_ReturnsResponse() { // Given var response = new OrganizationResponse { Item = new Organization { Id = 1 } }; _client.Setup(b => b.GetAsync <OrganizationResponse>(It.IsAny <Uri>())).Returns(TaskHelper.CreateTaskFromResult(response)); var resource = new OrganizationResource(_client.Object); // When var result = await resource.GetAsync(321); // Then Assert.That(result, Is.EqualTo(response)); }
public async void GetAsync_Called_ReturnsResponse() { // Given var response = new OrganizationResponse { Item = new Organization { Id = 1 } }; _client.Setup(b => b.GetAsync<OrganizationResponse>( It.IsAny<Uri>(), It.IsAny<string>(), It.IsAny<string>())) .Returns(TaskHelper.CreateTaskFromResult(response)); var resource = new OrganizationResource(_client.Object); // When var result = await resource.GetAsync(321); // Then Assert.That(result, Is.EqualTo(response)); }
public async void GetAsync_Called_ReturnsResponse() { // Given var client = new Mock <IRestClient>(); var response = new OrganizationResponse { Item = new Organization { Id = 1 } }; client.Setup(b => b.GetAsync <OrganizationResponse>( It.IsAny <Uri>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(TaskHelper.CreateTaskFromResult(response)); var resource = new OrganizationResource(client.Object); // When var result = await resource.GetAsync(321); // Then Assert.Equal(result, response); }