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