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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:50:29+00:00 2026-05-11T14:50:29+00:00

public DataSet ExampleMethod(int param1, string param2, Hashtable ht) { if(ht==null) { ht = new

  • 0
   public DataSet ExampleMethod(int param1, string param2, Hashtable ht)    {      if(ht==null)     {         ht = new Hashtable();     }     ht.Add('testKey','testData');       DataSet ds = new DataSet();     ds.Tables.Add();     ds.Tables[0].Columns.Add('Column1');     ds.Tables[0].Columns.Add('Column2');     ds.Tables[0].Columns.Add('Column3');     return ds ;       }  

this is just a example method now since i have a string ,a int and a hash table type as a input ,i can pass random values for int and string but what type of value will i pass for hash table type in order to unit test this method . and i also want a sample Nunit Fixture code for this method so that i can test it in Nunit framework .since my method returns a dataset how do i write a text fixture for it because i use AREequals.(5,add(2,3)) if it returns a int .so what to do for a method when it returns a Dataset

  • 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. 2026-05-11T14:50:30+00:00Added an answer on May 11, 2026 at 2:50 pm

    You can create a HashTable in the TestMethod or the TestFixture with dummy data and pass that object. Am I understanding you right?

    In the [SetUp] method you populate your HashTable with dummy data.

    Hashtable ht = new Hashtable();  [SetUp] public void SetUp() {    ht.Add( 'key1', 'value1' );    ht.Add( 'key2', 'value2' );    ht.Add( 'key3', 'value3' ); } 

    I can see you real question is about the Assert of the returned DataSet. You can still use Assert.AreEqual, but instead test that the DataSet contain the cell data you’d expect given the HashTable.

    Assert.AreEqual( ht['key1'], ds.Tables[0].Rows[0][0].ToString() ); Assert.AreEqual( ht['key1'], ds.Tables[0].Rows[0][1].ToString() ); 

    You could use a loop for this.

    Your TestMethod could look like this.

    [Test] public void Should_Do_Stuff() {     MyClass myObject = new MyClass();      DataSet ds = myObject.ExampleMethod( 1, 'string', ht );      Assert.AreEqual( ds.Tables[0].Rows.Count, ht.Count );     Assert.AreEqual( ht['key1'], ds.Tables[0].Rows[0][0].ToString() );     Assert.AreEqual( ht['key1'], ds.Tables[0].Rows[0][1].ToString() ); } 

    Hope that answered you question.

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

Sidebar

Ask A Question

Stats

  • Questions 95k
  • Answers 95k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can check the system tables, MSysObjects and MSysQueries for… May 11, 2026 at 6:59 pm
  • Editorial Team
    Editorial Team added an answer You can only use column aliases in GROUP BY, ORDER… May 11, 2026 at 6:59 pm
  • Editorial Team
    Editorial Team added an answer Microsoft Product Support has resolved this question: It's by design.… May 11, 2026 at 6:59 pm

Related Questions

How can I retuen a Object from a web service: [WebMethod] public DataSet GetVendors(string
How would I refactor this to get it to return a string not a
How can I write code for the below method so that it can be
In an attempt to add some parameter validation and correct usage semantics to our

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.