question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How can i mock CloudBlob.CopyState?

See original GitHub issue

Hi 👋

I’ve got some code that uploads a URL to a blob in the background, utilizing the following methods:

  • CloudBlob.StartCopyAsync
  • CloudBlob.FetchAttributesAsync
  • CloudBlob.CopyState

I’m trying to unit test my method that uses the above, and hence mock out the calls to Azure. The first two methods are virtual so i can mock out fine, but the last one is a get:

//
// Summary:
//     Gets the state of the most recent or pending copy operation.
public CopyState CopyState { get; }

So during my test, CopyState.Status will never be complete and will always be in it’s initial state.

Other than creating a wrapper class (which i always try and avoid), is there any other way i can mock out this method? For example: is there a way i can set some kind of state/property in the CloudBlob class so that the CopyState.Status will have a value of Success?

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
PureKromecommented, Jul 9, 2018

@erezvani1529 Heya 👋 Any chance this issue could be scheduled for resolution in a next-release plz?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mocking a CloudBlockBlob and have it return a stream
Those are two different streams. Grab the stream passed in the argument of the mock in a Callback and copy the test stream...
Read more >
com.microsoft.azure.storage.blob.BlobProperties. ...
Returns the blob's copy state. * * @return A {@link CopyState} object that represents the copy state of the blob. */ public CopyState...
Read more >
CloudBlob.CopyState Property - Storage
A CopyState object containing the copy state, or null if there is no copy state for the blob. Applies to. Product, Versions. Azure...
Read more >
Class BlobsModelFactory | Azure SDK for Net
Class BlobsModelFactory. BlobsModelFactory provides utilities for mocking. ... BlobCopyInfo(ETag, DateTimeOffset, String, CopyStatus) ... BlobItem blob ...
Read more >
CloudBlob.CopyState is null after direct account-to-account ...
This issue ended up being due to a logic error whereby blobs would be 'touched' resulting in the copy state being removed. The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found