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.

[QUERY] Is it possible to set LastModified property from BlobContainerProperties?

See original GitHub issue

Query/Question

I want to unit test a logic in my code. The logic gets a BlobContainerClient from the storage, get all blobs from it, and then filter the blobs for those who last modified date is before last week and delete those. I have somethind as the following:

                var blobContainerClient = storageWrapper.GetContainerReference(_connectionString, containerName); //returns a BlobContainerClient
                var dateLastWeek = DateTime.Now.AddDays(-7);

                var desiredBlobs = blobContainerClient
                    .GetBlobs()
                    .ToList()
                    .Where(x => x.Properties.LastModified < dateLastWeek)
                    .ToList();

But then I realized that the BlobContainerProperties.LastModified is a get only property, and non virtual (so I can’t mock it’s return).

image

Is there a way to create one of these objects with the LastModified date so I can use it in my test logic?

Environment:

  • .Net Version: Full Framework 4.8
  • New version: Azure.Storage.Blobs v12.8.0
  • IDE and version : Visual Studio 16.8.5

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

0reactions
WillRock19commented, Apr 6, 2021

It worked! Thank you very much 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Update LastModified on an Azure Blob
Azure allows you to add METADATA to the containers and blobs. LastModified is an internal property and there is no point to let...
Read more >
How to get "LastModifiedDate" for a file in Azure Blob ...
I have a variable called results which has a couple methods, main one being LastUpdatedDate which should be set to the LastModifiedDate from ......
Read more >
Five recommendations to amplify your Azure Storage Blobs ...
Azure storage blob container: In this blog, we will learn about how Cerebrata can be used to amplify your Azure Blobs Storage.
Read more >
Microsoft Azure Blob Storage connector
This connector has the following properties ((Get operation only) for output documents that you can set or reference in various step parameters.
Read more >
Azure Blob Storage
The Azure Blob Storage origin reads objects in ascending order based on the object name or the last modified timestamp. For best performance...
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