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 8075147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:53:43+00:00 2026-06-05T14:53:43+00:00

Based on my unit-test I’m trying to calculate when the next instance of 0400

  • 0

Based on my unit-test I’m trying to calculate when the next instance of 0400 hrs are and return this;

public void when_given_a_date_i_should_return_next_time_of_day_that_equals_04_hrs()
{
    var dateTimeNow = new DateTime(2012, 6, 11, 14, 22, 0);
    var dateTimeExpected = new DateTime(2012, 6, 12, 4, 0, 0);

    Assert.AreEqual(dateTimeExpected, t.CalculateIncremental(dateTimeNow));
}

The point of CalculateIncremental is to publish a message with nservicebus every 24 hrs, at exactly 04:00 am using RequestUtcTimeout. This again to trigger some functionality.

  • 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-06-05T14:53:44+00:00Added an answer on June 5, 2026 at 2:53 pm

    Something like this:

    private static DateTime GetNext4AM(DateTime input)
    {
        var result = new DateTime(input.Year, input.Month, input.Day, 4, 0, 0);
    
        if (result > input)
        {
            return result;
        }
        else
        {
            return result.AddDays(1);   
        }
    }
    

    Should return the next occurrence of 4 AM, which can be on the same day (if the input is earlier than 04:00) or the next. However:

    The point [..] is to publish a message with nservicebus every 24 hrs, at exactly 04:00 am using RequestUtcTimeout. This again to trigger some functionality.

    You should use a scheduler for that, like Quartz.NET or simply the Windows Task Scheduler.

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

Sidebar

Related Questions

I have a unit test project based on UnitTest++. I usually put a breakpoint
Could a sensible unit test be written for this code which extracts a rar
I am trying to unit test a class that does SAX parsing and creates
I was trying to setup a unit test for a private inner class, but
I've converted a project to VS2010. It includes a googletest based unit test project.
Visual studio created a unit test project for me based on a method (right-click
I am using a simple unit test based test runner to test my Django
How to sort list based on its element value? In my unit test class,
I am trying to write a unit test for an Action who's model uses
I am getting this error when running some unit tests (using the Test::Unit module

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.