public void Exception_Is_Rethrown_If_Error_Is_ParentNotFound() { var ex = new RequestFailedException( 500, "Error", ShareErrorCode.AccountAlreadyExists.ToString(), null); _directory.Setup(s => s.ExistsAsync(It.IsAny <CancellationToken>())) .ThrowsAsync(ex); Assert.That(async() => await ClassInTest.ExistsAsync("some-path", CancellationToken.None), Throws.Exception.InstanceOf <RequestFailedException>()); }
public async Task Setup() { SharedSetup(); ShareClient.Setup(s => s.GetDirectoryClient(It.IsAny <string>())) .Returns((_directory = new Mock <ShareDirectoryClient>()).Object); _directory.Setup(s => s.ExistsAsync(It.IsAny <CancellationToken>())) .ReturnsAsync((_existsResponse = new Mock <Response <bool> >()).Object); _existsResponse.Setup(s => s.Value) .Returns(true); _output = await ClassInTest.ExistsAsync(_input = "some-directory", CancellationToken.None); }
public async Task False_Is_Returned_If_Error_Is_ParentNotFound() { var ex = new RequestFailedException( 500, "Error", ShareErrorCode.ParentNotFound.ToString(), null); _directory.Setup(s => s.ExistsAsync(It.IsAny <CancellationToken>())) .ThrowsAsync(ex); var exists = await ClassInTest.ExistsAsync("some-path", CancellationToken.None); Assert.That(exists, Is.False); }
public void Exception_Thrown(string path) { Assert.That(() => ClassInTest.ExistsAsync(path, CancellationToken.None), ThrowsArgumentException("path", "Value must not be null or whitespace")); }