Link to home
Start Free TrialLog in
Avatar of satmisha
satmishaFlag for India

asked on

How to test methos returns nothing in nUnit

Hi Team,

I have the following method which returns nothing and takes nothing, I need to write the test method using the NUnit framework in C#. How could I achieve that?

Public Async Task ReceiveDataOnQueue()
{
   Try
   {
      If(Dev)
         {
            cred = GenerateToken();
            sqlClient = new AmazonSQlClient(cred, endPoint);
         }
   else{
         
       sqlClient = new AmazonSQlClient(cred, endPoint)
      }
   
   ReadMessageFromQueue(sqlClient);
   DeleteMessageFromQueue();

   }
   Catch(Exception Ex)
   {
      Throw Ex
   }
}

Open in new window


Nishant
Avatar of ste5an
ste5an
Flag of Germany image

A method like this does not needed to be tested. Cause it only contains side-effects.

Maybe you rephrase your question and explain what you like test for what reason.

Also your method contains some smells, I would even say anti-patterns. You should view The Clean Code Talks - "Global State and Singletons" and "The Clean Code Talks -- Unit Testing".
Avatar of satmisha

ASKER

Thank you ste5an for your prompt reply.

I am totally novice to testing got stuck on this. What I need to write is a nUnit test case for the above-said method, there any many more but if I get the help on one probably I can start writing others.

Appreciate it if you could help me out with some link through which I can start with it.

experts pls help...
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thank you, ste5an.