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

  • Home
  • SEARCH
  • 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 8198883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:03:23+00:00 2026-06-07T06:03:23+00:00

I have the following test method: [TestMethod] public void TestHarvestMethod() { HarvestTargetTimeRangeUTC time =

  • 0

I have the following test method:

[TestMethod]
public void TestHarvestMethod()
{
    HarvestTargetTimeRangeUTC time = new HarvestTargetTimeRangeUTC();
    time.StartTimeUTC = new DateTime(2008, 01, 01, 00, 00, 00, DateTimeKind.Utc);
    time.EndTimeUTC = DateTime.UtcNow;
    XElement lIntelexReport = XElement.Parse(rawXml);
    Harvester target = new Harvester();
    target.ConfigureHarvester((System.Configuration.Configuration)null);  
    var res = target.Harvest(time);
    Console.WriteLine(res);
 }

That works in conjunction with this method:

public void ConfigureHarvester(System.Configuration.Configuration configuration)
{
    reportId = Int32.Parse(configuration.AppSettings.Settings["IncidentReport"].Value);
}

to test this method:

public XElement Harvest(HarvestTargetTimeRangeUTC ranges)
{
    XElement lIntelexReport = IntelexServiceCall();  
    return XMLConversion(QueryData(ranges, lIntelexReport));
}

The problem is that I receive Null Exception error stating that “Object reference not set to an instance of an object.” on this line:

reportId = Int32.Parse(configuration.AppSettings.Settings["IncidentReport"].Value);

which I am almost positive is caused by the null value here:

target.ConfigureHarvester((System.Configuration.Configuration)null);

The System.Configuration in the above line is one used commonly in this shop, but normally for a method such as this:

public void ConfigureHarvester(System.Configuration.Configuration configuration)
{
    context = new PlannedOutageFactorDataContext();            
}

So my reportid field is obviously looking for something other than a null value, the problem is I don’t know exactly WHAT it’s looking for. Ive read the MSDN for System.Configuration but it was really no help. I would appreciate it if some one could point me in the right direction.

  • 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-07T06:03:24+00:00Added an answer on June 7, 2026 at 6:03 am

    Its looking for you to pass it a copy of your web.config or app.config value so it can extract the information it requires from this (held in the AppSettings section)

    For example

    <configuration>
        <appSettings>
            <add key="IncidentReport" value="1" />
        </appSettings> 
    </configuration>
    

    If your testing a webpage, a lot of the time you need to set the location of the webservice so that it can grab a copy of the web.config from your website.

    If your developing a console/desktop app then make sure you have an app.config file

    Alternativly you can manually pass it in using

    System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(exePath);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following unit test: [TestMethod] public void Execute_Sends_Email_To_User() { // Setup InitializeTestEntities();
I have the following test case [TestMethod()] [DeploymentItem(Courses.sdf)] public void RemoveCourseConfirmedTest() { CoursesController_Accessor target
I have the following code: [TestMethod] public void TestFoo() { Foo(null); } private void
consider the following test class: [TestClass] public class ExampleTests { [TestMethod] public void FileDoesNotExists()
I have the following unit test defined to test my model binder: [TestMethod] public
I have the following method: public void SetHttpStatusCode(HttpStatusCode httpStatusCode) { Response.StatusCode = (int)httpStatusCode; }
I have following code: [TestMethod] public void StartWorkInFirstThread() { if (SynchronizationContext.Current == null) SynchronizationContext.SetSynchronizationContext(
Came across the following MS Unit Test: [TestMethod] public void PersonRepository_AddressCountForSinglePerson_IsNotEqualToZero() { // Arrange.
i have a problem with a c# test method. it looks like: public void
I have following spec to test controller method: context #create do it should redirect

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.