Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6564203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:56:14+00:00 2026-05-25T13:56:14+00:00

As the title, the code itself as following internal static class ThumbnailPresentationLogic { public

  • 0

As the title, the code itself as following

internal static class ThumbnailPresentationLogic
    {
        public static string GetThumbnailUrl(List<Image> images)
        {
            if (images == null || images.FirstOrDefault() == null)
            {
                return ImageRetrievalConfiguration.MiniDefaultImageFullUrl;
            }

            Image latestImage = (from image in images
                                 orderby image.CreatedDate descending
                                 select image).First();

            Uri fullUrl;

            return 
                Uri.TryCreate(new Uri(ImageRetrievalConfiguration.GetConfig().ImageRepositoryName), latestImage.FileName,
                    out fullUrl)
                    ? fullUrl.AbsoluteUri
                    : ImageRetrievalConfiguration.MiniDefaultImageFullUrl;
        }
    }

I don’t want the unit test go through any methods in ImageRetrievalConfiguration class, so how can I mock ImageRetrievalConfiguration and pass it into ThumbnailPresentationLogic class ??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:56:14+00:00Added an answer on May 25, 2026 at 1:56 pm

    How about you split the method into two – one of which takes a “base URI” and “default Url” and one of which doesn’t:

    internal static class ThumbnailPresentationLogic
    {
        public static string GetThumbnailUrl(List<Image> images)
        {
            return GetThumbnailUrl(images,
               new Uri(ImageRetrievalConfiguration.GetConfig().ImageRepositoryName),
               ImageRetrievalConfiguration.MiniDefaultImageFullUrl);
        }
    
        public static string GetThumbnailUrl(List<Image> images, Uri baseUri,
            string defaultImageFullUrl)
        {
            if (images == null || images.FirstOrDefault() == null)
            {
                return defaultImageFullUrl;
            }
    
            Image latestImage = (from image in images
                                 orderby image.CreatedDate descending
                                 select image).First();
    
            Uri fullUrl;
    
            return 
                Uri.TryCreate(baseUri, latestImage.FileName, out fullUrl)
                    ? fullUrl.AbsoluteUri
                    : defaultImageFullUrl;
        }
    }
    

    Then you can test the logic in the “three-parameter” overload, but the public method doesn’t really contain any logic. You won’t get 100% coverage, but you’ll be able to test the real logic involved.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Title pretty much sums it up. The external style sheet has the following code:
I am using this code to alter the title of an image. Basically it
I'm often having code written as follows try: self.title = item.title().content.string except AttributeError, e:
I have the following code sample upload3.php: <html> <head> <title>PHP Form Upload</title> </head> <body>
The following code works fine as a independant page as itself. But if incorporated
The title is the error I get from the following code: $(this).parent().slideUp(200, function ()
I'm using the following code: string tile = a1; Regex regex= new Regex(@/([a-z])(\d{1,2})/i); if
Confusing title, hopefully some code will clarify: struct MyNestedType { void func(); }; struct
The code below works nicely. Each title in the MySQL table submission is printed
I have some VERY simple code to return the title for a section header:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.