public async void PostAsync_WithSuccessOnSecondOverload_MustResultSpectedValue() { var token = TokenBuilder.Create().Build(); var requestUri = "someDummyUrl"; var expected = new ProfileVM { ID = "Some Test ID" }; var httpClient = HandlerBuilder.Create().WithResult(expected).Build(); var client = new OneDriveClient(token, httpClient); var value = await client.PostAsync <ProfileVM, ProfileVM>(requestUri, expected); Assert.Equal(expected.ID, value.ID); }
public async void PostAsync_WithException_MustThrowException() { var token = TokenBuilder.Create().Build(); var requestUri = "someDummyUrl"; var exception = new Exception("Some dummy exception"); var httpClient = HandlerBuilder.Create().WithException(exception).Build(); var client = new OneDriveClient(token, httpClient); var expected = exception; var value = await Assert.ThrowsAsync <Exception>(async() => await client.PostAsync(requestUri, new StringContent(""))); Assert.NotNull(value); Assert.Equal(expected.Message, value.Message); }